Skip to content
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

tools: validate commit list as part of lint-release-commit #56291

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
49 changes: 42 additions & 7 deletions .github/workflows/lint-release-proposal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,52 @@ jobs:
[ "$PR_HEAD" = "$GITHUB_SHA" ]
env:
GH_TOKEN: ${{ github.token }}
- name: Verify it's release-ready
run: |
SKIP_XZ=1 make release-only
- name: Validate CHANGELOG
id: releaser-info
run: |
EXPECTED_CHANGELOG_TITLE_INTRO="## $COMMIT_SUBJECT, @"
echo "Expected CHANGELOG section title: $EXPECTED_CHANGELOG_TITLE_INTRO"
CHANGELOG_TITLE="$(grep "$EXPECTED_CHANGELOG_TITLE_INTRO" "doc/changelogs/CHANGELOG_V${COMMIT_SUBJECT:20:2}.md")"
CHANGELOG_PATH="doc/changelogs/CHANGELOG_V${COMMIT_SUBJECT:20:2}.md"
CHANGELOG_TITLE="$(grep "$EXPECTED_CHANGELOG_TITLE_INTRO" "$CHANGELOG_PATH")"
echo "Actual: $CHANGELOG_TITLE"
[ "${CHANGELOG_TITLE%%@*}@" = "$EXPECTED_CHANGELOG_TITLE_INTRO" ]
- name: Verify NODE_VERSION_IS_RELEASE bit is correctly set
run: |
grep -q '^#define NODE_VERSION_IS_RELEASE 1$' src/node_version.h
- name: Check for placeholders in documentation
run: |
! grep "REPLACEME" doc/api/*.md
MAJOR=$(awk '/^#define NODE_MAJOR_VERSION / { print $3 }' src/node_version.h)
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
--jq '.commits | map({ smallSha: .sha[0:10], splitTitle: .commit.message|split("\n\n")|first|split(":") })' \
"176b16a61c7ef3e8c36f9c64c14246d5331c2c53...v23.4.0" --paginate |\
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
jq -r '.[] | "* [[`" + .smallSha + "`](https://github.com/nodejs/node/commit/" + .smallSha + ")] - **" + (.splitTitle|first) + "**:" + (.splitTitle[1:]|join(":"))' |\
node --input-type=module -e '
import assert from "node:assert";
import {readFile} from "node:fs/promises";
import {createInterface} from "node:readline";
const [,CHANGELOG_PATH, GITHUB_SHA] = process.argv;
const changelog = await readFile(CHANGELOG_PATH, "utf-8");
const startCommitListing = changelog.indexOf("\n### Commits\n");
const commitList = changelog.slice(startCommitListing, changelog.indexOf("\n\n<a", startCommitListing))
// Checking for semverness is too expansive, it is left as a exercice for human reviewers.
.replaceAll("**(SEMVER-MINOR)** ", "")
// Correct Markdown escaping is validated by the linter, getting rid of it here helps.
.replaceAll("\\", "");

let expectedNumberOfCommitsLeft = commitList.match(/\n\* \[/g).length;
for await (const line of createInterface(process.stdin)) {
if (line.includes(GITHUB_SHA.slice(0, 10))) {
assert.strictEqual(
expectedNumberOfCommitsLeft, 0,
"Some commits are listed without being included in the proposal, or are listed more than once",
);
continue;
}

assert(commitList.includes("\n"+line), `Missing "${line}" in commit list`);
expectedNumberOfCommitsLeft--;
}
assert.strictEqual(expectedNumberOfCommitsLeft, 0, "Release commit is not the last commit in the proposal");
' "$CHANGELOG_PATH" "$GITHUB_SHA"
env:
GH_TOKEN: ${{ github.token }}
Loading