Skip to content

Commit 679d813

Browse files
authored
chore(prlint): allow 'aws-cdk-lib' as a pr title scope (#25181)
If a PR applies to aws-cdk-lib as a whole, we want to label it as such. Today, if you have a PR titled "fix(aws-cdk-lib): some change", the PR linter will include this message: ``` ❌ The title of the pull request should omit 'aws-' from the name of modified packages. Use 'cdk-lib' instead of 'aws-cdk-lib'. ``` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 6d906f8 commit 679d813

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

tools/@aws-cdk/prlint/lint.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -468,14 +468,15 @@ function hasLabel(pr: GitHubPr, labelName: string): boolean {
468468
*/
469469
function validateTitleScope(pr: GitHubPr): TestResult {
470470
const result = new TestResult();
471+
const scopesExemptFromThisRule = [ 'aws-cdk-lib' ];
471472
// Specific commit types are handled by `validateTitlePrefix`. This just checks whether
472473
// the scope includes an `aws-` prefix or not.
473474
// Group 1: Scope with parens - "(aws-<name>)"
474475
// Group 2: Scope name - "aws-<name>"
475476
// Group 3: Preferred scope name - "<name>"
476477
const titleRe = /^\w+(\((aws-([\w_-]+))\))?: /;
477478
const m = titleRe.exec(pr.title);
478-
if (m) {
479+
if (m && !scopesExemptFromThisRule.includes(m[2])) {
479480
result.assessFailure(
480481
!!(m[2] && m[3]),
481482
`The title of the pull request should omit 'aws-' from the name of modified packages. Use '${m[3]}' instead of '${m[2]}'.`,

tools/@aws-cdk/prlint/test/lint.test.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@ describe('commit message format', () => {
127127
expect(await prLinter.validate()).resolves;
128128
});
129129

130+
test('valid with aws-cdk-lib as a scope', async () => {
131+
const issue = {
132+
number: 1,
133+
title: 'fix(aws-cdk-lib): some title',
134+
body: '',
135+
labels: [{ name: 'pr-linter/exempt-test' }, { name: 'pr-linter/exempt-integ-test' }],
136+
user: {
137+
login: 'author',
138+
},
139+
};
140+
const prLinter = configureMock(issue, undefined);
141+
expect(await prLinter.validate()).resolves;
142+
});
143+
130144
test.each(['core', 'prlint', 'awslint'])('valid scope for packages that dont use aws- prefix', async (scope) => {
131145
const issue = {
132146
number: 1,
@@ -142,8 +156,8 @@ describe('commit message format', () => {
142156
})
143157
});
144158

145-
describe.only('ban breaking changes in stable modules', () => {
146-
test.only('breaking change in stable module', async () => {
159+
describe('ban breaking changes in stable modules', () => {
160+
test('breaking change in stable module', async () => {
147161
const issue = {
148162
number: 1,
149163
title: 'chore(s3): some title',

0 commit comments

Comments
 (0)