Skip to content

Commit

Permalink
Merge pull request #1032 from ckeditor/i/3814-skip-ci-on-release
Browse files Browse the repository at this point in the history
Other (release-tools): The `commitAndTag()` function understands a new parameter called `skipCi`. By default, release commits will not trigger a new workflow on CI. This behavior can be disabled when passing the `false` value.
  • Loading branch information
pomek authored Oct 23, 2024
2 parents 34bf2fd + a54bc39 commit ecc5104
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ const { toUnix } = upath;
* @param {string} options.version The commit will contain this param in its message and the tag will have a `v` prefix.
* @param {Array.<string>} options.files Array of glob patterns for files to be added to the release commit.
* @param {string} [options.cwd=process.cwd()] Current working directory from which all paths will be resolved.
* @param {boolean} [options.skipCi=true] Whether to add the "[skip ci]" suffix to the commit message.
* @returns {Promise}
*/
export default async function commitAndTag( { version, files, cwd = process.cwd() } ) {
export default async function commitAndTag( { version, files, cwd = process.cwd(), skipCi = true } ) {
const normalizedCwd = toUnix( cwd );
const filePathsToAdd = await glob( files, { cwd: normalizedCwd, absolute: true, nodir: true } );

Expand All @@ -38,6 +39,6 @@ export default async function commitAndTag( { version, files, cwd = process.cwd(
return;
}

await git.commit( `Release: v${ version }.`, filePathsToAdd );
await git.commit( `Release: v${ version }.${ skipCi ? ' [skip ci]' : '' }`, filePathsToAdd );
await git.addTag( `v${ version }` );
}
18 changes: 17 additions & 1 deletion packages/ckeditor5-dev-release-tools/tests/tasks/commitandtag.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,30 @@ describe( 'commitAndTag()', () => {
} ) );

expect( stubs.git.commit ).toHaveBeenCalledExactlyOnceWith(
'Release: v1.0.0.',
'Release: v1.0.0. [skip ci]',
[
'package.json',
'packages/ckeditor5-foo/package.json'
]
);
} );

it( 'should not add skip ci to the commit when skipCi is set as false', async () => {
vi.mocked( glob ).mockResolvedValue( [ 'package.json', 'packages/ckeditor5-foo/package.json' ] );

await commitAndTag( { version: '1.0.0', packagesDirectory: 'packages', files: [ '**/package.json' ], skipCi: false } );

expect( vi.mocked( glob ) ).toHaveBeenCalledExactlyOnceWith( expect.anything(), expect.objectContaining( {
absolute: true,
nodir: true
} ) );

expect( stubs.git.commit ).toHaveBeenCalledExactlyOnceWith(
'Release: v1.0.0.',
expect.anything()
);
} );

it( 'should add a tag to the created commit', async () => {
vi.mocked( glob ).mockResolvedValue( [ 'package.json' ] );

Expand Down

0 comments on commit ecc5104

Please sign in to comment.