Skip to content

Commit

Permalink
Fix error handling for performance tests on CI (#24925)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Aug 31, 2020
1 parent c7dfc62 commit b57ae9e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions bin/plugin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
*/
const program = require( 'commander' );

const catchException = ( command ) => {
return async ( ...args ) => {
try {
await command( ...args );
} catch ( error ) {
console.error( error );
process.exitCode = 1;
}
};
};

/**
* Internal dependencies
*/
Expand All @@ -22,37 +33,37 @@ program
.description(
'Release an RC version of the plugin (supports only rc.1 for now)'
)
.action( releaseRC );
.action( catchException( releaseRC ) );

program
.command( 'release-plugin-stable' )
.alias( 'stable' )
.description( 'Release a stable version of the plugin' )
.action( releaseStable );
.action( catchException( releaseStable ) );

program
.command( 'prepare-packages-stable' )
.alias( 'npm-stable' )
.description(
'Prepares the packages to be published to npm as stable (latest dist-tag, production version)'
)
.action( prepareLatestDistTag );
.action( catchException( prepareLatestDistTag ) );

program
.command( 'prepare-packages-rc' )
.alias( 'npm-rc' )
.description(
'Prepares the packages to be published to npm as RC (next dist-tag, RC version)'
)
.action( prepareNextDistTag );
.action( catchException( prepareNextDistTag ) );

program
.command( 'release-plugin-changelog' )
.alias( 'changelog' )
.option( '-m, --milestone <milestone>', 'Milestone' )
.option( '-t, --token <token>', 'Github token' )
.description( 'Generates a changelog from merged Pull Requests' )
.action( getReleaseChangelog );
.action( catchException( getReleaseChangelog ) );

program
.command( 'performance-tests [branches...]' )
Expand All @@ -65,6 +76,6 @@ program
.description(
'Runs performance tests on two separate branches and outputs the result'
)
.action( runPerformanceTests );
.action( catchException( runPerformanceTests ) );

program.parse( process.argv );

0 comments on commit b57ae9e

Please sign in to comment.