Skip to content
Merged
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
7 changes: 5 additions & 2 deletions tools/@aws-cdk/cdk-release/lib/conventional-commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 0 additions & 9 deletions tools/@aws-cdk/cdk-release/lib/lifecycles/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tools/@aws-cdk/cdk-release/test/changelog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
41 changes: 38 additions & 3 deletions tools/@aws-cdk/cdk-release/test/conventional-commits.test.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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');
});
});

Expand Down
Loading