Skip to content

Build/Test Tools: Avoid npx when running build and test tooling. - #13021

Open
adimoldovan wants to merge 2 commits into
WordPress:trunkfrom
adimoldovan:minimise-use-of-npx-with-non-dependency
Open

Build/Test Tools: Avoid npx when running build and test tooling.#13021
adimoldovan wants to merge 2 commits into
WordPress:trunkfrom
adimoldovan:minimise-use-of-npx-with-non-dependency

Conversation

@adimoldovan

@adimoldovan adimoldovan commented Aug 12, 2026

Copy link
Copy Markdown

Trac ticket: 65864

npx downloads a package and its dependencies from the registry when it cannot find that package locally, then runs the install scripts of everything it downloaded. Each call is a point where a compromised package can run code during a build.

This patch replaces every npx call in the repository with npm exec --no, which runs an installed binary and fails when the package is missing.
update-browserslist-db is now a devDependency at 1.3.1. browserslist already required it as ^1.2.3, so the lockfile hoists a package that was present and adds none.

Testing instructions

  1. Run npm ci.
  2. Run npm exec --no -- playwright --version. It prints the installed version and downloads nothing.
  3. Delete node_modules/update-browserslist-db and run npm exec --no -- update-browserslist-db. It fails with npx canceled due to missing packages and no YES option instead of fetching the package. Restore the tree with npm ci.
  4. Run grunt qunit and confirm the QUnit tests still run.
  5. Confirm the end-to-end and performance workflows pass on this pull request.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Auditing the npx call sites. I reviewed and verified the result, including the npm exec --no behavior described above.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

`npx` downloads a package and its dependencies from the registry when it cannot find that package locally, then runs the install scripts of everything it downloaded. Each call is a point where a compromised package can run code during a build.

Replace every `npx` call in the repository with `npm exec --no`, which runs an installed binary and fails when the package is missing.

`update-browserslist-db` is now a devDependency at 1.3.1. `browserslist` already required it as `^1.2.3`, so the lockfile hoists a package that was present and adds none.

See #65864.
@adimoldovan adimoldovan self-assigned this Aug 12, 2026
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@adimoldovan
adimoldovan force-pushed the minimise-use-of-npx-with-non-dependency branch from a68383d to 73ca3ca Compare August 12, 2026 16:51
@adimoldovan
adimoldovan marked this pull request as ready for review August 12, 2026 17:13
@github-actions

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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props adrianmoldovanwp.

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

@adimoldovan adimoldovan moved this from In progress to In review in WordPress Project Build Tooling Aug 12, 2026
@adimoldovan
adimoldovan force-pushed the minimise-use-of-npx-with-non-dependency branch from 73ca3ca to 5cd9e04 Compare August 12, 2026 17:20
@lancewillett
lancewillett requested a lite review from Copilot August 13, 2026 18:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the build/test toolchain by removing npx usage (which can implicitly download and run install scripts) and switching to npm exec --no so tooling runs only when already present in the workspace.

Changes:

  • Replace npx invocations with npm exec --no in Grunt tasks and GitHub Actions workflows.
  • Add update-browserslist-db@1.3.1 as a devDependency and update the lockfile accordingly.
  • Update the QUnit Playwright config comment to reflect the CI browser strategy (system Chrome channel).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/qunit/playwright.config.js Updates CI-related comment for Playwright browser selection.
package.json Adds update-browserslist-db as a pinned devDependency.
package-lock.json Updates lock entries to reflect the added/pinned dependency version.
Gruntfile.js Switches QUnit, package update, and Browserslist update tasks from npx to npm exec --no.
.github/workflows/reusable-performance-test-v2.yml Uses npm exec --no for Playwright browser installation in performance workflow.
.github/workflows/reusable-end-to-end-tests.yml Uses npm exec --no for Playwright browser installation in E2E workflow.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants