Skip to content

tools: add semver-major release support to release-lint #57827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
31 changes: 25 additions & 6 deletions tools/actions/lint-release-proposal-commit-list.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,34 @@
const stdinLineByLine = createInterface(process.stdin)[Symbol.asyncIterator]();

const changelog = await readFile(CHANGELOG_PATH, 'utf-8');
const commitListingStart = changelog.indexOf('\n### Commits\n');
const commitListingEnd = changelog.indexOf('\n\n<a', commitListingStart);
const commitList = changelog.slice(commitListingStart, commitListingEnd === -1 ? undefined : commitListingEnd + 1)
// Checking for semverness is too expansive, it is left as a exercice for human reviewers.
const sectionTitles = [
'### Commits',
'### Semver-Major Commits',
'### Semver-Minor Commits',
'### Semver-Patch Commits'

Check failure on line 25 in tools/actions/lint-release-proposal-commit-list.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing trailing comma
];

let commitList = '';

for (const title of sectionTitles) {
const start = changelog.indexOf(`\n${title}\n`);
Comment on lines +30 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would pull the commits from the .0.0 release for all releaases, which won't work. We need to differentiate the releases – i.e. if \n### Commits\n can be found, it's semver-minor or semver-patch, otherwise it's semver-major

if (start === -1) continue;

const end = changelog.indexOf('\n\n', start + 1);
const section = changelog.slice(start, end === -1 ? undefined : end + 1);
commitList += section;
}

assert(commitList, 'No recognized commit section found in changelog');

// Normalize for consistent comparison
commitList = commitList
.replaceAll('**(SEMVER-MINOR)** ', '')
// Correct Markdown escaping is validated by the linter, getting rid of it here helps.
.replaceAll('**(SEMVER-MAJOR)** ', '')
.replaceAll('\\', '');

let expectedNumberOfCommitsLeft = commitList.match(/\n\* \[/g).length;
let expectedNumberOfCommitsLeft = commitList.match(/\n\* \[/g)?.length ?? 0;

for await (const line of stdinLineByLine) {
const { smallSha, title, prURL } = JSON.parse(line);

Expand Down
Loading