Check the changelog section of pull request descriptions in CI

Ports the clusterio versions of the changelog scripts. pr_to_changelog.mts
gains the Contributors and Statistics blocks and a shared
checkPullRequestBody, which check_pr_changelog.mts runs on every pull
request through the new Changelog workflow. The latest release is now the
newest one targeting main. Adds the pull request template the check
expects, and node --test runs the script tests in Node.js CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-11-19 14:32:21 +00:00
1 parent b513b7a637
commit 3687a7a527
8 files changed
+305 -25

No files matched your search

+62
View File
@@ -0,0 +1,62 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { checkPullRequestBody } from "../scripts/pr_to_changelog.mts";
import { findChangelogProblems } from "../scripts/check_pr_changelog.mts";
describe("scripts/check_pr_changelog", function() {
function body(...lines) {
return ["Description.", "", "### Changelog", ...lines].join("\r\n");
}
it("accepts entries in a code block", function() {
const text = body(
"```",
"### Features",
"- Added doodad. #12",
"",
"### Fixes",
"- Fixed [#13](https://github.com/explosivegaming/ExpCluster/issues/13)",
"```",
);
assert.deepEqual(findChangelogProblems(text), []);
assert.deepEqual({ ...checkPullRequestBody(text).changelog }, {
"Features": ["Added doodad. #12"],
"Fixes": ["Fixed #13"],
});
});
it("accepts None. in place of the code block", function() {
assert.deepEqual(findChangelogProblems(body("", "None. Only changes CI.")), []);
});
it("rejects a missing body or section", function() {
assert.deepEqual(findChangelogProblems(null), ["Pull request has no body"]);
assert.deepEqual(findChangelogProblems("Description only."), ["\"### Changelog\" header not found"]);
assert.deepEqual(findChangelogProblems(body("Text")), ["Code block not found after header"]);
assert.deepEqual(findChangelogProblems(body("```", "### Fixes")), ["End of code block not found after header"]);
assert.deepEqual(findChangelogProblems(body("```", "", "```")), [
"Code block is empty, replace it with \"None.\" if nothing applies",
]);
});
it("rejects None. inside the code block", function() {
assert.deepEqual(findChangelogProblems(body("```", "None.", "```")), [
"\"None.\" on line 1 must replace the code block, not sit inside it",
]);
});
it("rejects malformed entries", function() {
const text = body("```", "- Orphan #1", "### Bugs", "- Fixed it", "Loose text", "```");
assert.deepEqual(findChangelogProblems(text), [
"Unexpected content \"- Orphan #1\" outside of a changelog section on line 1",
"Changelog section Bugs on line 2 is not one of " +
"Major Features, Features, Fixes, Changes, Breaking Changes, Meta",
"Changelog entry on line 3 does not reference an issue",
"Unexpected content \"Loose text\" on line 4",
]);
});
it("rejects the unedited template", function() {
const text = body(
"```", "### Features", "- Added doodad to web interface. #999", "", "### Changes", "- ...", "```",
);
assert.deepEqual(findChangelogProblems(text), ["Changelog entry on line 5 does not reference an issue"]);
});
});