fix(release): validate changelog before atomic write

This commit is contained in:
Vincent Koc
2026-07-10 23:14:52 -07:00
parent 2571ae3d9f
commit b2124af4e7
2 changed files with 85 additions and 8 deletions
+51
View File
@@ -470,6 +470,57 @@ describe("release-note verification", () => {
}
});
it("leaves CHANGELOG.md untouched when the rendered ledger fails validation", () => {
const cwd = mkdtempSync(join(tmpdir(), "openclaw-release-notes-"));
try {
git(cwd, ["init", "-q"]);
const changelog = [
"# Changelog",
"",
"## 2026.7.1",
"",
"### Highlights",
"",
"- Only one highlight.",
"",
"### Changes",
"",
"### Fixes",
"",
].join("\n");
writeFileSync(join(cwd, "CHANGELOG.md"), changelog);
git(cwd, ["add", "CHANGELOG.md"]);
git(cwd, ["commit", "-qm", "initial"]);
const manifestPath = join(cwd, "release-manifest.json");
const result = spawnSync(
process.execPath,
[
verifier,
"--base",
"HEAD",
"--target",
"HEAD",
"--main-ref",
"HEAD",
"--manifest",
manifestPath,
"--version",
"2026.7.1",
"--write-ledger",
],
{ cwd, encoding: "utf8" },
);
expect(result.status).toBe(1);
expect(result.stdout).toContain("1 errors");
expect(JSON.parse(readFileSync(manifestPath, "utf8")).version).toBe("2026.7.1");
expect(readFileSync(join(cwd, "CHANGELOG.md"), "utf8")).toBe(changelog);
} finally {
rmSync(cwd, { recursive: true, force: true });
}
});
it("rejects a release base that is not an ancestor of the target", () => {
const cwd = mkdtempSync(join(tmpdir(), "openclaw-release-notes-"));
try {