Public: anyone can read this; the crew can change it.
Production's changelog carries the running commit's check verdict even when the forge's repository is private #15529
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15528-production-s-changelog-carries-the-runni → main 0 commits fork 2 threads · 2 unresolved
3 files
changed +38
−12
src/core/forge_repo.ts +9 −2
| @@ -8,11 +8,18 @@ import { forgeSource } from "../settings/forge_source.ts"; | ||
| 8 | 8 | import { getRepo, type Repo } from "./repos.ts"; |
| 9 | 9 | |
| 10 | 10 | export function publicForgeRepo(app: App): Repo | undefined { |
| 11 | const [owner = "", name = ""] = (app.config.forgeRepo ?? "").split("/"); | |
| 12 | const repo = owner === "" || name === "" ? undefined : getRepo(app.db, owner, name); | |
| 11 | const repo = forgeRepo(app); | |
| 13 | 12 | return repo !== undefined && repo.visibility === "public" ? repo : undefined; |
| 14 | 13 | } |
| 15 | 14 | |
| 15 | /** | |
| 16 | * The repository `FORGE_REPO` names, whatever its visibility: callers decide what of it may leave. | |
| 17 | */ | |
| 18 | export function forgeRepo(app: App): Repo | undefined { | |
| 19 | const [owner = "", name = ""] = (app.config.forgeRepo ?? "").split("/"); | |
| 20 | return owner === "" || name === "" ? undefined : getRepo(app.db, owner, name); | |
| 21 | } | |
| 22 | ||
| 16 | 23 | /** |
| 17 | 24 | * Whether `repo` is the forge's own source (`settings/forge_source.ts`): an |
| 18 | 25 | * admin's setting, else `FORGE_REPO`. Names compare without case, as the |
src/release/running_check.ts +8 −5
| @@ -2,13 +2,13 @@ | ||
| 2 | 2 | * The full check's verdict on the commit this forge runs, for anyone (#15514): what the public |
| 3 | 3 | * changelog answer (`GET /api/v1/changelog`, MCP `releases`) says beside the running commit, so a |
| 4 | 4 | * stranger can see the release's tests ran green without reading the runs. Only the running |
| 5 | * commit of the forge's own public repository is ever asked, and only its state and run id leave: | |
| 6 | * no summary, no log, no other commit's check. | |
| 5 | * commit of the forge's own repository (`FORGE_REPO`) is ever asked, and only its state and run id | |
| 6 | * leave: no summary, no log, no other commit's check. | |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | import type { App } from "../app.ts"; |
| 10 | 10 | import { releaseCheck, type CommitCheck } from "../checks/commit_check.ts"; |
| 11 | import { publicForgeRepo } from "../core/forge_repo.ts"; | |
| 11 | import { forgeRepo } from "../core/forge_repo.ts"; | |
| 12 | 12 | import { hasCommit, isAncestor } from "../git/builds.ts"; |
| 13 | 13 | import { repoDir } from "../git/repos.ts"; |
| 14 | 14 | |
| @@ -32,10 +32,13 @@ export function runningState(state: CommitCheck["state"]): RunningCheckState { | ||
| 32 | 32 | */ |
| 33 | 33 | const settled = new WeakMap<App["db"], RunningCheck>(); |
| 34 | 34 | |
| 35 | /** The running commit's check, or null when the forge has no public repository or no commit. */ | |
| 35 | /** | |
| 36 | * The running commit's check, or null when the forge names no repository of its own or no commit. | |
| 37 | */ | |
| 36 | 38 | export async function runningCheck(app: App, commit: string | null): Promise<RunningCheck | null> { |
| 37 | 39 | if (commit === null || !/^[0-9a-f]{40}$/.test(commit)) return null; |
| 38 | const repo = publicForgeRepo(app); | |
| 40 | // Private too (#15528): a release's verdict on its own public commit is the release's claim. | |
| 41 | const repo = forgeRepo(app); | |
| 39 | 42 | if (repo === undefined) return null; |
outdated
Box 1 wants the reason as one line. Condense these three lines to a single sentence. |
||
| 40 | 43 | const kept = settled.get(app.db); |
| 41 | 44 | if (kept !== undefined && kept.commit === commit) return kept; |
test/running-check.test.ts +21 −5
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | /** |
| 2 | 2 | * The public changelog answer states the full check's verdict on the running commit, and only that |
| 3 | * commit's, only for the forge's own public repository (#15514): a stranger reads ok, failed or | |
| 4 | * running and the run id, never a summary. | |
| 3 | * commit's, of the forge's own repository, public or private (#15514, #15528): a stranger reads ok, | |
| 4 | * failed or running and the run id, never a summary. | |
| 5 | 5 | */ |
| 6 | 6 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 7 | 7 | import { mkdtemp, rm } from "node:fs/promises"; |
| @@ -23,6 +23,7 @@ let dirs: string[] = []; | ||
| 23 | 23 | let app: App; |
| 24 | 24 | let repo: Repo; |
| 25 | 25 | let hidden: App; |
| 26 | let hiddenRun: string; | |
| 26 | 27 | |
| 27 | 28 | async function forge(visibility: "public" | "private"): Promise<{ app: App; repo: Repo }> { |
| 28 | 29 | const dataDir = await mkdtemp(join(tmpdir(), "forge-running-check-")); |
| @@ -47,7 +48,7 @@ beforeAll(async () => { | ||
| 47 | 48 | ({ app, repo } = await forge("public")); |
| 48 | 49 | const other = await forge("private"); |
| 49 | 50 | hidden = other.app; |
| 50 | check(hidden, other.repo, OID("a"), "ok"); | |
| 51 | hiddenRun = check(hidden, other.repo, OID("a"), "ok"); | |
| 51 | 52 | }, 30_000); |
| 52 | 53 | |
| 53 | 54 | afterAll(async () => { |
| @@ -65,10 +66,25 @@ test("ok, failed and running are each stated with the run id", async () => { | ||
| 65 | 66 | expect(await runningCheck(app, OID("3"))).toEqual({ commit: OID("3"), state: "running", runId: running }); |
| 66 | 67 | }); |
| 67 | 68 | |
| 68 | test("nothing is stated without a running commit, and a private forge repository states nothing", async () => { | |
| 69 | test("nothing is stated without a running commit", async () => { | |
| 69 | 70 | expect(await runningCheck(app, null)).toBeNull(); |
| 70 | 71 | expect(await runningCheck(app, "not-a-commit")).toBeNull(); |
| 71 | expect(await runningCheck(hidden, OID("a"))).toBeNull(); | |
| 72 | }); | |
| 73 | ||
| 74 | test("a private forge repository still answers its running commit's verdict, in three fields only", async () => { | |
| 75 | const found = await runningCheck(hidden, OID("a")); | |
| 76 | expect(found).toEqual({ commit: OID("a"), state: "ok", runId: hiddenRun }); | |
| 77 | expect(Object.keys(found ?? {}).sort()).toEqual(["commit", "runId", "state"]); | |
| 78 | const before = process.env["FORGE_COMMIT"]; | |
| 79 | process.env["FORGE_COMMIT"] = OID("a"); | |
| 80 | try { | |
| 81 | const answer = await shippedAnswer(hidden); | |
| 82 | expect(answer.check).toEqual({ commit: OID("a"), state: "ok", runId: hiddenRun }); | |
| 83 | expect(JSON.stringify(answer)).not.toContain("a private summary"); | |
| 84 | } finally { | |
| 85 | if (before === undefined) delete process.env["FORGE_COMMIT"]; | |
| 86 | else process.env["FORGE_COMMIT"] = before; | |
| 87 | } | |
| 72 | 88 | }); |
| 73 | 89 | |
| 74 | 90 | test("the public answer carries the running commit's check, and nothing of its summary", async () => { |
new above
offline
Duplicates the FORGE_REPO parse in core/forge_repo.ts. Extract a shared
forgeRepo(app)there (any visibility) and call it here and from publicForgeRepo.