Build/Test Tools: Compare results in performance measurement workflow.

This extends the performance test workflow added in [55459] to also run tests against the target branch (if running on a pull request) or the previous commit (if running on trunk).

Those results are then compared with the ones from the current commit, and the difference is displayed as a GitHub Actions workflow summary for convenience.

Props mukesh27, flixos90, desrosj, joemcgill, swissspidy.
Fixes #58358, #58359.
See #56150.

git-svn-id: https://develop.svn.wordpress.org/trunk@56506 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler
2023-09-01 17:24:56 +00:00
parent 36fe58a8c6
commit b447190e4c
2 changed files with 209 additions and 4 deletions

View File

@@ -44,6 +44,8 @@ env:
# changed if we want to normalize results against a different baseline.
BASE_TAG: '6.1.1'
LOCAL_DIR: build
TARGET_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || '' }}
TARGET_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
jobs:
# Runs the performance test suite.
@@ -65,9 +67,17 @@ jobs:
# - Install MU plugin.
# - Run performance tests (current commit).
# - Print performance tests results.
# - Check out target commit (target branch or previous commit).
# - Install npm dependencies.
# - Build WordPress.
# - Run performance tests (previous/target commit).
# - Print target performance tests results.
# - Reset to original commit.
# - Set the environment to the baseline version.
# - Run baseline performance tests.
# - Print base line performance tests results.
# - Print baseline performance tests results.
# - Compare results with base.
# - Add workflow summary.
# - Set the base sha.
# - Set commit details.
# - Publish performance results.
@@ -152,7 +162,31 @@ jobs:
run: npm run test:performance
- name: Print performance tests results
run: "node ./tests/performance/results.js"
run: node ./tests/performance/results.js
- name: Check out target commit (target branch or previous commit)
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
- name: Install npm dependencies
run: npm ci
- name: Build WordPress
run: npm run build
- name: Run target performance tests (base/previous commit)
run: npm run test:performance -- --prefix=before
- name: Print target performance tests results
run: node ./tests/performance/results.js --prefix=before
- name: Reset to original commit
run: git reset --hard $GITHUB_SHA
- name: Set the environment to the baseline version
run: |
@@ -162,8 +196,14 @@ jobs:
- name: Run baseline performance tests
run: npm run test:performance -- --prefix=base
- name: Print base line performance tests results
run: "node ./tests/performance/results.js --prefix=base"
- name: Print baseline performance tests results
run: node ./tests/performance/results.js --prefix=base
- name: Compare results with base
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.