test(version): pin the semver release reported by /version (#23) - #59
test(version): pin the semver release reported by /version (#23)#59tarakanof wants to merge 3 commits into
Conversation
The semver reported by /version comes from -ldflags "-X main.version=…" at release build time, so nothing in the test suite noticed if the field stopped being wired: the existing handler test only asserted the key was present, whatever its value. Cover both build shapes end of the wire — a release build's injected "v0.22.0" and a plain source build's "dev" default (issue #23).
The metric gained a version label when the semver release started being embedded; the README metric list still advertised only revision and go_version.
…mits
docker/metadata-action's {{version}} strips the leading v, so a released
image reports "0.22.0", not "v0.22.0". Pinning the v-prefixed form invited a
future consumer to assume a prefix that never arrives on the wire.
Code review (independent pass)Reviewed the branch against Verdict: safe to merge. No blocking defects. One should-fix was found and is already applied in Verified independentlyThe whole chain is present on #23 can be closed as already-implemented. Should-fix — applied
Nits — not addressed, judgment call
|
Summary
Working #23 turned up that the feature is already shipped on
main— it landed in #31 (server) and #32 (menu app). The issue is stale. This PR therefore pins the behaviour with real regression tests instead of re-implementing it, and fixes one stale doc line.Verified end to end on
main:cmd/ember/version.go(var version = "dev")/versionpayloadcmd/ember/admin.go(Version string \json:"version"``)cmd/ember/metrics.go(ember_build_info{revision,go_version,version})Dockerfile(ARG VERSION=dev→-X main.version=$VERSION).github/workflows/docker-publish.yml(build-args: VERSION=…)macos/Sources/EmberKit/ServerInfo.swiftConnectionTab.swift,AppTab.swift(viaAppEnvironment.serverVersion())Empirically:
Changes
cmd/ember/admin_test.go— the pre-existing test only asserted theversionkey existed, never its value. AddsTestVersionHandler_ReportsInjectedRelease/TestVersionHandler_ReportsDevWithoutInjectedReleaseplus afetchVersionhelper. Non-tautology checked: stripping the json tag and theVersion:assignment makes both fail.README.md—ember_build_info{revision,go_version}→{revision,go_version,version}, stale since feat(version): report semver in /version and /metrics #31.No production Go / Swift / Docker / CI code changed.
One deviation from the issue text
The issue's acceptance says a released image reports
version: "v0.22.0". It actually reports0.22.0—docker/metadata-action's{{version}}strips the leadingvbefore it reachesbuild-args.Left as-is deliberately, and the tests now pin the bare form:
dtarakanov/ember:0.22.0), so/versionoutput pastes straight into adocker pull;0.22.0andv0.23.0coexisting;scripts/release.shnormalises thevaway,MARKETING_VERSIONis bare, andServerInfoTests.swiftalready encodes"0.9.0".If a
vis ever wanted it belongs inServerInfo.short(presentation), not the wire value.Known gap, out of scope
Nothing pins the symbol path
main.versionthat the Dockerfile targets. Ifversionmoves packages, Go still compiles, these tests still pass, but-X main.version=silently no-ops (the linker doesn't error on an unresolved-X) and released images regress todev— exactly the bug #23 was filed for. Atesting.Short()-gated test that shells out togo build -ldflags …would close it. Worth a follow-up issue.Test plan
gofmt -l .— cleango vet ./...— cleango test ./... -race— all packages passswift test --package-path macos— 165 tests pass-X main.version=v9.9.9, ran it, curled/version→{"binary":"ember","version":"v9.9.9",…}Closes #23.