diff --git a/bin/plugin/commands/performance.js b/bin/plugin/commands/performance.js index 2aa8a2c9a7f5c..e3118b73cb80f 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 ' +