From bd8e6504b2ea6cc6f96e5d4b958ab3a826807670 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Fri, 18 Oct 2024 13:37:23 +0000 Subject: [PATCH] Build/Test Tools: Add input for PHPUnit test group. This adds a `phpunit-test-goups` input to the reusable PHPUnit test workflow for added flexibility. When passed, only the specified test groups are run. Props jrf. See #52668. git-svn-id: https://develop.svn.wordpress.org/trunk@59251 602fd350-edb4-49c9-b593-d223f7449a82 --- .../workflows/reusable-phpunit-tests-v3.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/reusable-phpunit-tests-v3.yml b/.github/workflows/reusable-phpunit-tests-v3.yml index 80c08e95fd..5acdbae89c 100644 --- a/.github/workflows/reusable-phpunit-tests-v3.yml +++ b/.github/workflows/reusable-phpunit-tests-v3.yml @@ -42,6 +42,11 @@ on: required: false type: 'string' default: 'phpunit.xml.dist' + phpunit-test-groups: + description: 'A list of test groups to run.' + required: false + type: 'string' + default: '' tests-domain: description: 'The domain to use for the tests' required: false @@ -87,7 +92,7 @@ jobs: # - Checks out the WordPress Test reporter repository. # - Submit the test results to the WordPress.org host test results. phpunit-tests: - name: PHP ${{ inputs.php }} / ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }}${{ inputs.memcached && ' with memcached' || '' }}${{ inputs.report && ' (test reporting enabled)' || '' }} ${{ 'example.org' != inputs.tests-domain && inputs.tests-domain || '' }} + name: PHP ${{ inputs.php }} / ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }}${{ inputs.phpunit-test-groups && format( ' ({0})', inputs.phpunit-test-groups ) || '' }}${{ inputs.memcached && ' with memcached' || '' }}${{ inputs.report && ' (test reporting enabled)' || '' }} ${{ 'example.org' != inputs.tests-domain && inputs.tests-domain || '' }} runs-on: ${{ inputs.os }} timeout-minutes: 20 @@ -162,27 +167,28 @@ jobs: - name: Install WordPress run: npm run env:install - - name: Run PHPUnit tests + - name: Run PHPUnit tests${{ inputs.phpunit-test-groups && format( ' ({0} groups)', inputs.phpunit-test-groups ) || '' }} continue-on-error: ${{ inputs.allow-errors }} - run: node ./tools/local-env/scripts/docker.js run 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 }}${{ inputs.phpunit-test-groups && format( ' --group {0}', inputs.phpunit-test-groups ) || '' }} - name: Run AJAX tests + if: ${{ ! inputs.phpunit-test-groups }} continue-on-error: ${{ inputs.allow-errors }} 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: ${{ inputs.multisite }} + if: ${{ inputs.multisite && ! inputs.phpunit-test-groups }} continue-on-error: ${{ inputs.allow-errors }} run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ms-files - name: Run external HTTP tests - if: ${{ ! inputs.multisite }} + if: ${{ ! inputs.multisite && ! inputs.phpunit-test-groups }} continue-on-error: ${{ inputs.allow-errors }} run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group external-http # __fakegroup__ is excluded to force PHPUnit to ignore the settings in phpunit.xml.dist. - name: Run (Xdebug) tests - if: ${{ inputs.php != '8.4' }} + if: ${{ inputs.php != '8.4' && ! inputs.phpunit-test-groups }} continue-on-error: ${{ inputs.allow-errors }} run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__