Make WordPress Core

Changeset 62409 for trunk


Ignore:
Timestamp:
05/22/2026 08:52:59 AM (4 months ago)
Author:
johnbillion
Message:

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

Location:
trunk/.github/workflows
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/reusable-phpunit-tests-v3.yml

    r62404 r62409  
    8383env:
    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 }}
     
    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.
     
    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 }}
     
    244268          flags: ${{ inputs.multisite && 'multisite' || 'single' }},php
    245269          fail_ci_if_error: true
    246 
    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
    254270
    255271      - name: Ensure version-controlled files are not modified or deleted
  • trunk/.github/workflows/test-coverage.yml

    r62253 r62409  
    3939
    4040env:
    41   LOCAL_PHP_XDEBUG: true
    42   LOCAL_PHP_XDEBUG_MODE: 'coverage'
    4341  LOCAL_PHP_MEMCACHED: false
    4442  PUPPETEER_SKIP_DOWNLOAD: true
Note: See TracChangeset for help on using the changeset viewer.