Fix post-merge CI / update ci-jobs util to make base-ref optional (#44055)

* Update ci-jobs util to make base-ref optional

* Fix linting error

* Update baseRef option to be easier to read in ci.yml
This commit is contained in:
jonathansadowski 2024-01-26 13:52:55 -06:00 committed by GitHub
parent d7eaca8415
commit a7f9139b33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 16 deletions

View File

@ -35,10 +35,10 @@ jobs:
script: |
let baseRef = ${{ toJson( github.base_ref ) }};
if ( baseRef ) {
baseRef = 'origin/' + baseRef;
baseRef = `--base-ref origin/${ baseRef }`;
}
const child_process = require( 'node:child_process' );
child_process.execSync( 'pnpm utils ci-jobs ' + baseRef );
child_process.execSync( `pnpm utils ci-jobs ${ baseRef }` );
project-lint-jobs:
name: 'Lint - ${{ matrix.projectName }}'
runs-on: 'ubuntu-20.04'

File diff suppressed because one or more lines are too long

View File

@ -4,4 +4,6 @@ A CLI command for generating the jobs needed by the `ci.yml` file.
A CLI command for parsing CI workflow configuration from `package.json` files.
Usage: `pnpm utils ci-jobs <base-ref>`
Usage: `pnpm utils ci-jobs` (Considers all projects changed and returns all jobs)
Usage: `pnpm utils ci-jobs --base-ref <base-ref>` (Checks for changes between HEAD and `base-ref`)

View File

@ -17,34 +17,32 @@ const program = new Command( 'ci-jobs' )
.description(
'Generates CI workflow jobs based on the changes since the base ref.'
)
.argument(
'<base-ref>',
'Base ref to compare the current ref against for change detection.'
)
.option(
'-f --force',
'Forces all projects to be marked as changed.',
false
'-r --base-ref <baseRef>',
'Base ref to compare the current ref against for change detection. If not specified, all projects will be considered changed.',
''
)
.action( async ( baseRef: string, options ) => {
.action( async ( options ) => {
Logger.startTask( 'Parsing Project Graph', true );
const projectGraph = buildProjectGraph();
Logger.endTask( true );
let fileChanges;
if ( options.force ) {
Logger.warn( 'Forcing all projects to be marked as changed.' );
if ( options.baseRef === '' ) {
Logger.warn(
'No base ref was specified, forcing all projects to be marked as changed.'
);
fileChanges = true;
} else {
Logger.startTask( 'Pulling File Changes', true );
fileChanges = getFileChanges( projectGraph, baseRef );
fileChanges = getFileChanges( projectGraph, options.baseRef );
Logger.endTask( true );
}
Logger.startTask( 'Creating Jobs', true );
const jobs = await createJobsForChanges( projectGraph, fileChanges, {
commandVars: {
baseRef,
baseRef: options.baseRef,
},
} );
Logger.endTask( true );