Skip to content

Document why NodeJS is needed to run the tests - #347

Merged
mindctrl merged 10 commits into
WordPress:masterfrom
iarif4u:docs/why-nodejs
Oct 23, 2026
Merged

mindctrl merged 10 commits into
WordPress:masterfrom
iarif4u:docs/why-nodejs

Conversation

@iarif4u

@iarif4u iarif4u commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #243.

Purpose

Hosts ask why a PHP test suite needs NodeJS. This adds a short "Why NodeJS is needed" section under the NodeJS installation steps in the README.

What it explains

  • prepare.php runs npm install && npm run build. The step the tests need is build:gutenberg. It downloads the pinned Gutenberg artifact from ghcr.io and copies the block editor PHP files, routes, blocks, scripts, styles and theme.json into src/.
  • The tests load WordPress from src/. Those files left version control in changeset 61438, so without the build, WordPress fails to load (example: PHPUnit tests fail: routes.php generated under build/ but tests bootstrap from src/ #292).
  • Hosts must allow outbound connections to ghcr.io. This is new information for firewalled hosts.
  • engine-strict = true in wordpress-develop/.npmrc means that npm install stops on an older Node.js version.
  • The production part of npm run build (copy to build/, minify) is not used by PHPUnit. Core's own PHPUnit workflow uses npm ci and npm run build:dev. Links to Find ways to reduce the need for NodeJS #244 for the follow-up.

Sources (wordpress-develop trunk)

  • Gruntfile.js: the build, build:gutenberg and gutenberg:download tasks, and the comment that references changeset 61438 and ticket 64393
  • tools/gutenberg/utils.js and download.js: version check, auto-download, ghcr.io URLs
  • package.json (gutenberg.sha, engines) and .npmrc (engine-strict)
  • .github/workflows/reusable-phpunit-tests-v3.yml: npm ci and npm run build:dev before PHPUnit
  • wp-tests-config-sample.php: ABSPATH is src/

Contributed at WordCamp Contributor Day.

Explains that the build step downloads the pinned Gutenberg artifact from
ghcr.io and copies the block editor files into src/, which the tests load.
Also notes engine-strict and that the production build is not needed for
PHPUnit.

Fixes WordPress#243.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 2, 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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @iarif4u, @mindctrl.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: iarif4u, mindctrl.

Co-authored-by: kittenkamala <amykamala@git.wordpress.org>
Co-authored-by: dhruvang21 <dhruvang21@git.wordpress.org>
Co-authored-by: ekamran <ekamran@git.wordpress.org>
Co-authored-by: Crixu <crixu@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Comment thread README.md Outdated
Make it a standalone ### section, open with why a PHP suite needs Node.js,
list the Gutenberg steps in order, and add a summary sentence (from the
review). Keep the ghcr.io network requirement, the changeset and issue
references, and the build:dev note. Mention that devEngines also enforces
the npm version.
@iarif4u

iarif4u commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @dhruvang21, your version reads better. I reworked the section in 3632464 and used your structure:

  • A standalone ### Why Node.js is needed section, with "Node.js" spelled correctly.
  • It opens with why a PHP suite needs Node.js.
  • The Gutenberg steps are numbered in order, starting with the pinned version.
  • It ends with your summary sentence.

I kept a few things that your text left out, because hosts need them:

I also added that devEngines enforces the npm version, in addition to engine-strict. Could you take another look?

@dhruvang21

Copy link
Copy Markdown
Contributor

@iarif4u The technical details here are useful, but I think the section could be improved for clarity, flow, and grammatical accuracy. Rather than making several small edits, could we replace the current section with the version suggested in the change? It keeps the technical details while making the explanation easier to follow.

Comment thread README.md Outdated
Comment thread README.md Outdated
Base the section on the wording suggested in review, and use real
headings for Versions and Extra work (review suggestions). Keep the
facts hosts need: the build commands, changeset 61438, gutenberg.sha,
the ghcr.io connection, the routes.php example, devEngines with the
EBADDEVENGINES error, and Core's build:dev workflow.
@iarif4u

iarif4u commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

@dhruvang21 Done in 148566c. The section now uses your version, with your sentences. I only added back the facts that your version left out, each as a short clause in your text:

I also applied @mindctrl's two heading suggestions. Could you take another look?

Comment thread README.md Outdated
GHCR answers the blob request with a 307 to pkg-containers.githubusercontent.com,
so a host with an outbound allowlist needs both domains.
4814a42 recorded the deletion of 22 files that were missing from my local
working copy. Restore them unchanged. The only change left from that
commit is the ghcr.io redirect sentence in README.md.
Comment thread README.md Outdated
routes.php is in version control again since r62118, so cite WordPress#292 as
something that happened instead of a current example.

@ekamran ekamran 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.

Thanks, looks good.

Since WordPress#351, prepare.php runs npm run build:dev, so name that command and
replace the note that compared it with the full build.
@iarif4u

iarif4u commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

#351 is merged, so as agreed I updated the wording in 47af3de. The section now says that prepare.php runs npm install && npm run build:dev, and the "Extra work" note is replaced by a short "Development build" note. It says the development build is the same as in Core's PHPUnit workflow, writes into src/, and skips build/ and minification. No other changes. @mindctrl @ekamran @dhruvang21, since this came after your approvals.

@ekamran ekamran 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.

Thanks @iarif4u. I re-checked the whole section against wordpress-develop trunk and the runner's own CI logs. One line needs a fix, inline.

Comment thread README.md Outdated
kittenkamala and others added 2 commits October 14, 2026 11:32
`grunt build --dev` runs build:js and build:css, which minify into src/.
It only skips build:files (the build/ directory), replace:source-maps
and verify:build.

@ekamran ekamran 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.

Re-checked at 3455650: the Development build paragraph now matches the Gruntfile, and the npm commands match prepare.php. Thanks @iarif4u.

@mindctrl
mindctrl merged commit 1f276b2 into WordPress:master Oct 23, 2026
1 check passed
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.

Document why NodeJS is needed.

5 participants