Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

62221 Parallelise the performance tests #8190

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2bdcaa9
Split the performance tests into three jobs so they run in parallel.
johnbillion Jan 25, 2025
e11aae7
Prevent unnecessary tests running in this branch.
johnbillion Jan 25, 2025
8b62844
Naming.
johnbillion Jan 25, 2025
a12a65f
This does need to use a script because it fetches an artifact from an…
johnbillion Jan 25, 2025
5442eff
Start the environment in time.
johnbillion Jan 25, 2025
06072c5
We always need a build so all the themes are available.
johnbillion Jan 25, 2025
3ac9b9a
Naming.
johnbillion Jan 25, 2025
8ee02d7
Compare the results.
johnbillion Jan 25, 2025
f8f53e7
Naming.
johnbillion Jan 25, 2025
6506842
Todos.
johnbillion Jan 25, 2025
5979877
Need a checkout here.
johnbillion Jan 25, 2025
50e8501
Reinstate the logging.
johnbillion Jan 25, 2025
9090810
Reuse the tag name via workflow output.
johnbillion Jan 25, 2025
bad5906
Reinstate the original version number handling.
johnbillion Jan 25, 2025
bd82165
Skip the token check for now.
johnbillion Jan 25, 2025
3739509
Correct this prefix handling.
johnbillion Jan 27, 2025
8430bc3
Split the comparison and publishing into a reusable workflow.
johnbillion Jan 28, 2025
3398fa1
Prepare for running the base test only on pushes to trunk.
johnbillion Jan 28, 2025
a977c27
Hack the label.
johnbillion Jan 28, 2025
9cfff3d
A v2 workflow is needed so older branches continue to run the perform…
johnbillion Jan 28, 2025
d1fad83
Keep shellcheck happy.
johnbillion Jan 28, 2025
4a55471
Merge branch 'trunk' into 62221-parallel-performance-tests
johnbillion Jan 28, 2025
3d53664
Update the runners.
johnbillion Jan 28, 2025
25caafc
Merge branch 'trunk' into 62221-parallel-performance-tests
johnbillion Jan 30, 2025
f575835
Update the paths filtering.
johnbillion Jan 30, 2025
ab180b8
Consolidate the logic to determine whether to publish the report.
johnbillion Jan 31, 2025
7146739
Tidying up.
johnbillion Jan 31, 2025
4ec1e53
Consolidate the logic for the subjects and target SHA.
johnbillion Jan 31, 2025
f0a6cb5
Boop.
johnbillion Jan 31, 2025
d39178a
Combine these steps into one.
johnbillion Jan 31, 2025
fba63a7
Finalise the logic for publishing the results.
johnbillion Jan 31, 2025
df15f9d
Merge branch 'trunk' into 62221-parallel-performance-tests
johnbillion Feb 1, 2025
d925c05
Label tweaks.
johnbillion Feb 1, 2025
0e97a1a
Reintroduce the base test for now.
johnbillion Feb 1, 2025
a872e9c
Ensure the correct version of Node is used during reporting.
johnbillion Feb 1, 2025
74f2ee1
Docs.
johnbillion Feb 1, 2025
f57ce00
Is this causing a parsing problem?
johnbillion Feb 1, 2025
8892e8b
You what.
johnbillion Feb 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 67 additions & 3 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ on:
# Confirm any changes to relevant workflow files.
- '.github/workflows/performance.yml'
- '.github/workflows/reusable-performance.yml'
- '.github/workflows/reusable-performance-*.yml'
workflow_dispatch:

# Cancels all previous workflow runs for pull requests that have not completed.
Expand All @@ -47,21 +48,84 @@ concurrency:
permissions: {}

jobs:
determine-matrix:
name: Determine Matrix
runs-on: ubuntu-24.04
if: ${{ ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) && ! contains( github.event.before, '00000000' ) }}
permissions: {}
env:
TARGET_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
outputs:
subjects: ${{ steps.set-subjects.outputs.result }}
target_sha: ${{ env.TARGET_SHA }}
steps:
# The `workflow_dispatch` event is the only one missing the needed SHA to target.
- name: Retrieve previous commit SHA (if necessary)
if: ${{ github.event_name == 'workflow_dispatch' }}
run: echo "TARGET_SHA=$(git rev-parse HEAD^1)" >> "$GITHUB_ENV"

- name: Set subjects
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: set-subjects
with:
script: |
const artifacts = await github.rest.actions.listArtifactsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'wordpress-build-' + process.env.TARGET_SHA,
});
const has_previous_build = !! artifacts.data.artifacts[0];

const subjects = [
'current',
// Only included while this PR is being worked on:
'base',
];

if ( context.eventName === 'push' && context.ref === 'refs/heads/trunk' ) {
subjects.push( 'base' );
} else if ( has_previous_build ) {
subjects.push( 'before' );
}

