Skip to content
Closed
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
4 changes: 3 additions & 1 deletion .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
fetch-depth: 2

- name: Use desired version of NodeJS
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1
Expand All @@ -35,7 +37,7 @@ jobs:

- name: Compare performance with trunk
if: github.event_name == 'pull_request'
run: ./bin/plugin/cli.js perf --ci $GITHUB_SHA trunk --tests-branch $GITHUB_SHA
run: ./bin/plugin/cli.js perf --clone-path $GITHUB_WORKSPACE --ci $GITHUB_SHA trunk --tests-branch $GITHUB_SHA

- name: Compare performance with current WordPress Core and previous Gutenberg versions
if: github.event_name == 'release'
Expand Down
4 changes: 4 additions & 0 deletions bin/plugin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ program
.command( 'performance-tests [branches...]' )
.alias( 'perf' )
.option( ...ciOption )
.option(
'--clone-path <path>',
'Where the git repo is checked out'
)
.option(
'--tests-branch <branch>',
"Use this branch's performance test files"
Expand Down
26 changes: 13 additions & 13 deletions bin/plugin/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const fs = require( 'fs' );
const path = require( 'path' );
const { mapValues, kebabCase } = require( 'lodash' );
const SimpleGit = require( 'simple-git' );

/**
* Internal dependencies
Expand All @@ -16,12 +17,12 @@ const {
getRandomTemporaryPath,
} = require( '../lib/utils' );
const git = require( '../lib/git' );
const config = require( '../config' );

/**
* @typedef WPPerformanceCommandOptions
*
* @property {boolean=} ci Run on CI.
* @property {string} clonePath Directory where git checkout is cloned.
* @property {string=} testsBranch The branch whose performance test files will be used for testing.
* @property {string=} wpVersion The WordPress version to be used as the base install for testing.
*/
Expand Down Expand Up @@ -212,24 +213,23 @@ async function runPerformanceTests( branches, options ) {
// 1- Preparing the tests directory.
log( '\n>> Preparing the tests directories' );
log( ' >> Cloning the repository' );
const baseDirectory = await git.clone( config.gitRepositoryURL );
const baseDirectory = getRandomTemporaryPath();
fs.mkdirSync( baseDirectory, { recursive: true } );
runShellScript( 'cp -R ' + options.clonePath + ' ' + baseDirectory );

// @ts-ignore
const git = SimpleGit();
await git.clone( baseDirectory )
const mergeHEAD = options.testsBranch;
const trunkHEAD = await git.raw( 'rev-parse', 'HEAD~' );
branches = [ mergeHEAD, trunkHEAD ];

const rootDirectory = getRandomTemporaryPath();
const performanceTestDirectory = rootDirectory + '/tests';
await runShellScript( 'mkdir -p ' + rootDirectory );
await runShellScript(
'cp -R ' + baseDirectory + ' ' + performanceTestDirectory
);
if ( !! options.testsBranch ) {
log(
' >> Fetching the test branch: ' +
formats.success( options.testsBranch ) +
' branch'
);
await git.checkoutRemoteBranch(
performanceTestDirectory,
options.testsBranch
);
}
log( ' >> Installing dependencies and building packages' );
await runShellScript(
'npm ci && npm run build:packages',
Expand Down