Make WordPress Core

Changeset 63410


Ignore:
Timestamp:
08/31/2026 05:03:14 PM (2 months ago)
Author:
lancewillett
Message:

Build/Test Tools: Publish PHPUnit timing metrics to CodeVitals.

The canonical PHPUnit job now publishes six aggregate timing metrics to the
public CodeVitals dashboard after every push to trunk: total suite time, the
p95, p99 and maximum per-test times, and counts of tests over 500ms and over
1s. The publisher reads the JUnit report the suite already produces, streams
it, and sends only aggregates. No test names or per-test records leave CI.

The metric definitions are verified on submission, so a missing definition
fails the step rather than silently dropping data.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/13083

Props desrosj, adrianmoldovanwp, johnbillion, youknowriad.
See #65887.

Location:
trunk
Files:
3 added
2 edited

Legend:

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

    r63396 r63410  
    8282      contents: read
    8383    secrets:
     84      CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}
    8485      CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
    8586      WPT_REPORT_API_KEY: ${{ secrets.WPT_REPORT_API_KEY }}
  • trunk/.github/workflows/reusable-phpunit-tests-v3.yml

    r63163 r63410  
    8484        default: ''
    8585    secrets:
     86      CODEVITALS_PROJECT_TOKEN:
     87        description: 'The authorization token for publishing results to CodeVitals.'
     88        required: false
    8689      CODECOV_TOKEN:
    8790        description: 'The Codecov token required for uploading reports.'
    … …  
    124127  # - Install WordPress within the Docker container.
    125128  # - Run the PHPUnit tests.
     129  # - Publish PHPUnit timing metrics to CodeVitals.
    126130  # - Upload the code coverage report to Codecov.io.
    127131  # - Ensures version-controlled files are not modified or deleted.
    … …  
    270274          MULTISITE_FLAG: ${{ inputs.multisite && 'multisite' || 'single' }}
    271275
     276      - name: Publish PHPUnit timing metrics
     277        continue-on-error: true
     278        if: |
     279          github.event_name == 'push' &&
     280          github.ref == 'refs/heads/trunk' &&
     281          inputs.php == '8.5' &&
     282          inputs.report
     283        env:
     284          CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}
     285        shell: bash
     286        run: |
     287          if [ -z "$CODEVITALS_PROJECT_TOKEN" ]; then
     288            echo "PHPUnit timing metrics could not be published. 'CODEVITALS_PROJECT_TOKEN' is not set"
     289            exit 1
     290          fi
     291          COMMITTED_AT="$(git show -s "$GITHUB_SHA" --format='%cI')"
     292          RESPONSE="$(
     293            php tests/phpunit/prepare-timing-results.php \
     294              tests/phpunit/build/logs/junit.xml \
     295              trunk \
     296              "$GITHUB_SHA" \
     297              "$COMMITTED_AT" \
     298              | curl --fail-with-body --silent --show-error \
     299                --request POST \
     300                --header 'Content-Type: application/json' \
     301                --data-binary @- \
     302                "https://codevitals.run/api/log?token=${CODEVITALS_PROJECT_TOKEN}"
     303          )"
     304          if ! php -r "\$d = json_decode(file_get_contents('php://stdin'), true); exit(is_array(\$d) && (\$d['status'] ?? null) === 'ok' && (int) (\$d['count'] ?? 0) === 6 ? 0 : 1);" <<< "$RESPONSE"; then
     305            echo 'CodeVitals did not accept all six PHPUnit timing metrics.'
     306            exit 1
     307          fi
     308          echo 'Published six PHPUnit timing metrics to CodeVitals.'
     309
    272310      - name: Run AJAX tests
    273311        if: ${{ ! inputs.phpunit-test-groups && ! inputs.coverage-report }}
Note: See TracChangeset for help on using the changeset viewer.