Skip to content

fix: replace setup-node pnpm cache with explicit actions/cache#1060

Merged
dgee2 merged 2 commits into
mainfrom
dgee2/fix-pnpm-cache-ci
May 22, 2026
Merged

fix: replace setup-node pnpm cache with explicit actions/cache#1060
dgee2 merged 2 commits into
mainfrom
dgee2/fix-pnpm-cache-ci

Conversation

@dgee2

@dgee2 dgee2 commented May 22, 2026

Copy link
Copy Markdown
Owner

Problem

The \Frontend validation\ CI job was failing on the \Post Use Node.js 22.x\ step with:

\
##[error]Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.
\\

This happens because \�ctions/setup-node@v6\ with \cache: 'pnpm'\ computes the pnpm store path at setup time (before \pnpm install\ has run). When pnpm is managed by corepack and the cache misses, the store directory doesn't yet exist on disk at that point. The POST step's path-validation then fails and marks the entire job as failed — even though all tests, lint, and build steps passed.

Seen in: https://github.com/dgee2/Menu/actions/runs/26310091099/job/77456532434?pr=1058

Fix

  • Remove \cache: 'pnpm'\ from \setup-node@v6\ so it no longer manages pnpm caching
  • Add a Get pnpm store directory step that runs \pnpm store path --silent\ after corepack is enabled, capturing the real store path used by the project's pinned pnpm version
  • Add an explicit \�ctions/cache@v5\ step keyed on \pnpm-lock.yaml\ to cache that path

The explicit cache step avoids the path-detection race condition and is the approach recommended by the pnpm docs for corepack-managed pnpm.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

setup-node@v6 with cache: 'pnpm' fails on cache misses when pnpm is
managed by corepack: it computes the store path at setup time (before
pnpm install), but the path doesn't yet exist on disk, so the POST
step's path-validation check fails and marks the job as failed.

Replace with explicit caching:
- Remove cache: 'pnpm' from setup-node so it no longer manages pnpm
  caching itself
- Add a 'Get pnpm store directory' step that runs pnpm store path
  --silent (after corepack has been enabled) to capture the real store
  path used by the project's pinned pnpm version
- Add an explicit actions/cache@v5 step that caches that path, keyed
  on pnpm-lock.yaml so cache keys stay correct

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 22, 2026 20:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a GitHub Actions CI failure in the “Frontend validation” job by replacing actions/setup-node’s built-in pnpm caching with an explicit actions/cache step that keys off pnpm-lock.yaml, avoiding cache path validation issues when pnpm is Corepack-managed.

Changes:

  • Removed cache: 'pnpm' / cache-dependency-path from actions/setup-node@v6.
  • Added a step to compute the pnpm store path via pnpm store path --silent.
  • Added an explicit actions/cache@v5 step to cache the computed pnpm store path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/main.yml Outdated
Per Copilot review: running corepack enable pnpm before actions/setup-node
is non-deterministic because setup-node prepends its own Node installation
to PATH, which can shadow the corepack shims registered by the earlier
step. Running setup-node first ensures corepack enable registers pnpm
shims against the Node installation that is actually active for the rest
of the job.

Also extend the pnpm store cache key to include package.json alongside
pnpm-lock.yaml, so a packageManager version bump (which only changes
package.json, not the lockfile) correctly invalidates the cache.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dgee2 dgee2 enabled auto-merge (squash) May 22, 2026 20:53
@sonarqubecloud

Copy link
Copy Markdown

@dgee2 dgee2 merged commit fad0040 into main May 22, 2026
13 checks passed
@dgee2 dgee2 deleted the dgee2/fix-pnpm-cache-ci branch May 22, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants