Skip to content

Commit 4e9bd47

Browse files
aarsilvclaude
andauthored
Include Node version in CI setup cache key [FFESUPPORT-731] (#120)
The composite setup action caches `**/node_modules` keyed on OS + `yarn.lock` hash only. If a `node_modules` cache built under a different Node version were restored, packages with native bindings could load mismatched ABI binaries — and because the cache-hit path skips the install step, deps wouldn't get rebuilt. Capture the resolved Node version (`node -v`) into a step output, then include it in both the primary cache key and the `restore-keys` prefix. That way, bumping Node automatically busts the cache instead of relying on lockfile churn to do it incidentally. Stays with `actions/setup-node@v3` and `actions/cache@v3` — this is the minimal-change variant. Caching Yarn's download cache instead of `node_modules` would be the more robust pattern, but that's a bigger restructure for a separate ticket if we want it. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 38b917b commit 4e9bd47

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎.github/actions/setup/action.yml‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ runs:
99
with:
1010
node-version: '20.x' # Specify the Node.js version directly here
1111

12+
- name: Resolve installed Node version
13+
id: node-info
14+
run: echo "version=$(node -v)" >> "$GITHUB_OUTPUT"
15+
shell: bash
16+
1217
- name: Cache dependencies
1318
id: yarn-cache
1419
uses: actions/cache@v3
1520
with:
1621
path: |
1722
**/node_modules
18-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
23+
key: ${{ runner.os }}-node-${{ steps.node-info.outputs.version }}-yarn-${{ hashFiles('**/yarn.lock') }}
1924
restore-keys: |
20-
${{ runner.os }}-yarn-
25+
${{ runner.os }}-node-${{ steps.node-info.outputs.version }}-yarn-
2126
2227
- name: Install dependencies
2328
if: steps.yarn-cache.outputs.cache-hit != 'true'

0 commit comments

Comments
 (0)