Make WordPress Core

Changeset 59749


Ignore:
Timestamp:
02/01/2025 08:15:09 PM (5 months ago)
Author:
johnbillion
Message:

Build/Test Tools: Parallelise the performance tests.

This change introduces a job matrix for the "current", "before", and "base" performance tests to replace the current behaviour of running them sequentially in a single job. This speeds up the overall performance testing workflow and also reduces the chance of any given test interfering with another, for example by making a change to data in the database that affects a subsequent test.

Props johnbillion, swissspidy, dmsnell, joemcgill.

See #62221

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

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/performance.yml

    r59725 r59749  
    3434      - '.github/workflows/performance.yml'
    3535      - '.github/workflows/reusable-performance.yml'
     36      - '.github/workflows/reusable-performance-*.yml'
    3637  workflow_dispatch:
    3738
     
    4849
    4950jobs:
     51  determine-matrix:
     52    name: Determine Matrix
     53    runs-on: ubuntu-24.04
     54    if: ${{ ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) && ! contains( github.event.before, '00000000' ) }}
     55    permissions: {}
     56    env:
     57      TARGET_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
     58    outputs:
     59      subjects: ${{ steps.set-subjects.outputs.result }}
     60      target_sha: ${{ env.TARGET_SHA }}
     61    steps:
     62      # The `workflow_dispatch` event is the only one missing the needed SHA to target.
     63      - name: Retrieve previous commit SHA (if necessary)
     64        if: ${{ github.event_name == 'workflow_dispatch' }}
     65        run: echo "TARGET_SHA=$(git rev-parse HEAD^1)" >> "$GITHUB_ENV"
     66
     67      - name: Set subjects
     68        uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
     69        id: set-subjects
     70        with:
     71          script: |
     72            const artifacts = await github.rest.actions.listArtifactsForRepo({
     73              owner: context.repo.owner,
     74              repo: context.repo.repo,
     75              name: 'wordpress-build-' + process.env.TARGET_SHA,
     76            });
     77            const has_previous_build = !! artifacts.data.artifacts[0];
     78
     79            const subjects = [
     80              'current',
     81            ];
     82
     83            if ( context.eventName === 'push' && context.ref === 'refs/heads/trunk' ) {
     84              subjects.push( 'base' );
     85            } else if ( has_previous_build ) {
     86              subjects.push( 'before' );
     87            }
     88
     89            return subjects;
     90
    5091  # Runs the performance test suite.
    5192  performance:
    52     name: ${{ matrix.multisite && 'Multisite' || 'Single site' }}
    53     uses: ./.github/workflows/reusable-performance.yml
     93    name: ${{ matrix.multisite && 'Multisite' || 'Single Site' }} ${{ matrix.memcached && 'Memcached' || 'Default' }}
     94    uses: ./.github/workflows/reusable-performance-test-v2.yml
     95    needs: [ determine-matrix ]
    5496    permissions:
    5597      contents: read
    56     if: ${{ ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) }}
    5798    strategy:
    5899      fail-fast: false
     
    60101        memcached: [ true, false ]
    61102        multisite: [ true, false ]
     103        subject: ${{ fromJson( needs.determine-matrix.outputs.subjects ) }}
    62104    with:
    63105      memcached: ${{ matrix.memcached }}
    64106      multisite: ${{ matrix.multisite }}
     107      subject: ${{ matrix.subject }}
     108      TARGET_SHA: ${{ needs.determine-matrix.outputs.target_sha }}
     109
     110  compare:
     111    name: ${{ matrix.label }}
     112    uses: ./.github/workflows/reusable-performance-report-v2.yml
     113    needs: [ determine-matrix, performance ]
     114    permissions:
     115      contents: read
     116    strategy:
     117      fail-fast: false
     118      matrix:
     119        memcached: [ true, false ]
     120        multisite: [ true, false ]
     121        label: [ Compare ]
     122    with:
     123      memcached: ${{ matrix.memcached }}
     124      multisite: ${{ matrix.multisite }}
     125      BASE_TAG: ${{ needs.performance.outputs.BASE_TAG }}
     126      publish: ${{ contains( fromJson( needs.determine-matrix.outputs.subjects ), 'base' ) && ! matrix.memcached && ! matrix.multisite }}
    65127    secrets:
    66128      CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}
Note: See TracChangeset for help on using the changeset viewer.