Skip to content

Commit 419719e

Browse files
committed
fix(ci): cache vendor build artefacts alongside node_modules
The Windows install action enables the bun-output cache via the `cache: "true"` input added in `46d98c9756`. On a cache hit it `tar -xf`s the saved archive and skips `bun install`, but the original archive only contained `node_modules`. `bun install`'s `prepare` step runs `cd vendor && npm ci --include=dev`, whose `node rspack` postinstall lands `vendor/dist/{limiter, ...}` outside that path, so every cache-hit Windows job now fails at first require with `Cannot find module '../../../vendor/dist/limiter'`. Capture `vendor/node_modules` and `vendor/dist` in the archive, fold `vendor/package-lock.json` into the cache key so a transitive bump invalidates the entry, and rename the archive plus bump the key suffix to `-v3` so already-poisoned entries miss.
1 parent 19b6f68 commit 419719e

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

.github/actions/install/action.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Install dependencies
22
description: Install dependencies
33
inputs:
44
cache:
5-
description: Restore and save node_modules.tar between runs of this workflow/job.
5+
description: Restore and save the bun-install output tar between runs of this workflow/job.
66
required: false
77
default: 'false'
88
runs:
@@ -12,11 +12,15 @@ runs:
1212
if: inputs.cache == 'true'
1313
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
1414
with:
15-
key: install-cache-${{ github.workflow }}-${{ github.job }}-${{ hashFiles('bun.lock') }}-v2
16-
path: node_modules.tar
15+
# `bun install` runs `prepare`, which `cd vendor && npm ci --include=dev` runs
16+
# `node rspack` and lands the bundled artefacts under `vendor/dist`. Both
17+
# `vendor/package-lock.json` and `bun.lock` feed the install graph, so the cache
18+
# key has to invalidate when either moves.
19+
key: install-cache-${{ github.workflow }}-${{ github.job }}-${{ hashFiles('bun.lock', 'vendor/package-lock.json') }}-v3
20+
path: install-cache.tar
1721
- if: inputs.cache == 'true' && steps.install-cache.outputs.cache-hit == 'true'
1822
shell: bash
19-
run: tar -xf node_modules.tar
23+
run: tar -xf install-cache.tar
2024
- if: inputs.cache != 'true' || steps.install-cache.outputs.cache-hit != 'true'
2125
uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4.0.0
2226
env:
@@ -28,4 +32,7 @@ runs:
2832
command: bun install --linker=hoisted --trust --network-concurrency 8
2933
- if: inputs.cache == 'true' && steps.install-cache.outputs.cache-hit != 'true'
3034
shell: bash
31-
run: tar -cf node_modules.tar node_modules
35+
# `node_modules` alone misses `vendor/dist/*` (produced by the rspack postinstall)
36+
# and `vendor/node_modules` (needed for it to re-run on the next miss); without
37+
# them, every cache-hit job fails to require `vendor/dist/limiter` and friends.
38+
run: tar -cf install-cache.tar node_modules vendor/node_modules vendor/dist

0 commit comments

Comments
 (0)