diff --git a/tools/@aws-cdk/cdk-release/lib/conventional-commits.ts b/tools/@aws-cdk/cdk-release/lib/conventional-commits.ts index 4751f50f2237d..14ce826a82f05 100644 --- a/tools/@aws-cdk/cdk-release/lib/conventional-commits.ts +++ b/tools/@aws-cdk/cdk-release/lib/conventional-commits.ts @@ -73,7 +73,11 @@ export async function getConventionalCommitsFromGitHistory(args: ReleaseOptions, format: '%B%n-hash-%n%H', // our tags have the 'v' prefix from: gitTag, - }).pipe(conventionalCommitsParser()); + }).pipe(conventionalCommitsParser( + { + noteKeywords: ['BREAKING CHANGE', 'BREAKING-CHANGES', 'CHANGES TO L1 RESOURCES'], + }, + )); conventionalCommitsStream.on('data', function (data: any) { // filter out all commits that don't conform to the Conventional Commits standard @@ -134,7 +138,6 @@ export function createScopeVariations(names: string[]) { const transforms: Array<(x: string) => string> = [ (name) => name.replace(/^aws-/, ''), (name) => name.replace(/^aws-/, 'aws'), - (name) => name.replace(/-alpha$/, ''), ]; for (const transform of transforms) { diff --git a/tools/@aws-cdk/cdk-release/lib/lifecycles/changelog.ts b/tools/@aws-cdk/cdk-release/lib/lifecycles/changelog.ts index 1f93e7a89c14d..ebcb5c5d856f9 100644 --- a/tools/@aws-cdk/cdk-release/lib/lifecycles/changelog.ts +++ b/tools/@aws-cdk/cdk-release/lib/lifecycles/changelog.ts @@ -132,15 +132,6 @@ export async function changelog( // which are different than the 'conventionalChangelogWriter' defaults ...presetConfig.writerOpts, finalizeContext: (ctx: { noteGroups?: { title: string }[]; date?: string }) => { - // the heading of the "BREAKING CHANGES" section is governed by this Handlebars template: - // https://github.com/conventional-changelog/conventional-changelog/blob/f1f50f56626099e92efe31d2f8c5477abd90f1b7/packages/conventional-changelog-conventionalcommits/templates/template.hbs#L3-L12 - // to change the heading from 'BREAKING CHANGES' to 'BREAKING CHANGES TO EXPERIMENTAL FEATURES', - // we have to change the title of the 'BREAKING CHANGES' noteGroup - ctx.noteGroups?.forEach(noteGroup => { - if (noteGroup.title === 'BREAKING CHANGES') { - noteGroup.title = 'BREAKING CHANGES TO EXPERIMENTAL FEATURES'; - } - }); // in unit tests, we don't want to have the date in the Changelog if (args.includeDateInChangelog === false) { ctx.date = undefined; diff --git a/tools/@aws-cdk/cdk-release/test/changelog.test.ts b/tools/@aws-cdk/cdk-release/test/changelog.test.ts index 091524515e36c..0c54e395f60c6 100644 --- a/tools/@aws-cdk/cdk-release/test/changelog.test.ts +++ b/tools/@aws-cdk/cdk-release/test/changelog.test.ts @@ -161,7 +161,7 @@ describe('changelog', () => { expect(changelogContents).toBe( `## [1.24.0](https://github.com/aws/aws-cdk/compare/v1.23.0...v1.24.0) -### ⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES +### ⚠ BREAKING CHANGES * this is a breaking change diff --git a/tools/@aws-cdk/cdk-release/test/conventional-commits.test.ts b/tools/@aws-cdk/cdk-release/test/conventional-commits.test.ts index d54e726501093..d4d92beac68d2 100644 --- a/tools/@aws-cdk/cdk-release/test/conventional-commits.test.ts +++ b/tools/@aws-cdk/cdk-release/test/conventional-commits.test.ts @@ -1,6 +1,6 @@ import * as crypto from 'crypto'; import * as stream from 'stream'; -import { ConventionalCommit, createScopeVariations, filterCommits, getConventionalCommitsFromGitHistory } from '../lib/conventional-commits'; +import { ConventionalCommit, filterCommits, getConventionalCommitsFromGitHistory } from '../lib/conventional-commits'; import { ReleaseOptions } from '../lib/types'; // mock out Git interactions @@ -38,6 +38,30 @@ describe('getConventionalCommitsFromGitHistory', () => { expect(commits).toHaveLength(1); }); + + test('Changes to L1 are considered a note group', async () => { + const commitMessages = [ + 'fix(ec2): some fix', + ( + 'feat: update L1 CloudFormation resource definitions\n\n' + + 'CHANGES TO L1 RESOURCES:\n' + + 'L1 resources are automatically generated from...:\n' + + '- aws-cdk-lib.aws_kendra.CfnDataSource.TemplateConfigurationProperty: template property here has changed from string to json' + ), + ]; + gitRawCommits.mockImplementation(() => mockGitCommits(commitMessages)); + + const commits = await getConventionalCommitsFromGitHistory(args, '3.9.2'); + + expect(commits[0].notes).toHaveLength(0); + expect(commits[1].notes).toEqual([{ + title: 'CHANGES TO L1 RESOURCES', + text: ( + 'L1 resources are automatically generated from...:\n' + + '- aws-cdk-lib.aws_kendra.CfnDataSource.TemplateConfigurationProperty: template property here has changed from string to json' + ), + }]); + }); }); describe('filterCommits', () => { @@ -105,8 +129,19 @@ describe('filterCommits', () => { expect(filteredCommits[0].scope).toEqual('aws-stable'); }); - test('scope variants take alpha packages into account', () => { - expect(createScopeVariations(['@aws-cdk/aws-batch-alpha'])).toContain('batch'); + test('alpha packages are not considered stable', () => { + const ec2Commits = [ + commitWithScope('aws-ec2-alpha'), + commitWithScope('ec2'), + commitWithScope('aws-ec2'), + ]; + + const filteredCommits = filterCommits(ec2Commits, { + includePackages: ['@aws-cdk/aws-ec2-alpha'], + }); + + expect(filteredCommits.length).toEqual(1); + expect(filteredCommits[0].scope).toEqual('aws-ec2-alpha'); }); });