Skip to content

Commit 59c16b9

Browse files
authored
Improve build pipeline performance (#6082)
* Temporarily also save caches on my branch * Extract composite action to always save missing caches * Only save caches on master again
1 parent 8b6b06b commit 59c16b9

File tree

4 files changed

+43
-102
lines changed

4 files changed

+43
-102
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Install and Cache Node Dependencies
2+
description: Installs Node dependencies and saves cache if not already cached.
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Restore Node dependencies cache
7+
id: cache-node-modules
8+
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
9+
with:
10+
path: |
11+
node_modules
12+
~/.npm
13+
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
14+
restore-keys: node-modules-${{ runner.os }}-${{ runner.arch }}
15+
- name: Install Node dependencies
16+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
17+
run: npm ${{ github.ref == 'refs/heads/master' && 'ci' || 'install' }} --ignore-scripts
18+
shell: bash
19+
- name: Save Node dependencies cache
20+
if: steps.cache-node-modules.outputs.cache-hit != 'true' && github.ref == 'refs/heads/master'
21+
uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
22+
with:
23+
path: |
24+
node_modules
25+
~/.npm
26+
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
27+

.github/workflows/build-and-tests.yml

Lines changed: 10 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,8 @@ jobs:
3636
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
3737
with:
3838
node-version: 24.6.0
39-
- name: Restore Node dependencies cache
40-
id: cache-node-modules
41-
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
42-
with:
43-
path: |
44-
node_modules
45-
~/.npm
46-
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
47-
restore-keys: node-modules-${{ runner.os }}-${{ runner.arch }}
48-
- name: Install Node dependencies
49-
if: steps.cache-node-modules.outputs.cache-hit != 'true'
50-
run: npm ci --ignore-scripts
39+
- name: Install and Cache Node Dependencies
40+
uses: ./.github/actions/install-and-cache-node-deps
5141
- name: Lint
5242
run: npm run ci:lint
5343
- name: Vulnerabilities
@@ -245,26 +235,8 @@ jobs:
245235
run: ${{ matrix.settings.setup }}
246236
if: ${{ matrix.settings.setup }}
247237
shell: bash
248-
- name: Restore Node dependencies cache
249-
id: cache-node-modules
250-
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
251-
with:
252-
path: |
253-
node_modules
254-
~/.npm
255-
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
256-
restore-keys: node-modules-${{ runner.os }}-${{ runner.arch }}
257-
- name: Install Node dependencies
258-
if: steps.cache-node-modules.outputs.cache-hit != 'true'
259-
run: npm ${{ github.ref == 'refs/heads/master' && 'ci' || 'install' }} --ignore-scripts
260-
- name: Save Node dependencies cache
261-
if: steps.cache-node-modules.outputs.cache-hit != 'true' && github.ref == 'refs/heads/master'
262-
uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
263-
with:
264-
path: |
265-
node_modules
266-
~/.npm
267-
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
238+
- name: Install and Cache Node Dependencies
239+
uses: ./.github/actions/install-and-cache-node-deps
268240
- name: Build in docker
269241
uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 # v3
270242
if: ${{ matrix.settings.docker }}
@@ -346,18 +318,8 @@ jobs:
346318
steps:
347319
- name: Checkout Commit
348320
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
349-
- name: Restore Node dependencies cache
350-
id: cache-node-modules
351-
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
352-
with:
353-
path: |
354-
node_modules
355-
~/.npm
356-
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
357-
restore-keys: node-modules-${{ runner.os }}-${{ runner.arch }}
358-
- name: Install Node dependencies
359-
if: steps.cache-node-modules.outputs.cache-hit != 'true'
360-
run: npm install --ignore-scripts
321+
- name: Install and Cache Node Dependencies
322+
uses: ./.github/actions/install-and-cache-node-deps
361323
- name: Build JS
362324
run: npm run build:cjs
363325
- name: Download napi artifacts
@@ -452,18 +414,8 @@ jobs:
452414
with:
453415
node-version: ${{ matrix.node }}
454416
check-latest: true
455-
- name: Restore Node dependencies cache
456-
id: cache-node-modules
457-
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
458-
with:
459-
path: |
460-
node_modules
461-
~/.npm
462-
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
463-
restore-keys: node-modules-${{ runner.os }}-${{ runner.arch }}
464-
- name: Install Node dependencies
465-
if: steps.cache-node-modules.outputs.cache-hit != 'true'
466-
run: npm install --ignore-scripts
417+
- name: Install and Cache Node Dependencies
418+
uses: ./.github/actions/install-and-cache-node-deps
467419
- name: Download napi artifacts
468420
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
469421
with:
@@ -510,18 +462,8 @@ jobs:
510462
with:
511463
node-version: ${{ matrix.node }}
512464
check-latest: true
513-
- name: Restore Node dependencies cache
514-
id: cache-node-modules
515-
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
516-
with:
517-
path: |
518-
node_modules
519-
~/.npm
520-
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
521-
restore-keys: node-modules-${{ runner.os }}-${{ runner.arch }}
522-
- name: Install Node dependencies
523-
if: steps.cache-node-modules.outputs.cache-hit != 'true'
524-
run: npm install --ignore-scripts
465+
- name: Install and Cache Node Dependencies
466+
uses: ./.github/actions/install-and-cache-node-deps
525467
- name: Download all artifacts
526468
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
527469
with:

.github/workflows/performance-report.yml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,8 @@ jobs:
5252
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
5353
with:
5454
node-version: 24.6.0
55-
- name: Restore Node dependencies cache
56-
id: cache-node-modules
57-
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
58-
with:
59-
path: |
60-
node_modules
61-
~/.npm
62-
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
63-
- name: Install Node dependencies
64-
if: steps.cache-node-modules.outputs.cache-hit != 'true'
65-
run: npm install --ignore-scripts
55+
- name: Install and Cache Node Dependencies
56+
uses: ./.github/actions/install-and-cache-node-deps
6657
- name: Build artefacts 123
6758
run: npm exec -- concurrently -c green,blue 'npm:build:napi -- --release' 'npm:build:cjs' && npm run build:copy-native && npm run build:bootstrap:cjs && npm run build:copy-native
6859
- name: Upload artifact
@@ -103,17 +94,8 @@ jobs:
10394
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
10495
with:
10596
node-version: 24.6.0
106-
- name: Restore Node dependencies cache
107-
id: cache-node-modules
108-
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
109-
with:
110-
path: |
111-
node_modules
112-
~/.npm
113-
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
114-
- name: Install dependencies
115-
if: steps.cache-node-modules.outputs.cache-hit != 'true'
116-
run: npm ci --ignore-scripts
97+
- name: Install and Cache Node Dependencies
98+
uses: ./.github/actions/install-and-cache-node-deps
11799
- name: Download all artifacts
118100
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
119101
with:

.github/workflows/repl-artefacts.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,8 @@ jobs:
4747
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
4848
with:
4949
node-version: 24.6.0
50-
- name: Restore Node dependencies cache
51-
id: cache-node-modules
52-
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
53-
with:
54-
path: |
55-
node_modules
56-
~/.npm
57-
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }}
58-
restore-keys: node-modules-${{ runner.os }}-${{ runner.arch }}
59-
- name: Install Node dependencies
60-
if: steps.cache-node-modules.outputs.cache-hit != 'true'
61-
run: npm install --ignore-scripts
50+
- name: Install and Cache Node Dependencies
51+
uses: ./.github/actions/install-and-cache-node-deps
6252
- name: Build artefacts
6353
run: >-
6454
npm exec -- concurrently -c green,blue,yellow 'npm:build:napi -- --release' 'npm run build:wasm' 'npm:build:cjs' &&

0 commit comments

Comments
 (0)