Changeset 59287
- Timestamp:
- 10/24/2024 03:07:06 PM (6 months ago)
- Location:
- trunk/.github/workflows
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.github/workflows/reusable-phpunit-tests-v3.yml
r59251 r59287 53 53 type: 'string' 54 54 default: 'example.org' 55 coverage-report: 56 description: 'Whether to generate a code coverage report.' 57 required: false 58 type: boolean 59 default: false 55 60 report: 56 61 description: 'Whether to report results to WordPress.org Hosting Tests' … … 63 68 type: boolean 64 69 default: false 70 secrets: 71 CODECOV_TOKEN: 72 description: 'The Codecov token required for uploading reports.' 73 required: false 65 74 env: 66 75 LOCAL_PHP: ${{ inputs.php }}-fpm 76 LOCAL_PHP_XDEBUG: ${{ inputs.coverage-report || false }} 77 LOCAL_PHP_XDEBUG_MODE: ${{ inputs.coverage-report && 'coverage' || 'develop,debug' }} 67 78 LOCAL_DB_TYPE: ${{ inputs.db-type }} 68 79 LOCAL_DB_VERSION: ${{ inputs.db-version }} … … 89 100 # - Install WordPress within the Docker container. 90 101 # - Run the PHPUnit tests. 102 # - Upload the code coverage report to Codecov.io. 103 # - Upload the HTML code coverage report as an artifact. 91 104 # - Ensures version-controlled files are not modified or deleted. 92 105 # - Checks out the WordPress Test reporter repository. 93 106 # - Submit the test results to the WordPress.org host test results. 94 107 phpunit-tests: 95 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 || '' }}108 name: PHP ${{ inputs.php }} ${{ ! inputs.coverage-report && '/ ' || 'with ' }}${{ '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 || '' }} 96 109 runs-on: ${{ inputs.os }} 97 timeout-minutes: 20110 timeout-minutes: ${{ inputs.coverage-report && 120 || 20 }} 98 111 99 112 steps: … … 168 181 run: npm run env:install 169 182 170 - name: Run PHPUnit tests${{ inputs.phpunit-test-groups && format( ' ({0} groups)', inputs.phpunit-test-groups ) || '' }} 171 continue-on-error: ${{ inputs.allow-errors }} 172 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 ) || '' }} 183 - name: Run PHPUnit tests${{ inputs.phpunit-test-groups && format( ' ({0} groups)', inputs.phpunit-test-groups ) || '' }}${{ inputs.coverage-report && ' with coverage report' || '' }} 184 continue-on-error: ${{ inputs.allow-errors }} 185 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 ) || '' }}${{ inputs.coverage-report && format( ' --coverage-clover wp-code-coverage-{0}-{1}.xml --coverage-html wp-code-coverage-{0}-{1}', ( inputs.multisite && 'multisite' || 'single' ), github.sha ) || '' }} 173 186 174 187 - name: Run AJAX tests 175 if: ${{ ! inputs.phpunit-test-groups }}188 if: ${{ ! inputs.phpunit-test-groups && ! inputs.coverage-report }} 176 189 continue-on-error: ${{ inputs.allow-errors }} 177 190 run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax 178 191 179 192 - name: Run ms-files tests as a multisite install 180 if: ${{ inputs.multisite && ! inputs.phpunit-test-groups }}193 if: ${{ inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-report }} 181 194 continue-on-error: ${{ inputs.allow-errors }} 182 195 run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ms-files 183 196 184 197 - name: Run external HTTP tests 185 if: ${{ ! inputs.multisite && ! inputs.phpunit-test-groups }}198 if: ${{ ! inputs.multisite && ! inputs.phpunit-test-groups && ! inputs.coverage-report }} 186 199 continue-on-error: ${{ inputs.allow-errors }} 187 200 run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group external-http … … 189 202 # __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist. 190 203 - name: Run (Xdebug) tests 191 if: ${{ inputs.php != '8.4' && ! inputs.phpunit-test-groups }}204 if: ${{ inputs.php != '8.4' && ! inputs.phpunit-test-groups && ! inputs.coverage-report }} 192 205 continue-on-error: ${{ inputs.allow-errors }} 193 206 run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__ 207 208 - name: Upload test coverage report to Codecov 209 if: ${{ inputs.coverage-report }} 210 uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 211 with: 212 token: ${{ secrets.CODECOV_TOKEN }} 213 file: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }}.xml 214 flags: ${{ inputs.multisite && 'multisite' || 'single' }},php 215 fail_ci_if_error: true 216 217 - name: Upload HTML coverage report as artifact 218 if: ${{ inputs.coverage-report }} 219 uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 220 with: 221 name: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }} 222 path: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }} 223 overwrite: true 194 224 195 225 - name: Ensure version-controlled files are not modified or deleted -
trunk/.github/workflows/test-coverage.yml
r59208 r59287 25 25 workflow_dispatch: 26 26 27 # Cancels all previous workflow runs for pull requests that have not completed. 28 concurrency: 29 # The concurrency group contains the workflow name and the branch name for pull requests 30 # or the commit hash for any other events. 31 group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} 32 cancel-in-progress: true 33 27 34 # Disable permissions for all available scopes by default. 28 35 # Any needed permissions should be configured at the job level. … … 36 43 37 44 jobs: 38 # Runs the PHPUnit tests for WordPress.39 45 # 40 # Performs the following steps: 41 # - Sets environment variables. 42 # - Checks out the repository. 43 # - Sets up Node.js. 44 # - Sets up PHP. 45 # - Installs Composer dependencies. 46 # - Installs npm dependencies 47 # - Logs general debug information about the runner. 48 # - Logs Docker debug information (about the Docker installation within the runner). 49 # - Starts the WordPress Docker container. 50 # - Logs the running Docker containers. 51 # - Logs debug information about what's installed within the WordPress Docker containers. 52 # - Install WordPress within the Docker container. 53 # - Run the PHPUnit tests as a single site. 54 # - Ensures version-controlled files are not modified or deleted. 55 # - Upload the single site code coverage report to Codecov.io. 56 # - Run the PHPUnit tests as a multisite installation. 57 # - Ensures version-controlled files are not modified or deleted. 58 # - Upload the multisite code coverage report to Codecov.io. 46 # Creates a PHPUnit test jobs for generating code coverage reports. 47 # 59 48 test-coverage-report: 60 name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} report (${{ matrix.format }})61 runs-on: ubuntu-latest49 name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} report 50 uses: WordPress/wordpress-develop/.github/workflows/reusable-phpunit-tests-v3.yml@trunk 62 51 permissions: 63 52 contents: read 64 timeout-minutes: 12065 53 if: ${{ github.repository == 'WordPress/wordpress-develop' }} 66 54 strategy: … … 68 56 matrix: 69 57 multisite: [ false, true ] 70 format: [ clover, html ] 71 72 steps: 73 - name: Configure environment variables 74 run: | 75 echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV 76 echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV 77 78 - name: Checkout repository 79 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 80 with: 81 show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} 82 83 - name: Set up Node.js 84 uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 85 with: 86 node-version-file: '.nvmrc' 87 cache: npm 88 89 ## 90 # This allows Composer dependencies to be installed using a single step. 91 # 92 # Since the tests are currently run within the Docker containers where the PHP version varies, 93 # the same PHP version needs to be configured for the action runner machine so that the correct 94 # dependency versions are installed and cached. 95 ## 96 - name: Set up PHP 97 uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1 98 with: 99 php-version: '7.4' 100 coverage: none 101 102 # Since Composer dependencies are installed using `composer update` and no lock file is in version control, 103 # passing a custom cache suffix ensures that the cache is flushed at least once per week. 104 - name: Install Composer dependencies 105 uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a # v3.0.0 106 with: 107 custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") 108 109 - name: Install npm Dependencies 110 run: npm ci 111 112 - name: Log debug information 113 run: | 114 echo "$GITHUB_REF" 115 echo "$GITHUB_EVENT_NAME" 116 npm --version 117 node --version 118 curl --version 119 git --version 120 composer --version 121 locale -a 122 123 - name: Docker debug information 124 run: | 125 docker -v 126 127 - name: Start Docker environment 128 run: | 129 npm run env:start 130 131 - name: Log running Docker containers 132 run: docker ps -a 133 134 - name: WordPress Docker container debug information 135 run: | 136 docker compose run --rm mysql mysql --version 137 docker compose run --rm php php --version 138 docker compose run --rm php php -m 139 docker compose run --rm php php -i 140 docker compose run --rm php locale -a 141 142 - name: Install WordPress 143 run: npm run env:install 144 145 - name: Run tests as a single site 146 if: ${{ ! matrix.multisite }} 147 run: npm run test:php -- --verbose -c phpunit.xml.dist --coverage-${{ 'html' == matrix.format && 'html' || 'clover' }} wp-code-coverage-single-${{ github.sha }}${{ 'clover' == matrix.format && '.xml' || '' }} 148 149 - name: Ensure version-controlled files are not modified during the tests 150 run: git diff --exit-code 151 152 - name: Upload single site report to Codecov 153 if: ${{ ! matrix.multisite && matrix.format == 'clover' && github.event_name != 'pull_request' }} 154 uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 155 with: 156 token: ${{ secrets.CODECOV_TOKEN }} 157 file: wp-code-coverage-single-${{ github.sha }}${{ 'clover' == matrix.format && '.xml' || '' }} 158 flags: single,php 159 fail_ci_if_error: true 160 161 - name: Upload single site HTML report as artifact 162 if: ${{ ! matrix.multisite && matrix.format == 'html' }} 163 uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 164 with: 165 name: wp-code-coverage-single-${{ github.sha }} 166 path: wp-code-coverage-single-${{ github.sha }} 167 overwrite: true 168 169 - name: Run tests as a multisite install 170 if: ${{ matrix.multisite }} 171 run: npm run test:php -- --verbose -c tests/phpunit/multisite.xml --coverage-${{ 'html' == matrix.format && 'html' || 'clover' }} wp-code-coverage-multisite-${{ github.sha }}${{ 'clover' == matrix.format && '.xml' || '' }} 172 173 - name: Ensure version-controlled files are not modified during the tests 174 run: git diff --exit-code 175 176 - name: Upload multisite report to Codecov 177 if: ${{ matrix.multisite && matrix.format == 'clover' && github.event_name != 'pull_request' }} 178 uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 179 with: 180 token: ${{ secrets.CODECOV_TOKEN }} 181 file: wp-code-coverage-multisite-${{ github.sha }}${{ 'clover' == matrix.format && '.xml' || '' }} 182 flags: multisite,php 183 fail_ci_if_error: true 184 185 - name: Upload multisite HTML report as artifact 186 if: ${{ matrix.multisite && matrix.format == 'html' }} 187 uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 188 with: 189 name: wp-code-coverage-multisite-${{ github.sha }} 190 path: wp-code-coverage-multisite-${{ github.sha }} 191 overwrite: true 58 coverage-report: [ true ] 59 with: 60 php: '8.3' 61 multisite: ${{ matrix.multisite }} 62 coverage-report: ${{ matrix.coverage-report }} 63 secrets: 64 CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 192 65 193 66 slack-notifications:
Note: See TracChangeset
for help on using the changeset viewer.