ci: make npm run test:php actually work#2
Closed
epeicher wants to merge 6 commits into
Closed
Conversation
A fresh clone had no way to run PHP tests — `vendor/bin/phpunit` didn't exist and the test suite script had to be curl'd in CI every run. Wire up a Composer-based toolchain so local and CI share the same binary and setup flow. - composer.json / composer.lock: pin phpunit/phpunit ^9.6 and yoast/phpunit-polyfills ^2.0 (what WP's test suite needs on PHPUnit 9). PHP version constraint matches the plugin's header (>=7.4). - bin/install-wp-tests.sh: commit the canonical wp-cli scaffold installer (pinned from v2.4.0) so CI no longer has to curl it and local runs work the same way. - package.json: `test:php` runs `vendor/bin/phpunit …`; `test:php:install` is a convenience wrapper around the SVN-based installer with sensible local defaults (root / no password / 127.0.0.1 / latest). - tests/phpunit/bootstrap.php: require vendor/autoload.php first so phpunit-polyfills loads. Also improves the "tests not installed" error message to point at `test:php:install`. - .github/workflows/ci.yml: drop the phpunit:9 tool pin (Composer provides it), add a `composer install` step, and call the committed `bin/install-wp-tests.sh` instead of the inline curl. - .gitignore: exclude /vendor. - DEVELOPMENT.md: document the one-time setup — `composer install`, MySQL running, SVN present, then `npm run test:php:install`.
The old lockfile held only macOS-arm64 entries for `@esbuild/*`, so CI's Linux runner couldn't resolve them and `npm ci` bailed with "Missing: @esbuild/linux-x64@0.28.0 from lock file" (and 20+ more). A clean `npm install` writes the lockfile with every platform's optional binary, which is what npm 7+ expects.
Composer installed on my local PHP 8.5 pulled `doctrine/instantiator 2.1.0` into the lock, which requires PHP 8.4+. CI runs PHP 8.1 and 8.2 — the lock failed to resolve and `composer install` bailed. Setting `config.platform.php = "8.1"` in composer.json forces the resolver to pick versions compatible with the oldest CI matrix leg. Regenerated composer.lock drops instantiator back to 2.0.0 (PHP 7.4+) while keeping PHPUnit 9.6.34.
Fresh `npm install` on Node 24 / npm 11 left 28 entries in package-lock.json marked `"extraneous": true` — mostly `@esbuild/<platform>` optional binaries. `npm ci` on CI (Node 20) refused to install those because their platform metadata doesn't match the Linux runner, even though they're nominally optional. `npm prune` after install drops them cleanly from the lockfile, leaving only entries the dep tree actually references.
Mirror fix/lint-errors 9cfe655 — regenerate package-lock.json on node:20-alpine so CI's `npm ci` resolves cleanly. Replaces the previous Mac-generated-then-pruned lockfile that left npm short of legitimate `esbuild@0.28.0` entries.
This was referenced Apr 23, 2026
Collaborator
Author
|
Closed in favour of #7 |
This was referenced Apr 29, 2026
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A fresh clone had no way to run PHP tests —
vendor/bin/phpunitdidn't exist, and CI had to curl the WP test installer every run. This wires up a Composer-based toolchain so local dev and CI share one binary and one setup flow.composer.json+composer.lockpinphpunit/phpunit ^9.6andyoast/phpunit-polyfills ^2.0bin/install-wp-tests.shis the canonical wp-cli scaffold installer, pinned so CI no longer curls itpackage.json:test:php→vendor/bin/phpunit …; newtest:php:installwraps the SVN installer with local defaultstests/phpunit/bootstrap.phploads the Composer autoload first (polyfills) and points the "missing test suite" error attest:php:install.github/workflows/ci.ymldrops thephpunit:9tool pin, addscomposer install, calls the committed installerDEVELOPMENT.mddocuments the one-time setup (svn, MySQL,composer install,npm run test:php:install)Test plan
bin/install-wp-tests.shpopulates/tmp/wordpress-tests-libcomposer install+npm run test:php:install+npm run test:phpsucceeds