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

Perf tests: Store test run results as artifact #45747

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ jobs:
if: github.event_name == 'pull_request'
run: ./bin/plugin/cli.js perf $GITHUB_SHA trunk --tests-branch $GITHUB_SHA

- name: Store performance measurements
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
with:
name: perf-test-results
path: ./__test-results/*.json

- name: Compare performance with current WordPress Core and previous Gutenberg versions
if: github.event_name == 'release'
env:
Expand Down
13 changes: 11 additions & 2 deletions bin/plugin/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,21 @@ function curateResults( testSuite, results ) {
*
* @param {string} testSuite Name of the tests set.
* @param {string} performanceTestDirectory Path to the performance tests' clone.
* @param {string} runKey Unique identifier for the test run, e.g. `branch-name_post-editor_run-3`.
*
* @return {Promise<WPPerformanceResults>} Performance results for the branch.
*/
async function runTestSuite( testSuite, performanceTestDirectory ) {
async function runTestSuite( testSuite, performanceTestDirectory, runKey ) {
await runShellScript(
`npm run test:performance -- packages/e2e-tests/specs/performance/${ testSuite }.test.js`,
performanceTestDirectory
);
const resultsFile = path.join(
performanceTestDirectory,
`packages/e2e-tests/specs/performance/${ testSuite }.test.results.json`
);
fs.mkdirSync( './__test-results', { recursive: true } );
fs.copyFileSync( resultsFile, `./__test-results/${ runKey }.results.json` );
const rawResults = await readJSONFile(
path.join(
performanceTestDirectory,
Expand Down Expand Up @@ -388,6 +395,7 @@ async function runPerformanceTests( branches, options ) {
for ( let i = 0; i < TEST_ROUNDS; i++ ) {
rawResults[ i ] = {};
for ( const branch of branches ) {
const runKey = `${ branch }_${ testSuite }_run-${ i }`;
// @ts-ignore
const environmentDirectory = branchDirectories[ branch ];
log( ` >> Branch: ${ branch }, Suite: ${ testSuite }` );
Expand All @@ -399,7 +407,8 @@ async function runPerformanceTests( branches, options ) {
log( ' >> Running the test.' );
rawResults[ i ][ branch ] = await runTestSuite(
testSuite,
performanceTestDirectory
performanceTestDirectory,
runKey
);
log( ' >> Stopping the environment' );
await runShellScript(
Expand Down