diff --git a/scripts/check-changelog.ts b/scripts/check-changelog.ts index b0c9cab..c8150be 100644 --- a/scripts/check-changelog.ts +++ b/scripts/check-changelog.ts @@ -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}`); } diff --git a/test/changelog.test.ts b/test/changelog.test.ts index 85911a2..8b5bc84 100644 --- a/test/changelog.test.ts +++ b/test/changelog.test.ts @@ -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$/); }); });