Skip to content

Commit

Permalink
tools: validate commit list as part of lint-release-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Dec 17, 2024
1 parent 04c082b commit 75be282
Showing 1 changed file with 43 additions and 7 deletions.
50 changes: 43 additions & 7 deletions .github/workflows/lint-release-proposal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,53 @@ 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 |\
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;
}

Check failure on line 90 in .github/workflows/lint-release-proposal.yml

View workflow job for this annotation

GitHub Actions / lint-yaml

90:1 [trailing-spaces] trailing spaces
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 }}

Check failure on line 98 in .github/workflows/lint-release-proposal.yml

View workflow job for this annotation

GitHub Actions / lint-yaml

98:1 [trailing-spaces] trailing spaces

0 comments on commit 75be282

Please sign in to comment.