Repository navigation
CI: Harden setup-npm cache handling - #84322
Open
manzoorwanijk wants to merge 5 commits into
Open
manzoorwanijk wants to merge 5 commits into
manzoorwanijk wants to merge 5 commits into
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: -48 B (0%) Total Size: 8.65 MB 📦 View Changed
|
tyxla
reviewed
Oct 8, 2026
Member
Author
Yes, let us wait for his review. |
The cache directory was written straight from a command substitution inside echo, whose exit status ignores the substitution. A failing `npm config get cache` left the step green with an empty cache-dir output, and the error only surfaced later in the cache step. Assigning it to a variable first lets the shell's pipefail stop the step there.
compressed-size-action checks out the base branch to measure it, so the actions/cache post step registered by setup-npm runs against the base branch's copy of the action. Any change to that action on one side, or its absence on an old release branch, breaks the job. The cache only saves download time here, so turn it off.
Jobs that pass `cache: 'false'` never read the cache-dir output, so a failing lookup should not fail them now that the step stops on it. An npm that exits 0 but prints nothing would still leave the output empty, so fail on that too.
With setup-npm's cache off, the job ran `npm ci` for both the head and the base branch without any cache, which is slower and more exposed to registry hiccups. A workflow level actions/cache step restores the same cache, and its post step comes from the downloaded action rather than this repository, so checking out the base branch cannot break it.
manzoorwanijk
force-pushed
the
fix/setup-npm-cache-hardening
branch
from
November 13, 2026 10:30
0e2c2a6 to
c024519
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Follow up to #84169. See #82328, #72973
Part of the release-process work for moving the
wp/*branches to Node 24 and npm 11/12. Makessetup-npmfail early when it cannot read the npm cache directory, and moves the bundle size workflow's cache out ofsetup-npm.Why?
Both came up in @tyxla's review of the
wp/7.1port of this action. An emptycache-diroutput passed silently and failed later in the cache step.compressed-size-actionchecks out the base branch, so the cache post step runs the base branch's copy ofsetup-npmand breaks whenever the two copies differ.How?
bundle-size.ymlpassescache: 'false'and restores the same cache with its ownactions/cachestep.Testing Instructions
bash -eo pipefail -c 'X="$(false | tr -d x)"; echo reached'exits 1 without printing, while the oldecho "a=$(false | tr -d x)"form exits 0.Use of AI Tools
Claude Code (Opus) wrote the change; I reviewed it.