Skip to content

Commit 4eda24b

Browse files
authored
ci(cdk-release): fix bug marking stable changes as alpha (#35012)
### Issue #34907 Closes #34907. ### Reason for this change Changelog generation sometimes treats stable changes as alpha changes. ### Description of changes - "BREAKING CHANGE TO EXPERIMENTAL CHANGES" is changed to just "BREAKING CHANGES", there's no guarantee that the all breaking changes are limited to alpha modules. - alpha package scopes will not be treated as equal to stable package scopes. - The phrase "CHANGES TO L1 RESOURCES" will be treated as a note group similar to "BREAKING CHANGES". The description of L1 change commits should use the phrase "CHANGES TO L1 RESOURCES" instead of "BREAKING CHANGES". ### Describe any new or updated permissions being added No new permissions are added. ### Description of how you validated changes Unit tests added. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 2559e1d commit 4eda24b

File tree

4 files changed

+44
-15
lines changed

4 files changed

+44
-15
lines changed

tools/@aws-cdk/cdk-release/lib/conventional-commits.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ export async function getConventionalCommitsFromGitHistory(args: ReleaseOptions,
7373
format: '%B%n-hash-%n%H',
7474
// our tags have the 'v' prefix
7575
from: gitTag,
76-
}).pipe(conventionalCommitsParser());
76+
}).pipe(conventionalCommitsParser(
77+
{
78+
noteKeywords: ['BREAKING CHANGE', 'BREAKING-CHANGES', 'CHANGES TO L1 RESOURCES'],
79+
},
80+
));
7781

7882
conventionalCommitsStream.on('data', function (data: any) {
7983
// filter out all commits that don't conform to the Conventional Commits standard
@@ -134,7 +138,6 @@ export function createScopeVariations(names: string[]) {
134138
const transforms: Array<(x: string) => string> = [
135139
(name) => name.replace(/^aws-/, ''),
136140
(name) => name.replace(/^aws-/, 'aws'),
137-
(name) => name.replace(/-alpha$/, ''),
138141
];
139142

140143
for (const transform of transforms) {

tools/@aws-cdk/cdk-release/lib/lifecycles/changelog.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,6 @@ export async function changelog(
132132
// which are different than the 'conventionalChangelogWriter' defaults
133133
...presetConfig.writerOpts,
134134
finalizeContext: (ctx: { noteGroups?: { title: string }[]; date?: string }) => {
135-
// the heading of the "BREAKING CHANGES" section is governed by this Handlebars template:
136-
// https://github.com/conventional-changelog/conventional-changelog/blob/f1f50f56626099e92efe31d2f8c5477abd90f1b7/packages/conventional-changelog-conventionalcommits/templates/template.hbs#L3-L12
137-
// to change the heading from 'BREAKING CHANGES' to 'BREAKING CHANGES TO EXPERIMENTAL FEATURES',
138-
// we have to change the title of the 'BREAKING CHANGES' noteGroup
139-
ctx.noteGroups?.forEach(noteGroup => {
140-
if (noteGroup.title === 'BREAKING CHANGES') {
141-
noteGroup.title = 'BREAKING CHANGES TO EXPERIMENTAL FEATURES';
142-
}
143-
});
144135
// in unit tests, we don't want to have the date in the Changelog
145136
if (args.includeDateInChangelog === false) {
146137
ctx.date = undefined;

tools/@aws-cdk/cdk-release/test/changelog.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ describe('changelog', () => {
161161
expect(changelogContents).toBe(
162162
`## [1.24.0](https://github.com/aws/aws-cdk/compare/v1.23.0...v1.24.0)
163163
164-
### ⚠ BREAKING CHANGES TO EXPERIMENTAL FEATURES
164+
### ⚠ BREAKING CHANGES
165165
166166
* this is a breaking change
167167

tools/@aws-cdk/cdk-release/test/conventional-commits.test.ts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as crypto from 'crypto';
22
import * as stream from 'stream';
3-
import { ConventionalCommit, createScopeVariations, filterCommits, getConventionalCommitsFromGitHistory } from '../lib/conventional-commits';
3+
import { ConventionalCommit, filterCommits, getConventionalCommitsFromGitHistory } from '../lib/conventional-commits';
44
import { ReleaseOptions } from '../lib/types';
55

66
// mock out Git interactions
@@ -38,6 +38,30 @@ describe('getConventionalCommitsFromGitHistory', () => {
3838

3939
expect(commits).toHaveLength(1);
4040
});
41+
42+
test('Changes to L1 are considered a note group', async () => {
43+
const commitMessages = [
44+
'fix(ec2): some fix',
45+
(
46+
'feat: update L1 CloudFormation resource definitions\n\n' +
47+
'CHANGES TO L1 RESOURCES:\n' +
48+
'L1 resources are automatically generated from...:\n' +
49+
'- aws-cdk-lib.aws_kendra.CfnDataSource.TemplateConfigurationProperty: template property here has changed from string to json'
50+
),
51+
];
52+
gitRawCommits.mockImplementation(() => mockGitCommits(commitMessages));
53+
54+
const commits = await getConventionalCommitsFromGitHistory(args, '3.9.2');
55+
56+
expect(commits[0].notes).toHaveLength(0);
57+
expect(commits[1].notes).toEqual([{
58+
title: 'CHANGES TO L1 RESOURCES',
59+
text: (
60+
'L1 resources are automatically generated from...:\n' +
61+
'- aws-cdk-lib.aws_kendra.CfnDataSource.TemplateConfigurationProperty: template property here has changed from string to json'
62+
),
63+
}]);
64+
});
4165
});
4266

4367
describe('filterCommits', () => {
@@ -105,8 +129,19 @@ describe('filterCommits', () => {
105129
expect(filteredCommits[0].scope).toEqual('aws-stable');
106130
});
107131

108-
test('scope variants take alpha packages into account', () => {
109-
expect(createScopeVariations(['@aws-cdk/aws-batch-alpha'])).toContain('batch');
132+
test('alpha packages are not considered stable', () => {
133+
const ec2Commits = [
134+
commitWithScope('aws-ec2-alpha'),
135+
commitWithScope('ec2'),
136+
commitWithScope('aws-ec2'),
137+
];
138+
139+
const filteredCommits = filterCommits(ec2Commits, {
140+
includePackages: ['@aws-cdk/aws-ec2-alpha'],
141+
});
142+
143+
expect(filteredCommits.length).toEqual(1);
144+
expect(filteredCommits[0].scope).toEqual('aws-ec2-alpha');
110145
});
111146
});
112147

0 commit comments

Comments
 (0)