Skip to content

Build/Test Tools: Propagate the exit status of the local environment commands - #12735

Open
adimoldovan wants to merge 3 commits into
WordPress:trunkfrom
adimoldovan:fix-local-env-discarded-exit-status
Open

Build/Test Tools: Propagate the exit status of the local environment commands#12735
adimoldovan wants to merge 3 commits into
WordPress:trunkfrom
adimoldovan:fix-local-env-discarded-exit-status

Conversation

@adimoldovan

@adimoldovan adimoldovan commented Jul 28, 2026

Copy link
Copy Markdown

tools/local-env/scripts/start.js runs docker compose up through spawnSync and never inspects the result. A failed pull therefore does not fail the script. Execution continues into composer update -W with containers that may not exist, and the error surfaces later and in the wrong step.

tools/local-env/scripts/docker.js has the same class of defect. It calls process.exit( returns.status ), and status is null when Docker cannot be spawned. process.exit( null ) exits 0, so npm run env:pull reports success when the Docker CLI is missing.

This PR checks the status in both files and propagates it, falling back to 1 when status is null.

A command killed by a signal is a failure, with one exception: docker.js exits 0 on SIGINT, because Ctrl+C is the normal way to end a long-running command such as npm run env:logs and is not worth an npm error block. Every other signal exits non-zero. start.js exempts nothing, because npm run env:start runs composer update -W next and that must not run against containers that never came up.

The change is deliberately kept to that scope so it can be backported.

Backport

start.js and docker.js on the 6.8, 6.9 and 7.0 branches carry the same defect. Branches 6.7 and earlier run these commands through execSync, which throws on a non-zero exit, so they are not affected.

Branch start.js docker.js
4.1 - 6.7 not affected (execSync) not affected (execSync)
6.8 affected affected
6.9 affected affected
7.0 affected affected

Testing instructions

Reproduce the discarded status. Before this change the pull fails and the exit code is 0. After it, the exit code is 1.

LOCAL_PHP=this-tag-does-not-exist npm run env:start; echo $?

Reproduce the docker.js defect. Before this change the exit code is 0. After it, the exit code is 1.

env PATH=/var/empty $(which node) ./tools/local-env/scripts/docker.js pull; echo $?

Confirm a normal start still works.

npm run env:stop && docker compose down -v
npm run env:start && npm run env:install

Confirm Ctrl+C during npm run env:logs still exits without an npm error block.

Trac ticket: https://core.trac.wordpress.org/ticket/65745

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Investigating the CI failures, writing the patch, and iterative code review. The behaviour described above was reproduced and verified locally before and after the change.


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.

…commands.

`start.js` runs `docker compose up` through `spawnSync` and never inspects the
result, so a failed pull does not fail the script. Execution continues into
`composer update -W` with containers that may not exist, and the error surfaces
later and in the wrong place.

`docker.js` calls `process.exit( returns.status )`, and `status` is `null` when
Docker cannot be spawned. `process.exit( null )` exits 0, so `npm run env:pull`
reports success when the Docker CLI is missing.

Reproduce with:

    LOCAL_PHP=this-tag-does-not-exist npm run env:start; echo $?

See #65745.

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 updates the local Docker environment helper scripts to correctly propagate failures from spawnSync() so npm commands fail at the correct step (instead of continuing after Docker failures and surfacing errors later).

Changes:

  • Capture and check the result of docker compose up in start.js, exiting non-zero when container startup fails.
  • Avoid exiting 0 when the Docker CLI cannot be spawned in docker.js by handling status === null and reporting a clearer error.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tools/local-env/scripts/start.js Capture spawnSync() result for docker compose up and exit non-zero on failure to start/pull containers.
tools/local-env/scripts/docker.js Emit an error when Docker cannot be spawned and ensure a non-zero exit code when appropriate.

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

Comment thread tools/local-env/scripts/docker.js Outdated
@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.

…nment command.

`docker.js` exited 0 for any signal, so a command killed by SIGTERM or SIGKILL reported success. That reintroduced the false success this ticket set out to remove: the retry loop in `reusable-phpunit-tests-v3.yml` branches on the status of `npm run env:pull` and would treat a killed pull as a completed one.

Restrict the exemption to SIGINT, which is how a long-running command such as `env:logs` is normally ended. Report every other signal and exit non-zero.

`start.js` exempts no signal, because `env:start` runs `composer update -W` next and that must not run against containers that never came up. Say so in the comment, so the difference between the two files is deliberate.

Also fold the unreachable `up.error` branch in `start.js` into the failure message. The `docker info` check above it already throws when the Docker CLI is missing or the daemon is down.
Copilot AI review requested due to automatic review settings July 28, 2026 14:50

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@adimoldovan
adimoldovan marked this pull request as ready for review July 28, 2026 15:30
@adimoldovan
adimoldovan requested a review from lancewillett July 28, 2026 15:30
@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.

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

Tested with head a88479c

Confirmed failed image pulls and a missing Docker executable exit non-zero. SIGTERM exits non-zero, SIGINT remains clean for interactive commands, and a normal environment start and install > succeeded

The affected code shape was also verified on 6.8, 6.9, and 7.0.

Good to land.

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.

3 participants