Skip to content

Commit c170ff8

Browse files
feat(ci): more aggressive caching for node & npm installs
Signed-off-by: Victor Adossi <[email protected]>
1 parent 0badb40 commit c170ff8

File tree

1 file changed

+93
-6
lines changed

1 file changed

+93
-6
lines changed

.github/workflows/main.yml

Lines changed: 93 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,23 @@ jobs:
2222
- uses: actions/setup-node@v3
2323
with:
2424
node-version: "latest"
25+
2526
- name: Install Rust
2627
run: rustup update stable --no-self-update
2728
- uses: Swatinem/rust-cache@v2
2829
with:
2930
shared-key: jco-${{ hashFiles('Cargo.lock') }}
31+
32+
- name: Cache npm install
33+
id: cache-node-modules
34+
uses: actions/cache@v4
35+
with:
36+
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
37+
path: |
38+
node_modules
3039
- name: Install NPM packages
3140
run: npm install
41+
3242
- name: Build
3343
run: npm run build
3444
- name: Upload Jco Build
@@ -66,7 +76,8 @@ jobs:
6676
- os: windows-latest
6777
node: 18.x
6878
runs-on: ${{ matrix.os }}
69-
needs: [build]
79+
needs:
80+
- build
7081
steps:
7182
- uses: actions/checkout@v4
7283
- uses: actions/setup-node@v3
@@ -108,10 +119,29 @@ jobs:
108119
mkdir .weval-bin
109120
mv weval-${{ steps.weval-meta.outputs.version }}-aarch64-macos/weval .weval-bin/
110121
122+
- name: Cache npm install
123+
id: cache-npm
124+
uses: actions/cache@v4
125+
with:
126+
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
127+
path: |
128+
node_modules
111129
- name: Install NPM packages
112130
run: |
113131
npm install
114132
133+
- name: Cache puppeteer install
134+
id: cache-puppeteer
135+
uses: actions/cache@v4
136+
with:
137+
key: puppeteer-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
138+
path: |
139+
/home/runner/.cache/puppeteer
140+
- name: Install puppeteer
141+
if: steps.cache-puppeteer.outputs.cache-hit != 'true'
142+
run: |
143+
npx puppeteer browsers install chrome
144+
115145
- name: Download Build
116146
uses: actions/download-artifact@v4
117147
with:
@@ -169,36 +199,56 @@ jobs:
169199
test-wasi-deno:
170200
name: Jco Deno WASI Conformance Tests
171201
runs-on: "ubuntu-latest"
172-
needs: [build, build-wasi-tests]
202+
needs:
203+
- build
204+
- build-wasi-tests
173205
steps:
174206
- uses: actions/checkout@v4
175207
- uses: actions/setup-node@v3
176208
with:
177209
node-version: "latest"
210+
178211
- uses: denoland/setup-deno@v1
179212
with:
180213
deno-version: v1.x
214+
215+
- name: Cache npm install
216+
id: cache-npm
217+
uses: actions/cache@v4
218+
with:
219+
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
220+
path: |
221+
node_modules
181222
- name: Install NPM packages
182223
run: npm install
224+
183225
- name: Download Build
184226
uses: actions/download-artifact@v4
185227
with:
186228
name: jco-build
187229
path: obj
230+
188231
- name: Download WASI Tests
189232
uses: actions/download-artifact@v4
190233
with:
191234
name: wasi-tests
192235
path: tests/gen
236+
193237
- name: WASI Preview 2 Conformance
194238
run: cargo test deno_
195239

196240
test-wasi:
197241
name: Jco Node.js WASI Conformance Tests
198242
strategy:
199243
matrix:
200-
os: [ubuntu-latest, windows-latest, macos-latest]
201-
node: [18.x, 20.x, latest]
244+
os:
245+
- ubuntu-latest
246+
- windows-latest
247+
- macos-latest
248+
node:
249+
- 18.x
250+
- 20.x
251+
- latest
202252
exclude:
203253
- os: macos-latest
204254
node: 20.x
@@ -210,14 +260,25 @@ jobs:
210260
node: 18.x
211261
fail-fast: false
212262
runs-on: ${{ matrix.os }}
213-
needs: [build, build-wasi-tests]
263+
needs:
264+
- build
265+
- build-wasi-tests
214266
steps:
215267
- uses: actions/checkout@v4
216268
- uses: actions/setup-node@v3
217269
with:
218270
node-version: ${{ matrix.node }}
271+
272+
- name: Cache npm install
273+
id: cache-npm
274+
uses: actions/cache@v4
275+
with:
276+
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
277+
path: |
278+
node_modules
219279
- name: Install NPM packages
220280
run: npm install
281+
221282
- name: Download Build
222283
uses: actions/download-artifact@v4
223284
with:
@@ -236,8 +297,17 @@ jobs:
236297
runs-on: ubuntu-latest
237298
steps:
238299
- uses: actions/checkout@v4
300+
301+
- name: Cache npm install
302+
id: cache-npm
303+
uses: actions/cache@v4
304+
with:
305+
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
306+
path: |
307+
node_modules
239308
- name: Install NPM packages
240309
run: npm install
310+
241311
- name: Test Workspaces
242312
run: npm run test --workspace packages/preview2-shim
243313

@@ -246,8 +316,17 @@ jobs:
246316
runs-on: ubuntu-latest
247317
steps:
248318
- uses: actions/checkout@v4
319+
320+
- name: Cache npm install
321+
id: cache-npm
322+
uses: actions/cache@v4
323+
with:
324+
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
325+
path: |
326+
node_modules
249327
- name: Install NPM packages
250328
run: npm install
329+
251330
- name: Lint
252331
run: npm run lint
253332

@@ -265,7 +344,8 @@ jobs:
265344

266345
examples:
267346
name: Example ${{ matrix.project.name }}
268-
needs: [build]
347+
needs:
348+
- build
269349
runs-on: ubuntu-latest
270350
strategy:
271351
matrix:
@@ -320,6 +400,13 @@ jobs:
320400
rename-to: wac
321401
chmod: 0755
322402

403+
- name: Cache npm install
404+
id: cache-npm
405+
uses: actions/cache@v4
406+
with:
407+
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }}
408+
path: |
409+
node_modules
323410
- run: npm install
324411

325412
- name: Run all script for (${{ matrix.project.name }})

0 commit comments

Comments
 (0)