Public: anyone can read this; the crew can change it.
/changelog.atom on production names the running release, so the v1 probe's "version agrees" line passes #15483
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15482-changelog-atom-on-production-names-the-r → main 0 commits fork 1 thread · 1 unresolved
2 files
changed +59
−2
src/web/feeds.ts +5 −2
| @@ -256,7 +256,10 @@ export async function changelogAtom(ctx: Ctx): Promise<Response> { | ||
| 256 | 256 | const live = answer.live.slice(0, CHANGELOG_ENTRIES); |
| 257 | 257 | const { tip, waves } = await timePhaseAsync(ctx.request, "waves", () => ownWaves(ctx)); |
| 258 | 258 | const [ownerName = "", repoName = ""] = (ctx.app.config.forgeRepo ?? "").split("/"); |
| 259 | const etag = changelogTag(answer.version ?? "dev", live, [tip]); | |
| 259 | // A build with no version stamp is named by its commit, as /changelog names it (#15482): the | |
| 260 | // generator carries it, and the tag changes with it so a cached feed never outlives a release. | |
| 261 | const named = answer.version ?? answer.short; | |
| 262 | const etag = changelogTag(answer.version ?? answer.commit ?? "dev", live, [tip]); | |
| 260 | 263 | const headers = { etag, "cache-control": "public, max-age=300" }; |
| 261 | 264 | if (holds(ctx.request.headers.get("if-none-match"), etag)) return new Response(null, { status: 304, headers }); |
| 262 | 265 | const waveOf = new Map<string, Wave>(); |
| @@ -303,7 +306,7 @@ export async function changelogAtom(ctx: Ctx): Promise<Response> { | ||
| 303 | 306 | <updated>${xml(stamp(updated))}</updated> |
| 304 | 307 | <link rel="self" type="application/atom+xml" href="${xml(origin)}/changelog.atom"/> |
| 305 | 308 | <link rel="alternate" type="text/html" href="${xml(origin)}/changelog"/> |
| 306 | <generator${answer.version === null ? "" : ` version="${xml(answer.version)}"`}>forge</generator> | |
| 309 | <generator${named === null ? "" : ` version="${xml(named)}"`}>forge</generator> | |
| 307 | 310 | ${entries.join("\n")} |
| 308 | 311 | </feed> |
| 309 | 312 | `; |
test/changelog-atom-commit.test.ts added +54
| @@ -0,0 +1,54 @@ | ||
| 1 | /** | |
| 2 | * A running release with a commit and no version stamp is named by /changelog.atom as /changelog | |
| 3 | * names it: the short commit in the generator, and a tag that changes with the commit (#15482). | |
| 4 | */ | |
| 5 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 6 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 7 | import { tmpdir } from "node:os"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { createApp, type App } from "../src/app.ts"; | |
| 10 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 11 | ||
| 12 | describe("GET /changelog.atom on an unstamped release", () => { | |
| 13 | let dataDir: string; | |
| 14 | let app: App; | |
| 15 | let servers: Servers; | |
| 16 | const saved = { commit: process.env["FORGE_COMMIT"], version: process.env["FORGE_VERSION"] }; | |
| 17 | ||
| 18 | beforeAll(async () => { | |
| 19 | delete process.env["FORGE_VERSION"]; | |
| 20 | process.env["FORGE_COMMIT"] = "1e36e93" + "0".repeat(33); | |
| 21 | dataDir = await mkdtemp(join(tmpdir(), "forge-atom-commit-")); | |
| 22 | app = createApp({ dataDir, port: 0, forgeRepo: "alice/forge" }); | |
| 23 | servers = await serve(app); | |
| 24 | }); | |
| 25 | ||
| 26 | afterAll(async () => { | |
| 27 | for (const [k, v] of [["FORGE_COMMIT", saved.commit], ["FORGE_VERSION", saved.version]] as const) { | |
| 28 | if (v === undefined) delete process.env[k]; | |
| 29 | else process.env[k] = v; | |
| 30 | } | |
| 31 | servers.stop(); | |
| 32 | app.close(); | |
| 33 | await rm(dataDir, { recursive: true, force: true }); | |
| 34 | }); | |
| 35 | ||
| 36 | test("the generator names the running commit, as the page does", async () => { | |
| 37 | const [atom, page] = await Promise.all([ | |
| 38 | fetch(`${servers.url}/changelog.atom`).then((r) => r.text()), | |
| 39 | fetch(`${servers.url}/changelog`).then((r) => r.text()), | |
| 40 | ]); | |
| 41 | expect(page).toContain("1e36e93"); | |
| 42 | expect(atom).toContain(`<generator version="1e36e93">forge</generator>`); | |
| 43 | expect(atom).not.toContain("dev"); | |
| 44 | }); | |
| 45 | ||
| 46 | test("the tag changes when the running commit does", async () => { | |
| 47 | const before = (await fetch(`${servers.url}/changelog.atom`)).headers.get("etag"); | |
| 48 | process.env["FORGE_COMMIT"] = "2f47f04" + "0".repeat(33); | |
| 49 | const res = await fetch(`${servers.url}/changelog.atom`, { headers: { "if-none-match": before ?? "" } }); | |
| 50 | expect(res.status).toBe(200); | |
| 51 | expect(res.headers.get("etag")).not.toBe(before); | |
| 52 | expect(await res.text()).toContain(`<generator version="2f47f04">forge</generator>`); | |
| 53 | }); | |
| 54 | }); |
new above
offline
Fragile: any entry containing "dev" fails this. The generator assertion above already proves the fix; remove this line.