Repository navigation
Env: Fix PHP unit tests for "non-standard" cloned directories - #39362
Conversation
The PHP unit tests fail if the local copy is cloned into a "non-standard" directory. For example: ``` $ git clone https://github.com/WordPress/gutenberg wp-gutenberg $ npm ci; npm run build $ npm run test-unit-php Could not read "/var/www/html/wp-content/plugins/gutenberg/phpunit.xml.dist". ERROR: 1 ``` To avoid this, we add a new mapping so the hardcoded path on the npm "test-unit-php" script (https://github.com/WordPress/gutenberg/blob/2396f3a095d2dcf6248d60eae262a0564d13e2d9/package.json#L286) works as expected.
docker-compose fails to start if there are duplicate volumes.
noahtallen
left a comment
There was a problem hiding this comment.
Nice, this approach makes sense to me.
|
@carolinan You might want to give this a test on Windows to make sure all is still good? I don't use it primarily for dev or I would. I feel like a Windows sign off could be good for this as well. |
|
Unfortunately, running any wp-env commands has not worked for me on Windows for many months and the errors are unrelated to the PHP unit test. It started with the destroy command not working, but after that was solved, eventually it escalated to not working at all. I gave it a good try, but I am not able to test the PR. |
ajlende
left a comment
There was a problem hiding this comment.
Tested on Linux where I was having issues with the same thing, and it worked for me
|
Strangle I've recountered something similar today. Test failure: |
….9) (#85712) * Env: Don't add duplicate volumes to the generated docker-compose.yml file. docker-compose fails to start if a volume is listed more than once. That happens when a directory mapping and a plugin source resolve to the same path, such as mapping `wp-content/plugins/gutenberg` to `.` while `.` is also loaded as a plugin from a checkout named `gutenberg`. Backports the `packages/env` part of #39362. (cherry picked from commit 936ce3a) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Env: Mount the plugin at `wp-content/plugins/gutenberg` in the tests environment. The PHP unit test commands use the hardcoded path `/var/www/html/wp-content/plugins/gutenberg`, but wp-env mounts the plugin under the name of the directory it was checked out into. In a checkout with any other name, PHPUnit fails with: Could not read "/var/www/html/wp-content/plugins/gutenberg/phpunit.xml.dist". Map `wp-content/plugins/gutenberg` to the repository root so the path always exists. Backports the `.wp-env.json` part of #39362. (cherry picked from commit 936ce3a) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Alex Concha <xknown@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: desrosj <desrosj@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
….8) (#85711) * Env: Don't add duplicate volumes to the generated docker-compose.yml file. docker-compose fails to start if a volume is listed more than once. That happens when a directory mapping and a plugin source resolve to the same path, such as mapping `wp-content/plugins/gutenberg` to `.` while `.` is also loaded as a plugin from a checkout named `gutenberg`. Backports the `packages/env` part of #39362. (cherry picked from commit 936ce3a) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Env: Mount the plugin at `wp-content/plugins/gutenberg` in the tests environment. The PHP unit test commands use the hardcoded path `/var/www/html/wp-content/plugins/gutenberg`, but wp-env mounts the plugin under the name of the directory it was checked out into. In a checkout with any other name, PHPUnit fails with: Could not read "/var/www/html/wp-content/plugins/gutenberg/phpunit.xml.dist". Map `wp-content/plugins/gutenberg` to the repository root so the path always exists. Backports the `.wp-env.json` part of #39362. (cherry picked from commit 936ce3a) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Alex Concha <xknown@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: desrosj <desrosj@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
….7) (#85710) * Env: Don't add duplicate volumes to the generated docker-compose.yml file. docker-compose fails to start if a volume is listed more than once. That happens when a directory mapping and a plugin source resolve to the same path, such as mapping `wp-content/plugins/gutenberg` to `.` while `.` is also loaded as a plugin from a checkout named `gutenberg`. Backports the `packages/env` part of #39362. (cherry picked from commit 936ce3a) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Env: Mount the plugin at `wp-content/plugins/gutenberg` in the tests environment. The PHP unit test commands use the hardcoded path `/var/www/html/wp-content/plugins/gutenberg`, but wp-env mounts the plugin under the name of the directory it was checked out into. In a checkout with any other name, PHPUnit fails with: Could not read "/var/www/html/wp-content/plugins/gutenberg/phpunit.xml.dist". Map `wp-content/plugins/gutenberg` to the repository root so the path always exists. Backports the `.wp-env.json` part of #39362. (cherry picked from commit 936ce3a) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Alex Concha <xknown@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: desrosj <desrosj@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
….6) (#85709) * Env: Don't add duplicate volumes to the generated docker-compose.yml file. docker-compose fails to start if a volume is listed more than once. That happens when a directory mapping and a plugin source resolve to the same path, such as mapping `wp-content/plugins/gutenberg` to `.` while `.` is also loaded as a plugin from a checkout named `gutenberg`. Backports the `packages/env` part of #39362. (cherry picked from commit 936ce3a) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Env: Mount the plugin at `wp-content/plugins/gutenberg` in the tests environment. The PHP unit test commands use the hardcoded path `/var/www/html/wp-content/plugins/gutenberg`, but wp-env mounts the plugin under the name of the directory it was checked out into. In a checkout with any other name, PHPUnit fails with: Could not read "/var/www/html/wp-content/plugins/gutenberg/phpunit.xml.dist". Map `wp-content/plugins/gutenberg` to the repository root so the path always exists. Backports the `.wp-env.json` part of #39362. (cherry picked from commit 936ce3a) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Alex Concha <xknown@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: desrosj <desrosj@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
….5) (#85708) * Env: Don't add duplicate volumes to the generated docker-compose.yml file. docker-compose fails to start if a volume is listed more than once. That happens when a directory mapping and a plugin source resolve to the same path, such as mapping `wp-content/plugins/gutenberg` to `.` while `.` is also loaded as a plugin from a checkout named `gutenberg`. Adapted from the `packages/env` part of #39362 for this branch's version of wp-env, which builds a single list of local mounts for every service. Co-authored-by: Alex Concha <xknown@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Env: Mount the plugin at `wp-content/plugins/gutenberg`. The PHP unit test commands use the hardcoded path `/var/www/html/wp-content/plugins/gutenberg`, but wp-env mounts the plugin under the name of the directory it was checked out into. In a checkout with any other name, PHPUnit fails with: Could not read "/var/www/html/wp-content/plugins/gutenberg/phpunit.xml.dist". Map `wp-content/plugins/gutenberg` to the repository root so the path always exists. This branch's version of wp-env does not support per-environment mappings, so the mapping is added at the top level. Adapted from the `.wp-env.json` part of #39362. Co-authored-by: Alex Concha <xknown@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Alex Concha <xknown@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: desrosj <desrosj@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
What?
It updates the
wp-envconfig file so the PHP unit tests work as expected on a non-standard cloned directory.Why?
The PHP unit tests fail if our local copy is cloned into a "non-standard" directory.
For example:
How?
It updates the
.wp-env.jsonconfig file to map the volumewp-content/plugins/gutenbergto the current directory.This is required because we have a few hardcoded paths in the
package.jsonfile.gutenberg/package.json
Line 286 in 2396f3a
Testing Instructions
Run the PHP unit tests.
Screenshots or screencast