Skip to content

Commit bc730ed

Browse files
committed
Build/Test Tools: Switch to PCOV for the coverage report runner.
PCOV is a dedicated coverage reporting tool that performs significantly faster than Xdebug in coverage mode. This reduces the time that tests with coverage enabled take to run by around 50%. This also removes the HTML report generation which was producing unusable artifacts in excess of 7 GB in size. Props johnbillion, desrosj, swissspidy See #64893 git-svn-id: https://develop.svn.wordpress.org/trunk@62409 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 9560811 commit bc730ed

2 files changed

Lines changed: 29 additions & 15 deletions

File tree

.github/workflows/reusable-phpunit-tests-v3.yml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ on:
8282

8383
env:
8484
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'
8787
LOCAL_DB_TYPE: ${{ inputs.db-type }}
8888
LOCAL_DB_VERSION: ${{ inputs.db-version }}
8989
LOCAL_PHP_MEMCACHED: ${{ inputs.memcached }}
@@ -113,7 +113,6 @@ jobs:
113113
# - Install WordPress within the Docker container.
114114
# - Run the PHPUnit tests.
115115
# - Upload the code coverage report to Codecov.io.
116-
# - Upload the HTML code coverage report as an artifact.
117116
# - Ensures version-controlled files are not modified or deleted.
118117
# - Checks out the WordPress Test reporter repository.
119118
# - Submit the test results to the WordPress.org host test results.
@@ -201,15 +200,40 @@ jobs:
201200
- name: Install WordPress
202201
run: npm run env:install
203202

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+
204228
- name: Run PHPUnit tests${{ inputs.phpunit-test-groups && format( ' ({0} groups)', inputs.phpunit-test-groups ) || '' }}${{ inputs.coverage-report && ' with coverage report' || '' }}
205229
continue-on-error: ${{ inputs.allow-errors }}
206230
run: |
207-
node ./tools/local-env/scripts/docker.js run \
231+
node ./tools/local-env/scripts/docker.js ${{ inputs.coverage-report && 'exec' || 'run' }} \
208232
php ./vendor/bin/phpunit \
209233
--verbose \
210234
-c "${PHPUNIT_CONFIG}" \
211235
${{ 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"' || '' }}
213237
env:
214238
TEST_GROUPS: ${{ inputs.phpunit-test-groups }}
215239
MULTISITE_FLAG: ${{ inputs.multisite && 'multisite' || 'single' }}
@@ -244,14 +268,6 @@ jobs:
244268
flags: ${{ inputs.multisite && 'multisite' || 'single' }},php
245269
fail_ci_if_error: true
246270

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-
255271
- name: Ensure version-controlled files are not modified or deleted
256272
run: git diff --exit-code
257273

.github/workflows/test-coverage.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ concurrency:
3838
permissions: {}
3939

4040
env:
41-
LOCAL_PHP_XDEBUG: true
42-
LOCAL_PHP_XDEBUG_MODE: 'coverage'
4341
LOCAL_PHP_MEMCACHED: false
4442
PUPPETEER_SKIP_DOWNLOAD: true
4543

0 commit comments

Comments
 (0)