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

Slightly overhaul performance tests #5679

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
5cd1512
Run performance tests in a matrix
swissspidy Nov 17, 2023
b117403
Add missing quote
swissspidy Nov 17, 2023
fef9e38
install drop-in
swissspidy Nov 17, 2023
c5f1180
Add missing arg
swissspidy Nov 17, 2023
5464464
Move up env var
swissspidy Nov 17, 2023
538e605
Fix function name
swissspidy Nov 17, 2023
109e7ab
Fix compare script logic
swissspidy Nov 17, 2023
d18523e
Update name
swissspidy Nov 17, 2023
1fb6833
Merge branch 'trunk' into fix/59900-perf-matrix
swissspidy Nov 17, 2023
b762b79
Add missing import
swissspidy Nov 17, 2023
782b4c6
Add back the summary
swissspidy Nov 17, 2023
95a5e07
Merge branch 'trunk' into fix/59900-perf-matrix
swissspidy Nov 17, 2023
667bfeb
Skip base files
swissspidy Nov 17, 2023
dbdb469
Merge branch 'trunk' into fix/59900-perf-matrix
swissspidy Nov 17, 2023
3caf152
Merge branch 'trunk' into fix/59900-perf-matrix
swissspidy Nov 20, 2023
45f1a65
Merge branch 'trunk' into fix/59900-perf-matrix
swissspidy Feb 27, 2024
517c251
Merge branch 'trunk' into fix/59900-perf-matrix
swissspidy Apr 25, 2024
1dc70bd
Move back some logic to JS
swissspidy Apr 26, 2024
569e2db
Update scripts
swissspidy Apr 26, 2024
8095e99
Fix import
swissspidy Apr 27, 2024
b80659c
Upload artifacts for debugging
swissspidy Apr 27, 2024
2b328d8
Fix results structure
swissspidy Apr 27, 2024
b1e7826
Fix artifact name
swissspidy Apr 27, 2024
0bcac09
Use correct var
swissspidy Apr 27, 2024
2e8fc1c
Hardening
swissspidy Apr 27, 2024
1bcace7
Get previous build from artifact
swissspidy Apr 28, 2024
b4585b8
Pass gh token
swissspidy Apr 28, 2024
a86db9f
Double quotes, add missing comma
swissspidy Apr 28, 2024
41b06ec
Merge branch 'trunk' into fix/59900-perf-matrix
swissspidy Apr 28, 2024
fb4cfeb
Fix unzip step
swissspidy Apr 28, 2024
3021835
Fix comparison
swissspidy Apr 28, 2024
1cd06a8
Unzip with override instead
swissspidy Apr 28, 2024
cde781e
Track number of db queries
swissspidy Apr 28, 2024
70eba93
Track obj cache usage
swissspidy Apr 28, 2024
44aff66
Fix query count
swissspidy Apr 28, 2024
72456a5
Improve formatting
swissspidy Apr 28, 2024
a49f3cd
NaN check
swissspidy Apr 28, 2024
1b4ffab
Only run baseline on trunk
swissspidy Apr 28, 2024
b224b22
Further tests
swissspidy Apr 28, 2024
645c598
Formatting
swissspidy Apr 28, 2024
3522a01
Explain number of reps
swissspidy Apr 29, 2024
b00715c
Formatting
swissspidy Apr 29, 2024
2e7f4f3
Acc results
swissspidy Apr 29, 2024
81cac1a
More cleanup
swissspidy Apr 29, 2024
0602048
Merge branch 'trunk' into fix/59900-perf-matrix
swissspidy Apr 29, 2024
9a23f40
Server-Timing in admin
swissspidy Apr 29, 2024
6c48075
Fix log script
swissspidy Apr 29, 2024
bc75856
Undo unrelated change
swissspidy Apr 29, 2024
a83d9cf
Don't preserve output
swissspidy Apr 29, 2024
7d0a52a
Update docs
swissspidy Apr 29, 2024
9f06a51
Merge branch 'trunk' into fix/59900-perf-matrix
swissspidy Apr 29, 2024
4501774
Merge branch 'trunk' into fix/59900-perf-matrix
swissspidy May 1, 2024
97dcc38
Flush after upgrade
swissspidy May 1, 2024
ec092b6
Don't compare if there is no build
swissspidy May 1, 2024
ffb9387
Install only Chromium
swissspidy May 1, 2024
8feadc8
Add some comments
swissspidy May 1, 2024
3d3cb50
Use JS to get the artifact
swissspidy May 1, 2024
01ef3d4
Remove `if`
swissspidy May 1, 2024
814e2d6
Use `process.env`
swissspidy May 1, 2024
8e8df39
Merge branch 'trunk' into fix/59900-perf-matrix
swissspidy May 1, 2024
54d0414
Merge branch 'trunk' into fix/59900-perf-matrix
swissspidy May 2, 2024
5c91fe8
Use correct operator
swissspidy May 2, 2024
15658cf
Merge branch 'trunk' into fix/59900-perf-matrix
swissspidy May 2, 2024
9a09bc6
For now, don't log results of memcached tests
swissspidy May 2, 2024
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
144 changes: 85 additions & 59 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,45 @@ jobs:
# - Install WordPress.
# - Install WordPress Importer plugin.
# - Import mock data.
# - Deactivate WordPress Importer plugin.
# - Update permalink structure.
# - Install additional languages.
# - Disable external HTTP requests.
# - Disable cron.
# - List defined constants.
# - Install MU plugin.
# - Run performance tests (current commit).
# - Print performance tests results.
# - Check out target commit (target branch or previous commit).
# - Switch Node.js versions if necessary.
# - Install npm dependencies.
# - Build WordPress.
# - Get previous build (target branch or previous commit).
# - Download artifact.
# - Unzip the build.
# - Flush cache.
# - Run any database upgrades.
# - Delete expired transients.
# - Run performance tests (previous/target commit).
# - Print target performance tests results.
# - Reset to original commit.
# - Switch Node.js versions if necessary.
# - Install npm dependencies.
# - Set the environment to the baseline version.
# - Flush cache.
# - Run any database upgrades.
# - Delete expired transients.
# - Run baseline performance tests.
# - Print baseline performance tests results.
# - Compare results with base.
# - Archive artifacts.
# - Compare results.
# - Add workflow summary.
# - Set the base sha.
# - Set commit details.
# - Publish performance results.
# - Ensure version-controlled files are not modified or deleted.
# - Dispatch workflow run.
performance:
name: Run performance tests
name: Run performance tests ${{ matrix.memcached && '(with memcached)' || '' }}
runs-on: ubuntu-latest
permissions:
contents: read
if: ${{ ( github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' ) && ! contains( github.event.before, '00000000' ) }}

strategy:
fail-fast: false
matrix:
memcached: [ true, false ]
env:
LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }}
steps:
- name: Configure environment variables
run: |
Expand Down Expand Up @@ -133,8 +140,11 @@ jobs:
run: npm run build

- name: Start Docker environment
run: |
npm run env:start
run: npm run env:start

- name: Install object cache drop-in
if: ${{ matrix.memcached }}
run: cp src/wp-content/object-cache.php build/wp-content/object-cache.php

- name: Log running Docker containers
run: docker ps -a
Expand All @@ -160,16 +170,27 @@ jobs:
npm run env:cli -- import themeunittestdata.wordpress.xml --authors=create --path=/var/www/${{ env.LOCAL_DIR }}
rm themeunittestdata.wordpress.xml

- name: Deactivate WordPress Importer plugin
run: npm run env:cli -- plugin deactivate wordpress-importer --path=/var/www/${{ env.LOCAL_DIR }}

- name: Update permalink structure
run: |
npm run env:cli -- rewrite structure '/%year%/%monthnum%/%postname%/' --path=/var/www/${{ env.LOCAL_DIR }}
run: npm run env:cli -- rewrite structure '/%year%/%monthnum%/%postname%/' --path=/var/www/${{ env.LOCAL_DIR }}

- name: Install additional languages
run: |
npm run env:cli -- language core install de_DE --path=/var/www/${{ env.LOCAL_DIR }}
npm run env:cli -- language plugin install de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}
npm run env:cli -- language theme install de_DE --all --path=/var/www/${{ env.LOCAL_DIR }}
swissspidy marked this conversation as resolved.
Show resolved Hide resolved

- name: Disable external HTTP requests
run: npm run env:cli -- config set WP_HTTP_BLOCK_EXTERNAL true --raw --type=constant --path=/var/www/${{ env.LOCAL_DIR }}

- name: Disable cron
swissspidy marked this conversation as resolved.
Show resolved Hide resolved
run: npm run env:cli -- config set DISABLE_WP_CRON true --raw --type=constant --path=/var/www/${{ env.LOCAL_DIR }}

- name: List defined constants
run: npm run env:cli -- config list --path=/var/www/${{ env.LOCAL_DIR }}

- name: Install MU plugin
run: |
mkdir ./${{ env.LOCAL_DIR }}/wp-content/mu-plugins
Expand All @@ -178,74 +199,79 @@ jobs:
- name: Run performance tests (current commit)
run: npm run test:performance
swissspidy marked this conversation as resolved.
Show resolved Hide resolved

- name: Print performance tests results
run: node ./tests/performance/results.js

- name: Check out target commit (target branch or previous commit)
- name: Get previous build (target branch or previous commit)
id: get-previous-build
run: |
if [[ -z "$TARGET_REF" ]]; then
git fetch -n origin $TARGET_SHA
else
git fetch -n origin $TARGET_REF
fi
git reset --hard $TARGET_SHA
echo "artifact_id=$(gh api repos/WordPress/wordpress-develop/actions/artifacts?name="wordpress-build-$TARGET_SHA" --jq ".artifacts[] .id")" >> $GITHUB_OUTPUT
swissspidy marked this conversation as resolved.
Show resolved Hide resolved
swissspidy marked this conversation as resolved.
Show resolved Hide resolved
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
- name: Download artifact
swissspidy marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
node-version-file: '.nvmrc'
cache: npm
script: |
const download = await github.rest.actions.downloadArtifact( {
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: ${{ steps.get-previous-build.outputs.artifact_id || null }},
archive_format: 'zip',
} );

- name: Install npm dependencies
run: npm ci
const fs = require( 'fs' );
fs.writeFileSync( '${{ github.workspace }}/before.zip', Buffer.from( download.data ) )

- name: Build WordPress
run: npm run build
- name: Unzip the build
run: |
unzip ${{ github.workspace }}/before.zip
unzip -o ${{ github.workspace }}/wordpress.zip

- name: Flush cache
swissspidy marked this conversation as resolved.
Show resolved Hide resolved
run: npm run env:cli -- cache flush --path=/var/www/${{ env.LOCAL_DIR }}

- name: Run any database upgrades
run: npm run env:cli -- core update-db --path=/var/www/${{ env.LOCAL_DIR }}

- name: Run target performance tests (base/previous commit)
env:
TEST_RESULTS_PREFIX: before
run: npm run test:performance
- name: Delete expired transients
run: npm run env:cli -- transient delete --expired --path=/var/www/${{ env.LOCAL_DIR }}

- name: Print target performance tests results
- name: Run target performance tests (previous/target commit)
env:
TEST_RESULTS_PREFIX: before
run: node ./tests/performance/results.js

- name: Reset to original commit
run: git reset --hard $GITHUB_SHA

- name: Set up Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version-file: '.nvmrc'
cache: npm

- name: Install npm dependencies
run: npm ci
run: npm run test:performance

- name: Set the environment to the baseline version
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
run: |
npm run env:cli -- core update --version=${{ env.BASE_TAG }} --force --path=/var/www/${{ env.LOCAL_DIR }}
npm run env:cli -- core version --path=/var/www/${{ env.LOCAL_DIR }}

- name: Flush cache
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
run: npm run env:cli -- cache flush --path=/var/www/${{ env.LOCAL_DIR }}

- name: Run any database upgrades
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
run: npm run env:cli -- core update-db --path=/var/www/${{ env.LOCAL_DIR }}

- name: Delete expired transients
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
run: npm run env:cli -- transient delete --expired --path=/var/www/${{ env.LOCAL_DIR }}

- name: Run baseline performance tests
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/trunk' }}
env:
TEST_RESULTS_PREFIX: base
run: npm run test:performance

- name: Print baseline performance tests results
env:
TEST_RESULTS_PREFIX: base
run: node ./tests/performance/results.js
- name: Archive artifacts
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: always()
with:
name: performance-artifacts${{ matrix.memcached && '-memcached' || '' }}-${{ github.run_id }}
path: artifacts
if-no-files-found: ignore

- name: Compare results with base
- name: Compare results
run: node ./tests/performance/compare-results.js ${{ runner.temp }}/summary.md

- name: Add workflow summary
Expand Down
Loading
Loading