Build/Test Tools: Remove the PHPUnit container from local Docker environment.

This commit:

* Removes the PHPUnit `wordpressdevelop/phpunit` container as a service to the Docker environment.
* Updates `test:php` (the default way to run tests) to run the Composer PHPUnit package  default.
* Removes the `test:php-composer` script.

There is no longer a need for core to keep the `wordpressdevelop/phpunit` container as a service in `docker-compose.yml`. Removing it will reduce the overhead and bandwidth needed to set up WordPress locally and remove confusion about its use.

Follow-up to [45783-45784], [49099], [49362], [51545], [51736], [51685].

Props johnbillion, hellofromTonya.
Fixes #54112.

git-svn-id: https://develop.svn.wordpress.org/trunk@51868 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork 2021-09-24 16:54:42 +00:00
parent 3546c694e9
commit 284764c658
5 changed files with 11 additions and 66 deletions

22
.env
View File

@ -6,7 +6,6 @@
#
# Below, the following substitutions can be made:
# - '{version}': any major.minor PHP version from 5.2 onwards.
# - '{phpunit_version}': any major PHPUnit version starting with 4.
##
# The site will be available at http://localhost:LOCAL_PORT
@ -18,27 +17,6 @@ LOCAL_DIR=src
# The PHP version to use. Valid options are 'latest', and '{version}-fpm'.
LOCAL_PHP=latest
##
# The PHPUnit version to use when running tests.
#
# Support for new PHPUnit versions is not backported to past versions, so some old WordPress branches require an older
# version to run tests.
#
# Valid versions are:
# - 'latest' for the highest version of PHPUnit supported on the highest version of PHP supported.
# - '{version}-fpm' for the highest version of PHPUnit supported on the specified version of PHP.
# - '{phpunit_version}-php-{version}-fpm' for a specific version of PHPUnit on the specified version of PHP. This format
# is only available for PHP versions 5.6 and higher.
#
# For the full list of available options, see https://hub.docker.com/r/wordpressdevelop/phpunit/tags.
#
# For full documentation on PHPUnit compatibility and WordPress versions, see
# https://make.wordpress.org/core/handbook/references/phpunit-compatibility-and-wordpress-versions/.
#
# This defaults to the value assigned to the value of LOCAL_PHP.
##
LOCAL_PHPUNIT=${LOCAL_PHP}
# Whether or not to enable XDebug.
LOCAL_PHP_XDEBUG=false

View File

@ -191,41 +191,41 @@ jobs:
- name: Run slow PHPUnit tests
if: ${{ matrix.split_slow }}
run: node ./tools/local-env/scripts/docker.js run --rm phpunit php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
- name: Run PHPUnit tests for single site excluding slow tests
if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }}
run: node ./tools/local-env/scripts/docker.js run --rm phpunit php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required
- name: Run PHPUnit tests for Multisite excluding slow tests
if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }}
run: node ./tools/local-env/scripts/docker.js run --rm phpunit php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers
- name: Run PHPUnit tests
if: ${{ matrix.php >= '7.0' }}
continue-on-error: ${{ matrix.php == '8.1' }}
run: node ./tools/local-env/scripts/docker.js run --rm phpunit php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }}
- name: Run AJAX tests
if: ${{ ! matrix.split_slow }}
continue-on-error: ${{ matrix.php == '8.1' }}
run: node ./tools/local-env/scripts/docker.js run --rm phpunit php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
- name: Run ms-files tests as a multisite install
if: ${{ matrix.multisite && ! matrix.split_slow }}
continue-on-error: ${{ matrix.php == '8.1' }}
run: node ./tools/local-env/scripts/docker.js run --rm phpunit php ./vendor/bin/phpunit --verbose -c tests/phpunit/multisite.xml --group ms-files
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c tests/phpunit/multisite.xml --group ms-files
- name: Run external HTTP tests
if: ${{ ! matrix.multisite && ! matrix.split_slow }}
continue-on-error: ${{ matrix.php == '8.1' }}
run: node ./tools/local-env/scripts/docker.js run --rm phpunit php ./vendor/bin/phpunit --verbose -c phpunit.xml.dist --group external-http
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c phpunit.xml.dist --group external-http
# __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
- name: Run (xDebug) tests
if: ${{ ! matrix.split_slow }}
continue-on-error: ${{ matrix.php == '8.1' }}
run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run --rm phpunit php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__
run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__
- name: Ensure version-controlled files are not modified or deleted
run: git diff --exit-code

View File

@ -143,7 +143,7 @@ jobs:
- name: Run tests as a single site
if: ${{ ! matrix.multisite }}
run: npm run test:php-composer -- --verbose -c phpunit.xml.dist --coverage-clover wp-code-coverage-single-clover-${{ github.sha }}.xml
run: npm run test:php -- --verbose -c phpunit.xml.dist --coverage-clover wp-code-coverage-single-clover-${{ github.sha }}.xml
- name: Ensure version-controlled files are not modified during the tests
run: git diff --exit-code
@ -157,7 +157,7 @@ jobs:
- name: Run tests as a multisite install
if: ${{ matrix.multisite }}
run: npm run test:php-composer -- --verbose -c tests/phpunit/multisite.xml --coverage-clover wp-code-coverage-multisite-clover-${{ github.sha }}.xml
run: npm run test:php -- --verbose -c tests/phpunit/multisite.xml --coverage-clover wp-code-coverage-multisite-clover-${{ github.sha }}.xml
- name: Ensure version-controlled files are not modified during the tests
run: git diff --exit-code

View File

@ -92,41 +92,9 @@ services:
# The init directive ensures the command runs with a PID > 1, so Ctrl+C works correctly.
init: true
##
# The PHPUnit container.
##
phpunit:
image: wordpressdevelop/phpunit:${LOCAL_PHPUNIT-latest}
networks:
- wpdevnet
environment:
- LOCAL_PHP_XDEBUG=${LOCAL_PHP_XDEBUG-false}
- LOCAL_PHP_MEMCACHED=${LOCAL_PHP_MEMCACHED-false}
- PHP_FPM_UID=${PHP_FPM_UID-1000}
- PHP_FPM_GID=${PHP_FPM_GID-1000}
- LOCAL_DIR=${LOCAL_DIR-src}
- WP_MULTISITE=${WP_MULTISITE-false}
- GITHUB_REF=${GITHUB_REF-false}
- GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME-false}
volumes:
- ./tools/local-env/phpunit-config.ini:/usr/local/etc/php/conf.d/phpunit-config.ini
- ./:/var/www
- phpunit-uploads:/var/www/${LOCAL_DIR-src}/wp-content/uploads
# The init directive ensures the command runs with a PID > 1, so Ctrl+C works correctly.
init: true
depends_on:
- mysql
volumes:
# So that sites aren't wiped every time containers are restarted, MySQL uses a persistent volume.
mysql: {}
# Using a volume for the uploads directory improves PHPUnit performance.
phpunit-uploads: {}
networks:
# Creating our own network allows us to connect between containers using their service name.

View File

@ -170,8 +170,7 @@
"env:cli": "node ./tools/local-env/scripts/docker.js run cli",
"env:logs": "node ./tools/local-env/scripts/docker.js logs",
"env:pull": "node ./tools/local-env/scripts/docker.js pull",
"test:php": "node ./tools/local-env/scripts/docker.js run -T php composer update -W && node ./tools/local-env/scripts/docker.js run --rm phpunit phpunit",
"test:php-composer": "node ./tools/local-env/scripts/docker.js run -T php composer update -W && node ./tools/local-env/scripts/docker.js run --rm phpunit php ./vendor/bin/phpunit",
"test:php": "node ./tools/local-env/scripts/docker.js run -T php composer update -W && node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit",
"test:e2e": "node ./tests/e2e/run-tests.js",
"wp-packages-update": "wp-scripts packages-update"
}