Skip to content

Commit fe44ddb

Browse files
authored
ci: refresh Node patch versions on cross-window cache restores (#8179)
This fixes a stale-patch loop where the Node setup action's 20-minute key rotation was a no-op. 24.15.0 and 22.22.1 took ~2 weeks to land in CI after release. Two bugs interact. The cache step's restore-keys omits the time block, so every cross-window run partial-matches the previous cache and restores the prior resolved patch. The setup-node step then keys check-latest off file existence rather than cache-hit, so it passes the cached patch with check-latest=true. Because semver matches an exact spec only against itself, check-latest never upgrades 24.14.0 to 24.15.0; the save step re-pins the stale value under the new key. New patches only land when the cache is fully evicted. Pass the major (not the cached patch) whenever the cache misses exactly, and gate that on cache-hit. Exact hits within a 20-minute window still install the cached patch and skip the manifest lookup; cross-window runs go through the manifest, and the save step captures the upgraded patch under the new key.
1 parent 5f58236 commit fe44ddb

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

.github/actions/node/action.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ runs:
2424

2525
# Cache a tiny file containing the exact Node.js version resolved by a previous run.
2626
# Key rotates every 20 minutes (epoch / 1200) so patches are picked up regularly.
27-
# On cache hit, we pass the exact version to setup-node and skip the HTTP manifest lookup.
27+
# On cache hit, install the cached patch and skip the manifest lookup.
2828
- name: Compute cache key
2929
id: cache-key
3030
shell: bash
@@ -34,7 +34,6 @@ runs:
3434
with:
3535
path: /tmp/.node-resolved-version-${{ steps.node-version.outputs.version }}
3636
key: node-resolved-${{ runner.os }}-${{ runner.arch }}-v${{ steps.node-version.outputs.version }}-${{ steps.cache-key.outputs.block }}
37-
restore-keys: node-resolved-${{ runner.os }}-${{ runner.arch }}-v${{ steps.node-version.outputs.version }}-
3837
- name: Read cached version
3938
id: cached
4039
shell: bash
@@ -45,9 +44,9 @@ runs:
4544
4645
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
4746
with:
48-
# Use the exact cached version when available, otherwise fall back to the requested version.
47+
# Cache hit installs the cached patch directly. Otherwise pass the major; the cached
48+
# patch is a semver-exact spec, so check-latest would not upgrade it.
4949
node-version: ${{ steps.cached.outputs.version || steps.node-version.outputs.version }}
50-
# Resolve the latest patch on master when no cached version exists.
5150
check-latest: ${{ steps.cached.outputs.version == '' }}
5251
registry-url: ${{ inputs.registry-url || 'https://registry.npmjs.org' }}
5352

0 commit comments

Comments
 (0)