Skip to content

Commit 96e996e

Browse files
committed
tools: lint first Alpha release proposals
The release proposal linter assumed that a changelog without a `### Commits` section belongs to a semver-major release whose proposal contains only the release commit. The first Alpha release of a line has the same changelog layout, but its proposal may carry commits picked into `vN.x-staging` after the branch-off, which made the linter fail with "Cannot find <sha> on the list". Look the proposal commits up in the `Semver-*` lists instead, and skip the check that every listed commit is in the proposal, since that list covers every commit since the previous release line. Refs: #67062 Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
1 parent 75191c4 commit 96e996e

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

‎tools/actions/lint-release-proposal-commit-list.mjs‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ import { createInterface } from 'node:readline';
2020
const stdinLineByLine = createInterface(process.stdin)[Symbol.asyncIterator]();
2121

2222
const changelog = await readFile(CHANGELOG_PATH, 'utf-8');
23-
const commitListingStart = changelog.indexOf('\n### Commits\n');
23+
let commitListingStart = changelog.indexOf('\n### Commits\n');
2424
let commitList;
25+
// Whether every commit listed in the changelog must be in the proposal.
26+
let listMustMatchProposal = true;
2527
if (commitListingStart === -1) {
26-
// We're preparing a semver-major release.
27-
assert.match(changelog, /\n### Semver-Major Commits\n/);
28-
// The proposal should contain only the release commit.
29-
commitList = '';
28+
// We're preparing the first release of a new release line: the changelog
29+
// lists every commit since the previous release line, most of them already on
30+
// the release branch, so the proposal only contains a subset of the list.
31+
commitListingStart = changelog.indexOf('\n### Semver-Major Commits\n');
32+
assert.notStrictEqual(commitListingStart, -1, 'Could not find the commit list');
33+
const releaseEnd = changelog.indexOf('\n\n<a', commitListingStart);
34+
commitList = changelog.slice(commitListingStart, releaseEnd === -1 ? changelog.length : releaseEnd + 1);
35+
listMustMatchProposal = false;
3036
} else {
3137
// We can't assume the Commits section is the one for this release in case of
3238
// a release to transition to LTS (i.e. with no commits).
@@ -50,10 +56,12 @@ for await (const line of stdinLineByLine) {
5056
const { smallSha, title, prURL } = JSON.parse(line);
5157

5258
if (smallSha === RELEASE_COMMIT_SHA.slice(0, 10)) {
53-
assert.strictEqual(
54-
expectedNumberOfCommitsLeft, 0,
55-
'Some commits are listed without being included in the proposal, or are listed more than once',
56-
);
59+
if (listMustMatchProposal) {
60+
assert.strictEqual(
61+
expectedNumberOfCommitsLeft, 0,
62+
'Some commits are listed without being included in the proposal, or are listed more than once',
63+
);
64+
}
5765
continue;
5866
}
5967

@@ -91,4 +99,6 @@ for await (const line of stdinLineByLine) {
9199
expectedNumberOfCommitsLeft--;
92100
console.log(prURL);
93101
}
94-
assert.strictEqual(expectedNumberOfCommitsLeft, 0, 'Release commit is not the last commit in the proposal');
102+
if (listMustMatchProposal) {
103+
assert.strictEqual(expectedNumberOfCommitsLeft, 0, 'Release commit is not the last commit in the proposal');
104+
}

0 commit comments

Comments
 (0)