return subjects;

# Runs the performance test suite.
performance:
name: ${{ matrix.multisite && 'Multisite' || 'Single site' }}
uses: ./.github/workflows/reusable-performance.yml
name: ${{ matrix.multisite && 'Multisite' || 'Single Site' }} ${{ matrix.memcached && 'Memcached' || 'Default' }}
uses: ./.github/workflows/reusable-performance-test-v2.yml
needs: [ determine-matrix ]
permissions:
contents: read
strategy:
fail-fast: false
matrix:
memcached: [ true, false ]
multisite: [ true, false ]
subject: ${{ fromJson( needs.determine-matrix.outputs.subjects ) }}
with:
memcached: ${{ matrix.memcached }}
multisite: ${{ matrix.multisite }}
subject: ${{ matrix.subject }}
TARGET_SHA: ${{ needs.determine-matrix.outputs.target_sha }}

compare:
name: ${{ matrix.label }}
uses: ./.github/workflows/reusable-performance-report-v2.yml
needs: [ determine-matrix, performance ]
permissions:
contents: read
if: ${{ ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) }}
strategy:
fail-fast: false
matrix:
memcached: [ true, false ]
multisite: [ true, false ]
label: [ Compare ]
with:
memcached: ${{ matrix.memcached }}
multisite: ${{ matrix.multisite }}
BASE_TAG: ${{ needs.performance.outputs.BASE_TAG }}
publish: ${{ contains( fromJson( needs.determine-matrix.outputs.subjects ), 'base' ) && ! matrix.memcached && ! matrix.multisite }}
secrets:
CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}

Expand Down
116 changes: 116 additions & 0 deletions .github/workflows/reusable-performance-report-v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
##
# A reusable workflow that compares and publishes the performance tests.
##
name: Compare and publish performance Tests

on:
workflow_call:
inputs:
BASE_TAG:
description: 'The version being used for baseline measurements.'
required: true
type: string
memcached:
description: 'Whether to enable memcached.'
required: false
type: boolean
default: false
multisite:
description: 'Whether to use Multisite.'
required: false
type: boolean
default: false
publish:
description: 'Whether to publish the results to Code Vitals.'
required: false
type: boolean
default: false
secrets:
CODEVITALS_PROJECT_TOKEN:
description: 'The authorization token for https://www.codevitals.run/project/wordpress.'
required: false

env:
BASE_TAG: ${{ inputs.BASE_TAG }}

# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}

jobs:
# Performs the following steps:
# - Checkout repository.
# - Set up Node.js.
# - Download the relevant performance test artifacts.
# - List the downloaded files for debugging.
# - Compare results.
# - Add workflow summary.
# - Determine the sha of the baseline tag if necessary.
# - Publish performance results if necessary.
compare:
name: ${{ inputs.multisite && 'Multisite' || 'Single Site' }} ${{ inputs.memcached && 'Memcached' || 'Default' }} ${{ inputs.publish && '(Publishes)' || '' }}
runs-on: ubuntu-24.04
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
fetch-depth: ${{ github.event_name == 'workflow_dispatch' && '2' || '1' }}
persist-credentials: false

- name: Set up Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version-file: '.nvmrc'
cache: npm

- name: Download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
pattern: performance-${{ inputs.multisite && 'multisite' || 'single' }}-${{ inputs.memcached && 'memcached' || 'default' }}-*
path: artifacts
merge-multiple: true

- name: List files
run: tree artifacts

- name: Compare results
run: node ./tests/performance/compare-results.js "${RUNNER_TEMP}/summary.md"

- name: Add workflow summary
run: cat "${RUNNER_TEMP}/summary.md" >> "$GITHUB_STEP_SUMMARY"

- name: Set the base sha
# Only needed when publishing results.
if: ${{ inputs.publish }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: base-sha
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const baseRef = await github.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/' + process.env.BASE_TAG,
});
return baseRef.data.object.sha;

- name: Publish performance results
if: ${{ inputs.publish }}
env:
BASE_SHA: ${{ steps.base-sha.outputs.result }}
# CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}
# HOST_NAME: www.codevitals.run
CODEVITALS_PROJECT_TOKEN: test
HOST_NAME: yellow-ice-88.webhook.cool # View captured data at https://webhook.cool/at/yellow-ice-88/
run: |
if [ -z "$CODEVITALS_PROJECT_TOKEN" ]; then
echo "Performance results could not be published. 'CODEVITALS_PROJECT_TOKEN' is not set"
exit 1
fi
COMMITTED_AT="$(git show -s "$GITHUB_SHA" --format='%cI')"
node ./tests/performance/log-results.js "$CODEVITALS_PROJECT_TOKEN" trunk "$GITHUB_SHA" "$BASE_SHA" "$COMMITTED_AT" "$HOST_NAME"
Loading