|
82 | 82 |
|
83 | 83 | env: |
84 | 84 | LOCAL_PHP: ${{ inputs.php }}-fpm |
85 | | - LOCAL_PHP_XDEBUG: ${{ inputs.coverage-report || false }} |
86 | | - LOCAL_PHP_XDEBUG_MODE: ${{ inputs.coverage-report && 'coverage' || 'develop,debug' }} |
| 85 | + LOCAL_PHP_XDEBUG: false |
| 86 | + LOCAL_PHP_XDEBUG_MODE: 'develop,debug' |
87 | 87 | LOCAL_DB_TYPE: ${{ inputs.db-type }} |
88 | 88 | LOCAL_DB_VERSION: ${{ inputs.db-version }} |
89 | 89 | LOCAL_PHP_MEMCACHED: ${{ inputs.memcached }} |
@@ -113,7 +113,6 @@ jobs: |
113 | 113 | # - Install WordPress within the Docker container. |
114 | 114 | # - Run the PHPUnit tests. |
115 | 115 | # - Upload the code coverage report to Codecov.io. |
116 | | - # - Upload the HTML code coverage report as an artifact. |
117 | 116 | # - Ensures version-controlled files are not modified or deleted. |
118 | 117 | # - Checks out the WordPress Test reporter repository. |
119 | 118 | # - Submit the test results to the WordPress.org host test results. |
@@ -201,15 +200,40 @@ jobs: |
201 | 200 | - name: Install WordPress |
202 | 201 | run: npm run env:install |
203 | 202 |
|
| 203 | + # Installs PCOV as the code coverage driver for the PHPUnit run below. |
| 204 | + # |
| 205 | + # The INI directives tune PCOV for WordPress's codebase: |
| 206 | + # - `pcov.enabled` keeps the Zend hooks active (this is the default, but |
| 207 | + # stated explicitly for clarity). |
| 208 | + # - `pcov.directory` restricts instrumentation to `src/`, so PCOV does not |
| 209 | + # record hits for `vendor/`, `tests/`, or WordPress test fixtures that |
| 210 | + # PHPUnit would discard at report time anyway. |
| 211 | + # - `pcov.initial.files` pre-sizes the internal file tracking array for |
| 212 | + # the thousands of files under `src/`, avoiding reallocation churn |
| 213 | + # during test warmup. The default of 64 is far too low here. |
| 214 | + - name: Install PCOV coverage driver |
| 215 | + if: ${{ inputs.coverage-report }} |
| 216 | + run: | |
| 217 | + docker compose exec -T -u 0 php sh -c ' |
| 218 | + pecl install --force pcov-1.0.12 && |
| 219 | + docker-php-ext-enable pcov && |
| 220 | + { |
| 221 | + echo "pcov.enabled=1" |
| 222 | + echo "pcov.directory=/var/www/src" |
| 223 | + echo "pcov.initial.files=10000" |
| 224 | + } >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini && |
| 225 | + php -m | grep -i pcov |
| 226 | + ' |
| 227 | +
|
204 | 228 | - name: Run PHPUnit tests${{ inputs.phpunit-test-groups && format( ' ({0} groups)', inputs.phpunit-test-groups ) || '' }}${{ inputs.coverage-report && ' with coverage report' || '' }} |
205 | 229 | continue-on-error: ${{ inputs.allow-errors }} |
206 | 230 | run: | |
207 | | - node ./tools/local-env/scripts/docker.js run \ |
| 231 | + node ./tools/local-env/scripts/docker.js ${{ inputs.coverage-report && 'exec' || 'run' }} \ |
208 | 232 | php ./vendor/bin/phpunit \ |
209 | 233 | --verbose \ |
210 | 234 | -c "${PHPUNIT_CONFIG}" \ |
211 | 235 | ${{ inputs.phpunit-test-groups && '--group "${TEST_GROUPS}"' || '' }} \ |
212 | | - ${{ inputs.coverage-report && '--coverage-clover "wp-code-coverage-${MULTISITE_FLAG}-${GITHUB_SHA}.xml" --coverage-html "wp-code-coverage-${MULTISITE_FLAG}-${GITHUB_SHA}"' || '' }} |
| 236 | + ${{ inputs.coverage-report && '--coverage-clover "wp-code-coverage-${MULTISITE_FLAG}-${GITHUB_SHA}.xml"' || '' }} |
213 | 237 | env: |
214 | 238 | TEST_GROUPS: ${{ inputs.phpunit-test-groups }} |
215 | 239 | MULTISITE_FLAG: ${{ inputs.multisite && 'multisite' || 'single' }} |
@@ -244,14 +268,6 @@ jobs: |
244 | 268 | flags: ${{ inputs.multisite && 'multisite' || 'single' }},php |
245 | 269 | fail_ci_if_error: true |
246 | 270 |
|
247 | | - - name: Upload HTML coverage report as artifact |
248 | | - if: ${{ inputs.coverage-report }} |
249 | | - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
250 | | - with: |
251 | | - name: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }} |
252 | | - path: wp-code-coverage${{ inputs.multisite && '-multisite' || '-single' }}-${{ github.sha }} |
253 | | - overwrite: true |
254 | | - |
255 | 271 | - name: Ensure version-controlled files are not modified or deleted |
256 | 272 | run: git diff --exit-code |
257 | 273 |
|
|
0 commit comments