From 8c2b03d350c51581a86be5b75ab54500dafcbd22 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Sat, 12 Nov 2022 15:57:28 -0700 Subject: [PATCH] Performance Test: Reuse tests-branch build if possible When running the performance test suite we currently build three copies of the plugin: one for each branch under test and also one for the branch which provides the actual test suite. In this patch we're checking first if one of the branches under test is the same as that tests branch, and if so, re-using the built files from that to avoid the additional approximately five minutes of building. --- bin/plugin/commands/performance.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/bin/plugin/commands/performance.js b/bin/plugin/commands/performance.js index 2aa8a2c9a7f5c6..e3118b73cb80f6 100644 --- a/bin/plugin/commands/performance.js +++ b/bin/plugin/commands/performance.js @@ -258,12 +258,23 @@ async function runPerformanceTests( branches, options ) { await runShellScript( 'mkdir ' + environmentDirectory ); await runShellScript( `cp -R ${ baseDirectory } ${ buildPath }` ); - log( ` >> Fetching the ${ formats.success( branch ) } branch` ); - // @ts-ignore - await SimpleGit( buildPath ).reset( 'hard' ).checkout( branch ); + const fancyBranch = formats.success( branch ); - log( ` >> Building the ${ formats.success( branch ) } branch` ); - await runShellScript( 'npm ci && npm run build', buildPath ); + if ( branch === options.testsBranch ) { + log( + ` >> Re-using the testing branch for ${ fancyBranch }` + ); + await runShellScript( + `cp -R ${ performanceTestDirectory } ${ buildPath }` + ); + } else { + log( ` >> Fetching the ${ fancyBranch } branch` ); + // @ts-ignore + await SimpleGit( buildPath ).reset( 'hard' ).checkout( branch ); + + log( ` >> Building the ${ fancyBranch } branch` ); + await runShellScript( 'npm ci && npm run build', buildPath ); + } await runShellScript( 'cp ' +