Skip to content

Commit

Permalink
Improve CI caching for node_modules (#5783)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert authored Jan 6, 2025
1 parent f5c349e commit 27216d8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 18 deletions.
50 changes: 38 additions & 12 deletions .github/workflows/build-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ jobs:
id: cache-node-modules
uses: actions/cache/restore@v4
with:
path: node_modules
path: |
node_modules
~/.npm
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: node-modules-${{ runner.os }}
- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
run: npm install --ignore-scripts
- name: Lint
run: npm run ci:lint
- name: Vulnerabilities
Expand Down Expand Up @@ -245,16 +248,21 @@ jobs:
id: cache-node-modules
uses: actions/cache/restore@v4
with:
path: node_modules
path: |
node_modules
~/.npm
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: node-modules-${{ runner.os }}
- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
run: npm ${{ github.ref == 'refs/heads/master' && 'ci' || 'install' }} --ignore-scripts
- name: Save Node dependencies cache
if: steps.cache-node-modules.outputs.cache-hit != 'true' && github.ref == 'refs/heads/master'
uses: actions/cache/save@v4
with:
path: node_modules
path: |
node_modules
~/.npm
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Build in docker
uses: addnab/docker-run-action@v3
Expand Down Expand Up @@ -323,6 +331,15 @@ jobs:
rust/target/
key: ${{ matrix.settings.target }}-cargo-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: ${{ matrix.settings.target }}-cargo
- name: Restore Node dependencies cache
id: cache-node-modules
uses: actions/cache/restore@v4
with:
path: |
node_modules
~/.npm
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: node-modules-${{ runner.os }}
- name: Build
uses: cross-platform-actions/action@v0.26.0
with:
Expand All @@ -332,7 +349,7 @@ jobs:
memory: 8G
run: |
sudo pkg install -y node npm rust
npm ci --ignore-scripts
${{ steps.cache-node-modules.outputs.cache-hit != 'true' && 'npm install --ignore-scripts' || 'echo Cache hit' }}
npm run build:napi -- --release --target ${{ matrix.settings.target }}
- name: Save Cargo cache
if: github.ref == 'refs/heads/master'
Expand Down Expand Up @@ -397,11 +414,14 @@ jobs:
id: cache-node-modules
uses: actions/cache/restore@v4
with:
path: node_modules
path: |
node_modules
~/.npm
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: node-modules-${{ runner.os }}
- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
run: npm install --ignore-scripts
- name: Build JS
run: npm run build:cjs
- name: Download napi artifacts
Expand Down Expand Up @@ -492,11 +512,14 @@ jobs:
id: cache-node-modules
uses: actions/cache/restore@v4
with:
path: node_modules
path: |
node_modules
~/.npm
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: node-modules-${{ runner.os }}
- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
run: npm install --ignore-scripts
- name: Download napi artifacts
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -547,11 +570,14 @@ jobs:
id: cache-node-modules
uses: actions/cache/restore@v4
with:
path: node_modules
path: |
node_modules
~/.npm
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: node-modules-${{ runner.os }}
- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
run: npm install --ignore-scripts
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/performance-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ jobs:
id: cache-node-modules
uses: actions/cache/restore@v4
with:
path: node_modules
path: |
node_modules
~/.npm
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
run: npm install --ignore-scripts
- name: Build artefacts 123
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
- name: Upload artifact
Expand Down Expand Up @@ -105,7 +107,9 @@ jobs:
id: cache-node-modules
uses: actions/cache/restore@v4
with:
path: node_modules
path: |
node_modules
~/.npm
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/repl-artefacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ jobs:
id: cache-node-modules
uses: actions/cache/restore@v4
with:
path: node_modules
path: |
node_modules
~/.npm
key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
restore-keys: node-modules-${{ runner.os }}
- name: Install Node dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci --ignore-scripts
run: npm install --ignore-scripts
- name: Build artefacts
run: npm exec -- concurrently -c green,blue,yellow 'npm:build:napi -- --release' 'npm run build:wasm' 'npm:build:cjs' && npm run build:copy-native && npm run build:bootstrap
- name: Upload "${{ github.event.number }}/rollup.browser.js" to bucket
Expand Down

0 comments on commit 27216d8

Please sign in to comment.