Public: anyone can read this; the crew can change it.

Release reused an image built from an older commit: v0.7.646 shipped without the fix it was cut for #17028

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

This pull fixes only the labelling half of #16349. The reuse check lives in tick.sh, which isn't in this repository, so I couldn't change or test it. Until the host script is changed, the tick can still reuse a stale forge: image.

Notes

opened this

This pull fixes only the labelling half of #16349. The reuse check lives in tick.sh, which isn't in this repository, so I couldn't change or test it. Until the host script is changed, the tick can still reuse a stale forge:<version> image.

What changed

  • The Dockerfile now adds LABEL forge.commit=$COMMIT, using the existing COMMIT build argument. Every image it builds carries the commit it was built from. That includes the .forgejo/workflows/release.yml build, which already passes COMMIT.
  • test/release-gate.test.ts has a new test. It checks that the Dockerfile carries the label and that the release build passes the commit. That test and tsc pass. I didn't run the rest of the suite; the forge runs it on push.
  • docs/features/nightly-release.md now says what the host script must do. It should reuse forge:<version> only when docker image inspect -f '{{index .Config.Labels "forge.commit"}}' equals the commit it is cutting. Otherwise it rebuilds with --build-arg COMMIT=<sha>, and an unlabelled image counts as stale.

What I did not do

  • I did not write the issue's test, "a tick whose tag exists with another commit's label rebuilds". It needs tick.sh, so it can only be written where that script lives.
  • I did not find what built 0.7.646 at 21:44:02, ahead of the tick. Nothing in this repository shows a pre-build on merge. If it was a separate docker build on the host, it must pass --build-arg COMMIT=<sha>.

How to try it Build the image and run docker inspect -f '{{index .Config.Labels "forge.commit"}}' on it. It should print the commit you passed.

Closes #16349

3 earlier comments
commented

This pull fixes only the labelling half of #16349. The reuse check lives in tick.sh, which isn't in this repository, so I couldn't change or test it. Until the host script is changed, the tick can still reuse a stale forge:<version> image.

What changed

  • The Dockerfile now adds LABEL forge.commit=$COMMIT, using the existing COMMIT build argument. Every image it builds carries the commit it was built from. That includes the .forgejo/workflows/release.yml build, which already passes COMMIT.
  • test/release-gate.test.ts has a new test. It checks that the Dockerfile carries the label and that the release build passes the commit. That test and tsc pass. I didn't run the rest of the suite; the forge runs it on push.
  • docs/features/nightly-release.md now says what the host script must do. It should reuse forge:<version> only when docker image inspect -f '{{index .Config.Labels "forge.commit"}}' equals the commit it is cutting. Otherwise it rebuilds with --build-arg COMMIT=<sha>, and an unlabelled image counts as stale.

What I did not do

  • I did not write the issue's test, "a tick whose tag exists with another commit's label rebuilds". It needs tick.sh, so it can only be written where that script lives.
  • I did not find what built 0.7.646 at 21:44:02, ahead of the tick. Nothing in this repository shows a pre-build on merge. If it was a separate docker build on the host, it must pass --build-arg COMMIT=<sha>.

How to try it Build the image and run docker inspect -f '{{index .Config.Labels "forge.commit"}}' on it. It should print the commit you passed.

commented

This pull gives the release a tested reuse decision, but the tick still has to call it, and that call is outside this repo. It is not wired to anything yet. tick.sh lives on the host and still reuses any image with the version's tag. Until the host script runs bun src/release/reuse.ts <image> <commit>, a release can still reuse a stale image. So this pull should not close #16349. A person should keep the issue open until the host script calls the check.

I ran the new reuse tests, test/release-gate.test.ts, test/unused-exports.test.ts and the type check, and they pass. The forge runs the full check on push.

What changed

  • Labelling: every image the Dockerfile builds carries forge.commit=<sha>, taken from the existing COMMIT build argument.
  • Reuse decision: a new module, src/release/reuse.ts, reuses an image only when its forge.commit label matches the commit being cut. A different commit's label, a missing label, or no image all mean rebuild. An abbreviated sha on either side matches by prefix, and a commit that isn't a sha is never reused.
  • Command line: bun src/release/reuse.ts <image> <commit> reads the label with docker image inspect, passing the image name as a single argument with no shell. It prints reuse (exit 0) or rebuild: <why> (exit 1), and exits 2 on a bad argument. If docker is missing it prints rebuild: ….
  • Tests: test/release-reuse.test.ts covers an image from another commit, an unlabelled image, and a matching label (full, abbreviated and mixed case). It also covers the command line's rebuild and bad-argument exits. This replaces the text-matching test I had added to test/release-gate.test.ts.
  • Docs: docs/features/nightly-release.md now describes what the release does, with no issue number and no incident narrative.

What I did not do

  • I did not find what built 0.7.646 at 21:44:02. Nothing in this repo shows a pre-build on merge. If a separate docker build on the host does it, it must pass --build-arg COMMIT=<sha>.
commented

I fixed the three failing tests and pushed. The three tests (test/unreached.test.ts, test/spawn-sites.test.ts, test/spawn-pipes.test.ts) and test/release-reuse.test.ts pass locally. The type check is clean. I didn't run the whole suite.

src/release/reuse.ts is a command run by the release tick, so nothing in the app imports it. The failures were bookkeeping, and I made three small edits:

  • scripts/unreached.ts: added src/release/reuse.ts to ENTRIES, alongside src/release/boot.ts, with a comment saying the tick runs it.
  • test/spawn-sites.test.ts: listed the file with its one spawn, docker image inspect with the image name as a single validated argument.
  • test/spawn-pipes.test.ts: listed its piped stdout as read to the end before the exit is awaited.

The check's other concern is unchanged. Nothing in this repo calls the reuse check yet, because tick.sh lives on the host. #16349 should stay open until the host script runs bun src/release/reuse.ts <image> <commit> before reusing an image.

commented

Before this change, a release reused an existing image whenever the version tag already existed. It could ship an image built from an older tree: v0.7.646 went out without the fix it was cut for. Now every image carries a forge.commit label with the commit it was built from. src/release/reuse.ts (reuseDecision, run as bun src/release/reuse.ts <image> <commit>) reuses an image only when that label matches the commit being cut. Otherwise it prints rebuild: <why> and exits 1.

This push fixes the review blocker. The label is now checked against the same commit-id pattern as the commit being cut: 7 to 64 hex characters. Before, a label like 0, a or 00 matched almost any commit by prefix, so a short or garbage label would have reused a stale image. Now any such label means a rebuild, with why set to "the forge.commit label is not a commit id". test/release-reuse.test.ts covers 0, a, 00, a 6-character prefix, zzzzzzz and a label with a non-hex character. The comment at the top of reuse.ts and docs/features/nightly-release.md now include this rule.

Not done here: the release tick on the host does not call bun src/release/reuse.ts yet. #16349 should stay open until it does.

Checks run: the gate (32 rules satisfied) and bun x tsc --noEmit both pass. bun scripts/fast.ts exited 2: the branch changes scripts/unreached.ts, so it could not name the tests to run. I picked 27 test files instead, including the reuse, unreached, unused-exports, spawn-sites, spawn-pipes and spawn-argv tests, and all 282 tests passed.

To try it: bun test test/release-reuse.test.ts, or bun src/release/reuse.ts forge:<tag> <commit> on a host with docker.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs