Skip to content

Repair wp/5.6 branch Actions: Migrate wp-env to Docker Compose v2 - #310

Closed
desrosj wants to merge 2 commits into
fix-actions-5.6/upgrade-node-to-14from
fix-actions-5.6/docker-compose-v2
Closed

desrosj wants to merge 2 commits into
fix-actions-5.6/upgrade-node-to-14from
fix-actions-5.6/docker-compose-v2

Conversation

@desrosj

@desrosj desrosj commented Sep 13, 2026 •

Copy link
Copy Markdown
Owner

What?

Migrates wp-env (packages/env) from Docker Compose v1 to v2, and fixes the database credentials mismatch the migration exposes.

Why?

Every wp-env job (PHP in unit-test.yml, Admin - 1 to Admin - 4 in end2end-test.yml) fails with spawn docker-compose ENOENT: packages/env runs the standalone Docker Compose v1 binary, which GitHub's runner images no longer ship. Trunk fixed the same problem in #51339 (WordPress@a0943f2, December 2023).

With that fixed, wp-env start reaches the database and fails at wp db check:

mariadb-check: Got error: 1045: Access denied for user 'example username'@'172.18.0.5' (using password: YES) when trying to connect

example username is the wordpress image's placeholder default, used when WORDPRESS_DB_USER/WORDPRESS_DB_PASSWORD are unset. No service on this branch sets them, while the mysql service (MYSQL_ALLOW_EMPTY_PASSWORD: 'yes') only has root with an empty password. This isn't a v2 regression; the v1 ENOENT failure hid it.

How?

  • Migrate wp-env to Docker Compose V2.: adapts trunk's commit to this branch's files (lib/commands/{clean,destroy,logs,run,start,stop}.js, lib/wordpress.js, lib/cli.js). Each require( 'docker-compose' ) uses the v2 export; run.js spawns docker with compose prepended instead of docker-compose; cli.js's error message and its test/cli.js assertion say "docker compose". docker-compose (npm) is pinned to exactly 0.24.0, the newest release still on yaml@^1.10.2, the yaml line the rest of the lockfile uses; 0.24.1 and later move to yaml@^2.2.2, whose optional chaining Node 12 can't parse; the pin predates the Node 14 upgrade in Repair wp/5.6 branch Actions: Upgrade Node.js from 12 to 14 #334, and relaxing it is out of scope. package-lock.json gets a nested yaml@1.10.3 under docker-compose.
  • Set explicit WORDPRESS_DB_USER/WORDPRESS_DB_PASSWORD on every service that talks to the database.: adds WORDPRESS_DB_USER: 'root' and WORDPRESS_DB_PASSWORD: '' to the wordpress, tests-wordpress, cli, tests-cli and phpunit services. Each container reads wp-config.php with its own environment, so all of them need it.

Verified on this fix's earlier unstacked PR (#284) with the react-native-screens fix (#294) applied: Install WordPress got past ENOENT and Access denied. At this point in the stack, CI jobs still stop at the npm ci failure fixed by #294, and then at the database setup that later PRs fix.

Use of AI Tools

This PR was created by Claude Code under my supervision. All code should be treated as AI-produced and not yet reviewed by a human until this PR is marked Ready for Review.

@desrosj desrosj self-assigned this Sep 13, 2026
@desrosj
desrosj added this pull request to stack #159 September 13, 2026 00:45
@desrosj
desrosj removed this pull request from stack #159 September 13, 2026 03:43
@desrosj
desrosj force-pushed the fix-actions-5.6/docker-compose-v2 branch from 6885338 to 19832be Compare September 13, 2026 03:45
@desrosj
desrosj added this pull request to stack #335 September 13, 2026 03:46
@desrosj
desrosj force-pushed the fix-actions-5.6/docker-compose-v2 branch from 19832be to bd48a77 Compare September 13, 2026 04:02
@desrosj
desrosj force-pushed the fix-actions-5.6/docker-compose-v2 branch from bd48a77 to d9caa86 Compare September 14, 2026 00:42
@desrosj
desrosj force-pushed the fix-actions-5.6/docker-compose-v2 branch from d9caa86 to c503481 Compare September 14, 2026 01:39
@desrosj
desrosj force-pushed the fix-actions-5.6/docker-compose-v2 branch from c503481 to 0600678 Compare September 14, 2026 02:02
@desrosj
desrosj removed this pull request from stack #335 September 21, 2026 19:17
@desrosj
desrosj changed the base branch from fix-actions-5.6/add-workflow-concurrency to wp/5.6 September 21, 2026 19:18
@desrosj
desrosj force-pushed the fix-actions-5.6/docker-compose-v2 branch from 0600678 to 97ccb22 Compare September 21, 2026 19:20
@desrosj
desrosj changed the base branch from wp/5.6 to fix-actions-5.6/add-workflow-concurrency September 21, 2026 19:21
@desrosj
desrosj added this pull request to stack #406 September 21, 2026 19:21
@desrosj
desrosj removed this pull request from stack #406 September 22, 2026 16:17
@desrosj
desrosj changed the base branch from fix-actions-5.6/add-workflow-concurrency to wp/5.6 September 22, 2026 16:18
@desrosj
desrosj force-pushed the fix-actions-5.6/docker-compose-v2 branch from 97ccb22 to ab31a7c Compare September 22, 2026 16:20
@desrosj
desrosj changed the base branch from wp/5.6 to fix-actions-5.6/upgrade-node-to-14 September 22, 2026 16:21
@desrosj
desrosj added this pull request to stack #466 September 22, 2026 16:21
@desrosj
desrosj removed this pull request from stack #466 September 23, 2026 21:27
@desrosj
desrosj added this pull request to stack #557 September 28, 2026 17:20
@desrosj
desrosj removed this pull request from stack #557 October 6, 2026 16:14
@desrosj
desrosj added this pull request to stack #631 October 6, 2026 16:14
@desrosj
desrosj force-pushed the fix-actions-5.6/docker-compose-v2 branch from 2104235 to c654745 Compare October 7, 2026 13:03
@desrosj
desrosj removed this pull request from stack #631 October 7, 2026 18:05
@desrosj
desrosj changed the base branch from fix-actions-5.6/upgrade-node-to-14 to wp/5.6 October 7, 2026 18:05
@desrosj
desrosj force-pushed the fix-actions-5.6/docker-compose-v2 branch from c654745 to abb7eda Compare October 7, 2026 18:07
@desrosj
desrosj changed the base branch from wp/5.6 to fix-actions-5.6/upgrade-node-to-14 October 7, 2026 18:08
@desrosj
desrosj added this pull request to stack #670 October 7, 2026 18:08
@desrosj
desrosj force-pushed the fix-actions-5.6/docker-compose-v2 branch from abb7eda to b26f2ee Compare October 8, 2026 17:40
@desrosj
desrosj removed this pull request from stack #670 October 8, 2026 18:01
@desrosj
desrosj added this pull request to stack #690 October 8, 2026 18:01
@desrosj
desrosj force-pushed the fix-actions-5.6/docker-compose-v2 branch from b26f2ee to 508d8c0 Compare October 9, 2026 15:49
@desrosj
desrosj force-pushed the fix-actions-5.6/docker-compose-v2 branch from 508d8c0 to d12092a Compare October 9, 2026 15:54
desrosj and others added 2 commits October 9, 2026 14:17
`wp-env` shells out to the standalone `docker-compose` v1 binary via the
`docker-compose` npm package's default export, and `run.js` spawns a
literal `docker-compose` binary directly. GitHub's current Actions runner
images no longer ship that binary — only the `docker compose` v2
subcommand (via the `docker` CLI plugin) is present — so every `wp-env`
command (`start`, `stop`, `clean`, `logs`, `run`, `destroy`) fails
immediately with `Error: spawn docker-compose ENOENT`, breaking every
e2e/PHPUnit CI job that depends on `wp-env start`.

Switch every `require( 'docker-compose' )` call to the package's `v2`
export, which shells out to `docker compose` instead of the standalone
binary, and update `run.js`'s direct `spawn()` call to invoke `docker`
with a `compose` subcommand rather than the removed `docker-compose`
binary. Update `cli.js`'s error-handling message and its accompanying
unit test in `test/cli.js` to match the new wording. Bump the
`docker-compose` npm dependency from `^0.22.2` to `^0.24.3`, the first
release line whose `v2` export is available, and update
`package-lock.json` accordingly (including a nested `yaml@2.2.2`
dependency required by that version, since the rest of the lockfile is
pinned to `yaml@^1.x`).

`docker-compose@^0.24.3`'s new `yaml` dependency ships as an ESM
package, which Jest cannot parse by default since `node_modules` is
excluded from transformation unless explicitly allow-listed. Add a
`transformIgnorePatterns` entry to `test/unit/jest.config.js` allow-listing
`docker-compose`/`yaml` so Jest can transform them, otherwise
`packages/env`'s own unit tests fail to load with "Jest encountered an
unexpected token."

This is the same fix WordPress#51339 (commit
a0943f2, "wp-env: Migrate to Compose V2")
applied to trunk in December 2023 to fix
WordPress#51249, adapted to this branch's own file layout and
dependency versions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…vice that talks to the database.

Real CI on this PR (after the Docker Compose v2 fix let `wp-env start`
get this far for the first time) showed `wp-env start` hanging for ~30
retries and then failing at the `wp db check` step with:

```
mariadb-check: Got error: 1045: Access denied for user 'example username'@'172.18.0.5' (using password: YES) when trying to connect
```

The literal, space-containing username is not a real credential anyone
configured — it is the hardcoded placeholder default baked into the
official `wordpress` Docker image's `wp-config-docker.php` template:

```php
define( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username') );
define( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password') );
```

`getenv_docker()` re-evaluates these environment variables every time
`wp-config.php` is loaded, in whatever process loads it — it does not
bake a value in once and share it. `wp-config.php` is generated once by
the `wordpress`/`tests-wordpress` apache containers and then read from
the same shared volume by `cli`/`tests-cli` (which is what actually
runs `wp db check`/`wp core install`) and by `phpunit` (via the
`phpunit-wp-config.php` copy `sed` produces from it). Each of those
containers evaluates `getenv_docker()` using *its own* environment, so
setting `WORDPRESS_DB_USER`/`WORDPRESS_DB_PASSWORD` only on
`wordpress`/`tests-wordpress` is not enough — confirmed directly with a
local reproduction: doing only that still failed with the identical
error, because `cli`'s own environment (which is what `wp db check`
actually runs in) still had neither variable set.

This branch's `wordpress`/`tests-wordpress`/`cli`/`tests-cli`/`phpunit`
services only ever set `WORDPRESS_DB_NAME` (or nothing at all, for
`cli`/`tests-cli`/`phpunit`) — never `WORDPRESS_DB_USER` or
`WORDPRESS_DB_PASSWORD` — so every one of them falls back to the
placeholder default. The `mysql` service, meanwhile, is configured with
`MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'` and no `MYSQL_USER`/`MYSQL_PASSWORD`
of its own, so the only account that actually exists in the database is
`root` with an empty password — never a match for the placeholder.

This is not a Docker Compose v1-vs-v2 regression: the environment
variables a `docker-compose.yml` `environment:` block passes into a
container work identically under both `docker-compose` and
`docker compose`, and this branch's own `build-docker-compose-config.js`
never set these two variables anywhere, in either case. The bug was
simply unreachable until now, because `wp-env start` always failed
earlier, at the `docker-compose` v1 binary's `ENOENT`.

Setting `WORDPRESS_DB_USER: 'root'` and `WORDPRESS_DB_PASSWORD: ''`
explicitly on every service that ever reads `wp-config.php` (matching
the `mysql` service's actual, empty-password `root` account) makes each
of them connect as a user that genuinely exists, instead of silently
falling back to the Docker image's documentation placeholder.
@desrosj
desrosj removed this pull request from stack #690 October 9, 2026 19:56
@desrosj
desrosj changed the base branch from fix-actions-5.6/upgrade-node-to-14 to wp/5.6 October 9, 2026 19:56
@desrosj
desrosj force-pushed the fix-actions-5.6/docker-compose-v2 branch from d12092a to 253b1a2 Compare October 9, 2026 19:57
@desrosj
desrosj changed the base branch from wp/5.6 to fix-actions-5.6/upgrade-node-to-14 October 9, 2026 19:58
@desrosj
desrosj added this pull request to stack #721 October 9, 2026 19:59
@desrosj
desrosj removed this pull request from stack #721 October 16, 2026 01:09
@desrosj
desrosj added this pull request to stack #727 October 16, 2026 01:10
@desrosj
desrosj marked this pull request as ready for review October 16, 2026 13:16
@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.

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: 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.

@desrosj

desrosj commented Oct 16, 2026

Copy link
Copy Markdown
Owner Author

Moved to WordPress#84961.

@desrosj desrosj closed this Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant