test(build): hold the revision stamp to a symbol that exists #283

Merged
coilysiren merged 1 commit from test/build-revision into main 2026-08-13 06:51:20 +00:00
Member

Tests only. Covers the fix for #279, which landed at 0% coverage.

Why this needs a guard specifically

-ldflags -X is the one piece of wiring in this repository that fails silently. The linker does not error on a symbol it cannot resolve — it writes nothing and exits zero. So a rename of buildRevision, a package move, or a module rename leaves an unstamped binary and a completely green build, and nobody finds out until someone reads a log expecting a sha and sees an empty string.

That is the same failure shape as the ones this repo has been closing all night: a claim that looks true because nothing checks it.

I verified the current path resolves rather than assuming it. Built a throwaway main with the Dockerfile's exact -X argument and read the value back:

with    -X …/internal/community.buildRevision=abc123def   → revision="abc123def"
without                                                    → revision=""

It works today. These tests hold it that way.

Three properties

Test Property
…IsEmptyWhenUnstamped an unstamped binary reports empty, not a placeholder — so a caller can tell not stamped from stamped with something
…DockerfileStampsThisPackagesVariable the -X target equals this package's variable, compared against the module path read from go.mod rather than written twice
…PublishPassesTheRevisionBuildArg publish-image.sh passes the ARG the Dockerfile declares

The third exists because a declared ARG with nothing passed stamps an empty string, which is indistinguishable from no stamp at all. Two independent ways to get the same silent nothing.

Verified by mutation

Mutation Result
rename to community.buildRev in the Dockerfile fails, naming both the stamped path and the real one
publish-image.sh stops passing the arg fails, naming the ARG

Note

The implementation took the --build-arg-ldflags -X route rather than copying .git, which keeps -trimpath and keeps repository history out of the build context. Good call — and it means the serving process can now report its own revision, so SIRENS_ECHO_IMAGE stops being something a human has to set correctly.

go vet, gofmt, full go test ./..., pre-commit run --files clean.


Quail (QA)

Tests only. Covers the fix for https://forgejo.coilysiren.me/coilyco-gaming/sirens-echo/issues/279, which landed at 0% coverage. ## Why this needs a guard specifically `-ldflags -X` is the one piece of wiring in this repository that **fails silently**. The linker does not error on a symbol it cannot resolve — it writes nothing and exits zero. So a rename of `buildRevision`, a package move, or a module rename leaves an **unstamped binary and a completely green build**, and nobody finds out until someone reads a log expecting a sha and sees an empty string. That is the same failure shape as the ones this repo has been closing all night: a claim that looks true because nothing checks it. **I verified the current path resolves** rather than assuming it. Built a throwaway `main` with the Dockerfile's exact `-X` argument and read the value back: ``` with -X …/internal/community.buildRevision=abc123def → revision="abc123def" without → revision="" ``` It works today. These tests hold it that way. ## Three properties | Test | Property | | --- | --- | | `…IsEmptyWhenUnstamped` | an unstamped binary reports empty, not a placeholder — so a caller can tell *not stamped* from *stamped with something* | | `…DockerfileStampsThisPackagesVariable` | the `-X` target equals this package's variable, compared against the module path **read from `go.mod`** rather than written twice | | `…PublishPassesTheRevisionBuildArg` | `publish-image.sh` passes the ARG the Dockerfile declares | The third exists because a declared `ARG` with nothing passed stamps an **empty string**, which is indistinguishable from no stamp at all. Two independent ways to get the same silent nothing. ## Verified by mutation | Mutation | Result | | --- | --- | | rename to `community.buildRev` in the Dockerfile | fails, naming both the stamped path and the real one | | `publish-image.sh` stops passing the arg | fails, naming the ARG | ## Note The implementation took the `--build-arg` → `-ldflags -X` route rather than copying `.git`, which keeps `-trimpath` and keeps repository history out of the build context. Good call — and it means the **serving process** can now report its own revision, so `SIRENS_ECHO_IMAGE` stops being something a human has to set correctly. `go vet`, `gofmt`, full `go test ./...`, `pre-commit run --files` clean. --- Quail (QA)
test(build): hold the revision stamp to a symbol that exists
All checks were successful
ci / test (pull_request) Successful in 28s
ci / publish-echo-image (pull_request) Has been skipped
ci / image-build (pull_request) Successful in 15s
61d43a357d
The revision arrives through -ldflags -X, which is the one wiring in this
repository that fails silently. The linker does not error on a symbol it
cannot resolve; it writes nothing and exits zero, so a rename leaves an
unstamped binary and a green build.

I verified the current path resolves by building a throwaway main with the
Dockerfile's exact -X argument and reading the value back. It works today.
These hold it that way.

Three properties. An unstamped binary reports empty rather than a
placeholder, so a caller can tell "not stamped" from "stamped with
something". The Dockerfile's -X target equals this package's variable,
compared against the module path read from go.mod rather than written
twice. And publish-image.sh passes the build arg the Dockerfile declares,
because a declared ARG with nothing passed stamps an empty string, which
looks the same as no stamp.

Verified by mutation. Renaming the stamped variable fails naming both
paths, and dropping the build arg fails naming the ARG.

Refs: #279

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Kai Siren <coilysiren@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
coilyco-ops force-pushed test/build-revision from 61d43a357d
All checks were successful
ci / test (pull_request) Successful in 28s
ci / publish-echo-image (pull_request) Has been skipped
ci / image-build (pull_request) Successful in 15s
to 05ef749670
All checks were successful
ci / test (pull_request) Successful in 29s
ci / publish-echo-image (pull_request) Has been skipped
ci / image-build (pull_request) Successful in 16s
2026-08-13 06:41:05 +00:00
Compare
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
coilyco-gaming/sirens-echo!283
No description provided.