fix(changelog): check spec paths outside the image build
The image build runs the suite without docs/, which .dockerignore excludes, so asserting that each note's spec exists on disk failed there and blocked the image. The test now checks a path's shape; check-changelog.ts checks the file exists, the same split the commit refs already have for CI's shallow checkout. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ab3173adf0
commit
fc58cf175f
@@ -4,8 +4,11 @@
|
||||
*
|
||||
* bun run scripts/check-changelog.ts
|
||||
*
|
||||
* Not a test, because CI checks out shallowly and the history is not there.
|
||||
* Not a test, because CI checks out shallowly and the history is not there,
|
||||
* and the image build runs the suite without docs/ — so spec paths are checked
|
||||
* here too.
|
||||
*/
|
||||
import { existsSync } from "node:fs";
|
||||
import { ENTRIES, NOTES } from "../src/shared/changelog.ts";
|
||||
|
||||
const exists = (ref: string) =>
|
||||
@@ -17,6 +20,9 @@ const problems: string[] = [];
|
||||
for (const e of ENTRIES) if (!exists(e.ref)) problems.push(`entry ${e.id}: no commit ${e.ref}`);
|
||||
for (const n of NOTES) {
|
||||
for (const ref of [n.from, n.to]) if (!exists(ref)) problems.push(`note ${n.id}: no commit ${ref}`);
|
||||
for (const path of n.specs ?? []) {
|
||||
if (!existsSync(path)) problems.push(`note ${n.id}: no spec at ${path}`);
|
||||
}
|
||||
if (exists(n.from) && exists(n.to) && !before(n.from, n.to)) {
|
||||
problems.push(`note ${n.id}: ${n.from} does not come before ${n.to}`);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { existsSync } from "node:fs";
|
||||
import {
|
||||
compareUrl,
|
||||
ENTRIES,
|
||||
@@ -31,10 +30,13 @@ describe("the changelog's content", () => {
|
||||
expect(sorted(NOTES)).toBe(true);
|
||||
});
|
||||
|
||||
test("every entry's note exists, and every note's specs exist on disk", () => {
|
||||
test("every entry's note exists, and every spec path is shaped like one", () => {
|
||||
const ids = new Set(NOTES.map((n) => n.id));
|
||||
for (const e of ENTRIES) if (e.note !== undefined) expect(ids).toContain(e.note);
|
||||
for (const n of NOTES) for (const p of n.specs ?? []) expect(existsSync(p)).toBe(true);
|
||||
// Shape only: the image build runs this suite without docs/ (.dockerignore),
|
||||
// so whether the file exists is scripts/check-changelog.ts's question, the
|
||||
// same split the refs get for CI's shallow checkout.
|
||||
for (const n of NOTES) for (const p of n.specs ?? []) expect(p).toMatch(/^docs\/[\w./-]+\.md$/);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user