fix(ci): scope node_modules cache key per job to stop save races

The Windows desktop build now succeeds (artifact builds + uploads), but the
job was marked failed on the post-job cache *save*: build-binaries
(windows-x64) and build-desktop-windows share runner.os/arch and thus the
same cache key, so concurrent saves hit "unable to reserve cache ... another
job may be creating this cache." Adding github.job to the key gives each job
its own cache and eliminates the race.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-05-30 09:09:25 -07:00
parent 4153ad7323
commit 805eae4237
2 changed files with 6 additions and 2 deletions

View File

@@ -34,6 +34,10 @@ runs:
# runner.arch is essential: pnpm only installs the current platform's optional
# native deps (e.g. @rollup/rollup-linux-arm64-gnu), so an x64 cache restored on
# an arm64 runner (same runner.os) would be missing native binaries and break builds.
# github.job scopes the key per job: jobs sharing an OS/arch (e.g. the windows-x64
# CLI build and the Windows desktop build) would otherwise race on the same key and
# one would fail the post-job cache save ("unable to reserve cache ... another job
# may be creating this cache"). Per-job keys trade a little reuse for reliability.
# Intentionally no restore-keys fallback: partial restores can create inconsistent trees.
- name: Cache node_modules
id: node-modules-cache
@@ -44,7 +48,7 @@ runs:
node_modules
**/node_modules
!**/.cache
key: node-modules-${{ runner.os }}-${{ runner.arch }}-node${{ inputs.node-version }}-${{ hashFiles('pnpm-lock.yaml') }}
key: node-modules-${{ github.job }}-${{ runner.os }}-${{ runner.arch }}-node${{ inputs.node-version }}-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install dependencies
if: ${{ inputs.skip-install != 'true' && steps.node-modules-cache.outputs.cache-hit != 'true' }}