Skip to content

CI: Add the setup-npm action to wp/7.1 - #84169

Draft
manzoorwanijk wants to merge 1 commit into
wp/7.1from
build/wp-7.1-setup-npm
Draft

manzoorwanijk wants to merge 1 commit into
wp/7.1from
build/wp-7.1-setup-npm

Conversation

@manzoorwanijk

Copy link
Copy Markdown
Member

What?

See #82328, #72973

Adds trunk's .github/setup-npm action to wp/7.1, unchanged. Nothing uses it yet.

Why?

#84161 moves wp/7.1 to Node 24 and npm 11.18 and installs npm through this action. Its Compressed Size check builds the base branch with preactjs/compressed-size-action, and the action's post step then fails while wp/7.1 lacks .github/setup-npm. Landing the action first keeps that check green; #84161 is stacked on this PR.

How?

Copies .github/setup-npm/action.yml from trunk byte for byte.

Testing Instructions

CI passes. The file matches trunk's copy.

Use of AI Tools

Claude Code (Opus) prepared this PR; I reviewed it.

Ports trunk's `.github/setup-npm` action unchanged, ahead of the change
that moves `wp/7.1` to Node 24 and npm 11.18 and uses it in its workflows.

Landing it first keeps the Compressed Size check working on that change:
`preactjs/compressed-size-action` checks out the base branch to build it,
and the action's post step then needs `.github/setup-npm` to exist there.
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: def11503-775d-4a73-ba2a-084e06ef0338

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

should paste block styles using keyboard in /test/e2e/specs/editor/various/list-view.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 6
+ Received  + 0

@@ -1,15 +1,9 @@
  Array [
    Object {
      "attributes": Object {
        "content": "First Block",
-       "style": Object {
-         "color": Object {
-           "background": "#00ff00",
-           "text": "#ff0000",
-         },
-       },
      },
      "name": "core/paragraph",
    },
    Object {
      "attributes": Object {

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/list-view.spec.js:653:41

02d5923 Run

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@tyxla tyxla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, but once we merge, let's consider updating #84161 as needed

Also I've left a few ideas that should be possible to be iterated on separately, as follow-ups, that don't necessarily come from this PR.


- name: Cache npm downloads
if: ${{ inputs.cache == 'true' }}
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This works, but it feels fragile. The post step reads action.yml from the base branch, so any future change to this file on wp/7.1 (step id, outputs, cache key) could break Compressed Size again.

One way around it is to pass cache: 'false' in bundle-size.yml. Or alternatively we can check out to a separate path like build-plugin-zip.yml does?

Not a blocker FWIW

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed. #84322 passes cache: 'false' in trunk's bundle-size.yml. This PR stays a copy of trunk's action.

env:
WORKING_DIRECTORY: ${{ inputs.working-directory }}
run: |
NPM_VERSION="$(jq -r '.devEngines.packageManager.version // empty' package.json)"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Keep in mind wp/7.1 doesn't have devEngines yet, only engines.npm. So until #84161 lands, this action will keep the bundled npm and do nothing else.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, intended. This PR only makes the action exist on the base branch; #84161 adds devEngines.


- name: Cache npm downloads
if: ${{ inputs.cache == 'true' }}
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On wp/7.1, .github/setup-node/action.yml still uses cache: npm. When #84161 uses this action, we should also port the package-manager-cache: false change from trunk. Otherwise we cache the same folder twice, and setup-node may fail the devEngines check

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

#84161 already ports that: trunk's setup-node action with package-manager-cache: false, and the same flag in the workflows.

# actions/setup-node cannot restore the npm cache: it locates the
# directory with `npm config get cache`, which runs before this step
# and fails the devEngines check under the bundled npm.
echo "cache-dir=$(npm config get cache | tr -d '\r')" >> "$GITHUB_OUTPUT"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If npm config get cache fails, the step still passes and writes an empty cache-dir.

The error then shows up later in the cache step, which may be harder to debug.

Should we save to a variable first, so the step fails early?

That's the same on trunk btw, so a follow-up is fine.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch, fixed on trunk in #84322. The release branches will pick it up when they next sync with trunk's action.

NPM_VERSION="$(jq -r '.devEngines.packageManager.version // empty' package.json)"
if [ -n "$NPM_VERSION" ]; then
# Contributors need the floor; CI stays on that major's newest release.
npm install --global "npm@${NPM_VERSION/>=/^}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changing >= to ^ means each run installs the latest npm in that major. Two jobs could end up on different npm versions. Should we pin the exact version instead? Also, >= 11.18 (with a space) would not match.

That's the same on trunk btw, so could be a follow-up

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Floating within the major is deliberate on trunk, so CI gets npm patch releases without a bump. The space is fine: semver reads ^ 11.18 as >=11.18.0 <12.0.0-0.

uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.npm.outputs.cache-dir }}
key: npm-cache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles(format('{0}package-lock.json', steps.npm.outputs.path-prefix)) }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If hashFiles finds no lockfile, the key ends with - and never changes. The cache is saved once and then never updated. Not a problem today, but maybe worth a guard. Another thing that's in trunk and we could follow up with.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Every caller has a lockfile, so I'd leave it.

uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.npm.outputs.cache-dir }}
key: npm-cache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles(format('{0}package-lock.json', steps.npm.outputs.path-prefix)) }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The cache key does not include the npm version. After an npm upgrade we could restore a cache made by the old version. Adding npm --version to the key would avoid this. Already the case in trunk, so this is yet another follow-up

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

npm's download cache uses the same format across versions. And since npm floats, adding the version would throw the cache away on every npm release.

@desrosj

desrosj commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Could we please hold off on merging this, unless it's urgent.

I'm wrapping up work I've been doing across all the old WP branches to restore/harden the GitHub Actions workflows, and this will likely cause conflicts with the PR stack that I have prepared for 7.1. Rebasing the entire 10+ PR stack will be much more of a pain than rebasing this PR, and I'm fairly certain there will be some overlap.

I am preparing a briefing document today so that we can begin to divide and conquer reviewing these stacks, so I don't think that will take much longer.

@manzoorwanijk

Copy link
Copy Markdown
Member Author

Could we please hold off on merging this, unless it's urgent.

Sure.

I'm wrapping up work I've been doing across all the old WP branches to restore/harden the GitHub Actions workflows, and this will likely cause conflicts with the PR stack that I have prepared for 7.1. Rebasing the entire 10+ PR stack will be much more of a pain than rebasing this PR, and I'm fairly certain there will be some overlap.

I am preparing a briefing document today so that we can begin to divide and conquer reviewing these stacks, so I don't think that will take much longer.

Thanks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Build Tooling Issues or PRs related to build tooling

Projects

Status: In review
Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants