Build/Test Tools: Simplify the PHPUnit test workflow.

This removes the previously duplicated set of test runs specifically for PHP 8.1 in favor of combining `if` conditions for individual test runs with the `continue-on-error` option.

Follow-up to [51588].

Props desrosj, swissspidy, jrf.
Fixes .

git-svn-id: https://develop.svn.wordpress.org/trunk@51604 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2021-08-11 15:42:06 +00:00
parent f7a7025899
commit 8df58341a5

@ -36,6 +36,9 @@ env:
jobs:
# Runs the PHPUnit tests for WordPress.
#
# Note: Steps running tests for PHP 8.1 jobs are allowed to "continue-on-error".
# This prevents workflow runs from being marked as "failed" when only PHP 8.1 fails.
#
# Performs the following steps:
# - Set environment variables.
# - Sets up the environment variables needed for testing with memcached (if desired).
@ -188,7 +191,7 @@ jobs:
run: npm run env:install
- name: Run slow PHPUnit tests
if: ${{ matrix.php != '8.1' && matrix.split_slow }}
if: ${{ matrix.split_slow }}
run: npm run test:php-composer -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
- name: Run PHPUnit tests for single site excluding slow tests
@ -200,64 +203,31 @@ jobs:
run: npm run test:php-composer -- --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' && matrix.php != '8.1' }}
if: ${{ matrix.php >= '7.0' }}
continue-on-error: ${{ matrix.php == '8.1' }}
run: npm run test:php-composer -- --verbose -c ${{ env.PHPUNIT_CONFIG }}
- name: Run AJAX tests
if: ${{ matrix.php != '8.1' && ! matrix.split_slow }}
if: ${{ ! matrix.split_slow }}
continue-on-error: ${{ matrix.php == '8.1' }}
run: npm run test:php-composer -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
- name: Run ms-files tests as a multisite install
if: ${{ matrix.php != '8.1' && matrix.multisite && ! matrix.split_slow }}
if: ${{ matrix.multisite && ! matrix.split_slow }}
continue-on-error: ${{ matrix.php == '8.1' }}
run: npm run test:php-composer -- --verbose -c tests/phpunit/multisite.xml --group ms-files
- name: Run external HTTP tests
if: ${{ matrix.php != '8.1' && ! matrix.multisite && ! matrix.split_slow }}
if: ${{ ! matrix.multisite && ! matrix.split_slow }}
continue-on-error: ${{ matrix.php == '8.1' }}
run: npm run test:php-composer -- --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.php != '8.1' && ! matrix.split_slow }}
if: ${{ ! matrix.split_slow }}
continue-on-error: ${{ matrix.php == '8.1' }}
run: LOCAL_PHP_XDEBUG=true npm run test:php-composer -- -v --group xdebug --exclude-group __fakegroup__
#### Duplicate set of test runs specifically for PHP 8.1 while WP is not yet compatible. ####
# Splitting off the test runs for PHP 8.1 allows us to apply "continue-on-error" to the job steps,
# which will prevent the builds from showing as "failed" when they only fail on PHP 8.1.
# This block should be removed once all PHP 8.1 test failures have been fixed.
# When the block is removed, the conditions in the block above should also be adjusted back
# to their original values.
- name: Run slow PHPUnit tests
if: ${{ matrix.php == '8.1' && matrix.split_slow }}
continue-on-error: true
run: npm run test:php-composer -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
- name: Run PHPUnit tests
if: ${{ matrix.php == '8.1' }}
continue-on-error: true
run: npm run test:php-composer -- --verbose -c ${{ env.PHPUNIT_CONFIG }}
- name: Run AJAX tests
if: ${{ matrix.php == '8.1' && ! matrix.split_slow }}
continue-on-error: true
run: npm run test:php-composer -- --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
- name: Run ms-files tests as a multisite install
if: ${{ matrix.php == '8.1' && matrix.multisite && ! matrix.split_slow }}
continue-on-error: true
run: npm run test:php-composer -- --verbose -c tests/phpunit/multisite.xml --group ms-files
- name: Run external HTTP tests
if: ${{ matrix.php == '8.1' && ! matrix.multisite && ! matrix.split_slow }}
continue-on-error: true
run: npm run test:php-composer -- --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.php == '8.1' && ! matrix.split_slow }}
continue-on-error: true
run: LOCAL_PHP_XDEBUG=true npm run test:php-composer -- -v --group xdebug --exclude-group __fakegroup__
#### End of duplicate set of test runs. ####
- name: Ensure version-controlled files are not modified or deleted
run: git diff --exit-code