Skip to content

Rung 4/9 — feat(output): Emit a machine-readable build result as JSON and GitHub output - #23

Merged
kerren merged 2 commits into
developfrom
feature/build-result
Aug 29, 2026
Merged

Rung 4/9 — feat(output): Emit a machine-readable build result as JSON and GitHub output#23
kerren merged 2 commits into
developfrom
feature/build-result

Conversation

@kerren

@kerren kerren commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Phase 2. A pipeline had no way to learn the tag it should deploy, or whether a build actually happened, short of scraping prose from stdout.

Adds BuildResult + BuildLog.Result(), WriteBuildOutput (--output-format=text|json, --output-file) and WriteGitHubOutput (hash, cache-hit, image, version, primary-tag, tags, platforms).

Review focus: that --output-format=json puts only JSON on stdout — the contract downstream pipelines depend on, and only true because of rung 1. Also that $GITHUB_OUTPUT is opened O_APPEND|O_WRONLY and never truncated, since other steps write to the same file.

On failure the partial result is still emitted under --output-format=json, so callers can see the hash computed before the error.

Deferred: the e2e JSON-cleanliness assertion (needs a registry; covered by a unit test here) and the follow-up issue on kerren/setup-dockem (external repo).


Merging this completes the v2.6.0 scope — everything to here is additive with no hash change, so users upgrade with no cache impact.

Stack (each PR is based on the one above it — review and merge top-down):
develop ← docs ← 1 log-helpers ← 2 resolve-target-tags ← 3 manifest-head-errors ← 4 build-result ← v2.6.0 ← 5 dockerignore-hashing ← 6 dockerignore-default ← 7 buildx-detect ← 8 buildx-build ← 9 buildx-cache ← v3.0.0

Verified on every rung: go build ./..., go vet ./..., and the full non-e2e unit suite. The e2e suite was not run anywhere — no registry credentials in this environment — so any new e2e test is compile-verified only.

… output

Add an exported BuildResult type (BuildLog.Result()) and two emitters:
WriteBuildOutput, which prints an indented JSON BuildResult to stdout (or
--output-file) when --output-format=json, and WriteGitHubOutput, which
appends hash/cache-hit/image/version/primary-tag/tags/platforms to
$GITHUB_OUTPUT whenever it is set, regardless of --output-format. On a
build failure, cmd/build.go still emits the partial JSON result so a
caller can see whatever was computed - eg. the hash - before the error.

Implements Phase 2 of PLAN.md (Rung 4 of the stacked branch ladder,
feature/build-result on feature/manifest-head-errors). Deferred: the
e2e JSON-parseability assertion (needs a real registry) and the
kerren/setup-dockem follow-up issue (external repo) - both left
unchecked in PLAN.md with a note.
Base automatically changed from feature/manifest-head-errors to develop August 29, 2026 10:44
Develop carried rewritten (but patch-equivalent) copies of this branch's
logging, tag-resolution and manifest-head commits, plus one new fix:
fix(logging), which routed the pre-panic separator in cmd/build.go
through LogInfo and dropped the now-unused fmt import.

That collided with the build-result work, which had wrapped the same
separator in an `outputFormat != "json"` guard so that a JSON run kept
stdout free of anything but the result. LogInfo writes to stderr, so the
guard's only justification is gone: keep the build-result structure and
emit the separator unconditionally through LogInfo, which leaves stdout
pure JSON on the failure path as well.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CShtKNBF7tSFSiXBpCPXiB
@kerren
kerren merged commit 9c39ca8 into develop Aug 29, 2026
2 checks passed
@kerren
kerren deleted the feature/build-result branch August 29, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants