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: Set up branch only once for all test suites #24123

Merged
merged 3 commits into from
Jul 23, 2020
Merged
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
60 changes: 33 additions & 27 deletions bin/plugin/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,12 @@ function curateResults( results ) {
}

/**
* Runs the performance tests on a given branch.
* Set up the given branch for testing.
*
* @param {string} performanceTestDirectory Path to the performance tests' clone.
* @param {string} environmentDirectory Path to the plugin environment's clone.
* @param {string} testSuite Name of the tests set.
* @param {string} branch Branch name.
*
* @return {Promise<WPFormattedPerformanceResults>} Performance results for the branch.
* @param {string} environmentDirectory Path to the plugin environment's clone.
*/
async function getPerformanceResultsForBranch(
performanceTestDirectory,
environmentDirectory,
testSuite,
branch
) {
async function setUpGitBranch( branch, environmentDirectory ) {
// Restore clean working directory (e.g. if `package-lock.json` has local
// changes after install).
await git.discardLocalChanges( environmentDirectory );
Expand All @@ -144,10 +135,17 @@ async function getPerformanceResultsForBranch(
'rm -rf node_modules && npm install && npm run build',
environmentDirectory
);
}

log(
'>> Running the test on the ' + formats.success( branch ) + ' branch'
);
/**
* Runs the performance tests on the current branch.
*
* @param {string} testSuite Name of the tests set.
* @param {string} performanceTestDirectory Path to the performance tests' clone.
*
* @return {Promise<WPFormattedPerformanceResults>} Performance results for the branch.
*/
async function runTestSuite( testSuite, performanceTestDirectory ) {
const results = [];
for ( let i = 0; i < 3; i++ ) {
await runShellScript(
Expand Down Expand Up @@ -246,18 +244,26 @@ async function runPerformanceTests( branches, options ) {
const testSuites = [ 'post-editor', 'site-editor' ];

/** @type {Record<string,Record<string, WPFormattedPerformanceResults>>} */
const results = {};
for ( const testSuite of testSuites ) {
results[ testSuite ] = {};
for ( const branch of branches ) {
results[ testSuite ][
branch
] = await getPerformanceResultsForBranch(
performanceTestDirectory,
environmentDirectory,
testSuite,
branch
);
let results = {};
for ( const branch of branches ) {
await setUpGitBranch( branch, environmentDirectory );
log(
'>> Running the test on the ' +
formats.success( branch ) +
' branch'
);

for ( const testSuite of testSuites ) {
results = {
...results,
[ testSuite ]: {
...results[ testSuite ],
[ branch ]: await runTestSuite(
testSuite,
performanceTestDirectory
),
},
};
}
}

Expand Down