46
46
- name : Run twine checker
47
47
run : |
48
48
twine check dist/*
49
+
50
+ yarn_build :
51
+ permissions :
52
+ contents : read # to fetch code (actions/checkout)
53
+
54
+ name : Build JS with Yarn
55
+ runs-on : ubuntu-latest
56
+ timeout-minutes : 5
57
+ steps :
58
+ - name : Checkout
59
+ uses : actions/checkout@v4
60
+ - name : Install yarn
61
+ run : sudo apt install yarn -y
62
+ - name : Get yarn cache dir
63
+ run : echo "yarn_cache=$(yarn cache dir)" >> "$GITHUB_ENV"
64
+ - name : Cache node modules
65
+ uses : actions/cache@v3
66
+ id : cache-modules
67
+ with :
68
+ key : node-${{ hashFiles('admin-js/package.json') }}-${{ github.run_id }}
69
+ restore-keys : node-${{ hashFiles('admin-js/package.json') }}
70
+ path : |
71
+ ${{ env.yarn_cache }}
72
+ admin-js/node_modules
73
+ - name : Yarn install
74
+ run : yarn install
75
+ working-directory : admin-js/
76
+ - name : Cache output files
77
+ uses : actions/cache@v3
78
+ id : cache_admin_js
79
+ with :
80
+ key : yarn-${{ hashFiles('admin-js/src/*') }}-${{ hashFiles('admin-js/yarn.lock') }}
81
+ path : |
82
+ aiohttp_admin/static/admin.js
83
+ aiohttp_admin/static/*.map
84
+ - name : Yarn build
85
+ if : steps.cache_admin_js.outputs.cache-hit != 'true'
86
+ run : yarn build
87
+ working-directory : admin-js/
88
+
49
89
test :
50
90
name : Test
91
+ needs : yarn_build
51
92
strategy :
52
93
matrix :
53
94
pyver : ['3.9', '3.10', '3.11', '3.12']
@@ -65,14 +106,14 @@ jobs:
65
106
python-version : ${{ matrix.pyver }}
66
107
cache : ' pip'
67
108
cache-dependency-path : ' **/requirements*.txt'
68
- - name : Install yarn
69
- run : sudo apt install yarn -y
70
- - name : Yarn install
71
- run : yarn install
72
- working-directory : admin-js/
73
- - name : Yarn build
74
- run : yarn build
75
- working-directory : admin-js/
109
+ - name : Restore cached JS files
110
+ uses : actions/cache/restore@v3
111
+ with :
112
+ key : yarn-${{ hashFiles('admin-js/src/*') }}
113
+ fail-on-cache-miss : true
114
+ path : |
115
+ aiohttp_admin/static/admin.js
116
+ aiohttp_admin/static/*.map
76
117
- name : Install dependencies
77
118
uses : py-actions/py-dependency-install@v4
78
119
with :
0 commit comments