You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working on integrating wp-env into a GitLab CI pipeline for a WordPress plugin project. The goal is to run PHPUnit tests automatically across multiple versions of PHP and WordPress.
So far, I’ve made it work almost completely, but there are a few caveats and unexpected behaviors that are making this more difficult than expected:
Setup
CI is based on docker:dind
@wordpress/env is installed via npm
I provide .wp-env.json and set WP_ENV_HOME dynamically per pipeline using CI_PIPELINE_ID to isolate each environment
su-exec wpuser is used to simulate a non-root environment (Docker rootless doesn’t fully work with wp-env due to permission errors)
Main issues encountered
--allow-root not available
There is no way to force wp-env to run as root (--allow-root like WP-CLI).
This makes CI workarounds a bit hacky, requiring:
manually creating a user with adduser
using su-exec wpuser to run any command related to wp-env
It would be helpful if wp-env could detect CI or root environments and allow this explicitly with a flag.
PHPUnit test files are not installed
Despite wp-env starting correctly, the test files (/wordpress-phpunit) are not always installed or are missing functions.php, causing:
Could not find /wordpress-phpunit/includes/functions.php, have you run install-wp-tests.sh ?
As a workaround, I now manually clone the wordpress-develop repo and copy over the tests/phpunit/includes and tests/phpunit/data folders into /tmp/wordpress-tests-lib.
Not sure if this is due to a permission issue, or a bug in the way wp-env sets up the test environment in headless CI.
WordPress version is not respected in cli and tests-cli containers
Even when specifying this in .wp-env.json:
"core": "WordPress/WordPress#tags/6.5" or "core": "WordPress/WordPress#6.5"
And setting WP_ENV_CORE and WP_ENV_PHP_VERSION before calling wp-env start, the version of WordPress in the cli and tests-cli containers remains the latest (e.g. 6.7.2).
The docker-compose.yml logs show 6.5 being fetched, but the version reported by wp core version is still 6.7.2 inside the containers. Idk if its related to .wp-env-cache.json. Each new pipeline contains same hash.
Suggestions
Add a way to force version or reset .wp-env cache manually (--clear-cache?)
Add a --allow-root option or handle root automatically in CI
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi 👋
I'm currently working on integrating wp-env into a GitLab CI pipeline for a WordPress plugin project. The goal is to run PHPUnit tests automatically across multiple versions of PHP and WordPress.
So far, I’ve made it work almost completely, but there are a few caveats and unexpected behaviors that are making this more difficult than expected:
Setup
Main issues encountered
There is no way to force wp-env to run as root (--allow-root like WP-CLI).
This makes CI workarounds a bit hacky, requiring:
It would be helpful if wp-env could detect CI or root environments and allow this explicitly with a flag.
Despite wp-env starting correctly, the test files (/wordpress-phpunit) are not always installed or are missing functions.php, causing:
Could not find /wordpress-phpunit/includes/functions.php, have you run install-wp-tests.sh ?As a workaround, I now manually clone the wordpress-develop repo and copy over the tests/phpunit/includes and tests/phpunit/data folders into /tmp/wordpress-tests-lib.
Not sure if this is due to a permission issue, or a bug in the way wp-env sets up the test environment in headless CI.
Even when specifying this in .wp-env.json:
"core": "WordPress/WordPress#tags/6.5"or"core": "WordPress/WordPress#6.5"And setting WP_ENV_CORE and WP_ENV_PHP_VERSION before calling wp-env start, the version of WordPress in the cli and tests-cli containers remains the latest (e.g. 6.7.2).
The docker-compose.yml logs show 6.5 being fetched, but the version reported by wp core version is still 6.7.2 inside the containers. Idk if its related to .wp-env-cache.json. Each new pipeline contains same hash.
Suggestions
gitlab-ci.yml (atm)
Beta Was this translation helpful? Give feedback.
All reactions