Skip to content

Move build smoke tooling to Go - #86

Merged
anandh8x merged 1 commit into
mainfrom
feat/go-build-smoke-tools
Jun 6, 2026
Merged

Move build smoke tooling to Go#86
anandh8x merged 1 commit into
mainfrom
feat/go-build-smoke-tools

Conversation

@anandh8x

@anandh8x anandh8x commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

Summary:

  • Add zero-release build/smoke commands backed by internal/release.
  • Switch package scripts and README examples from TS build/smoke scripts to Go.
  • Remove replaced TS build/smoke scripts and move build parser coverage to Go tests.

Tests:

  • go test ./internal/release ./cmd/zero-release
  • bun test ./tests --timeout 15000
  • bun run typecheck
  • bun run build
  • bun run smoke:build
  • bun run build:go
  • bun run smoke:go
  • go test ./...
  • bun run package:release
  • bun run verify:release
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added build and smoke commands to the zero-release CLI tool for building and validating releases.
  • Refactor

    • Build workflows migrated from TypeScript/Bun scripts to Go-based command execution (zero-release build and zero-release smoke).

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Zero automated PR review

Verdict: No blockers found

Blockers

  • None found.

Validation

  • [pass] Diff hygiene: git diff --check
  • [pass] Typecheck: bun run typecheck
  • [pass] Tests: bun run test
  • [pass] Build: bun run build
  • [pass] Smoke build: bun run smoke:build

Scope

Head: c0f57910834e
Changed files (12): README.md, cmd/zero-release/main.go, cmd/zero-release/main_test.go, internal/release/release.go, internal/release/release_test.go, internal/testrunner/testrunner_test.go, internal/verify/verify_test.go, package.json, scripts/build.ts, scripts/smoke-build.ts, scripts/smoke-go.ts, tests/build-scripts.test.ts

This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Complex PR? Review this PR in Change Stack to move by importance, not file order.

Review Change Stack

Walkthrough

This PR migrates build and smoke-check functionality from TypeScript/Bun scripts to Go CLI commands within the zero-release tool. New build and smoke subcommands are added with full flag parsing, environment variable support (ZERO_BUILD_GOOS/ZERO_BUILD_GOARCH), and exported Go API surface. TypeScript scripts are removed and package.json scripts updated to invoke the Go commands instead.

Changes

Build and smoke command migration

Layer / File(s) Summary
Build command CLI routing, parsing, and help
cmd/zero-release/main.go
New build subcommand with --root, --goos, --goarch, -o/--output, --version flags; environment variable defaults from ZERO_BUILD_GOOS/ZERO_BUILD_GOARCH; consistent --help validation; help text generation via writeBuildHelp.
Build command CLI tests
cmd/zero-release/main_test.go
Validates environment variable resolution, CLI override behavior, error handling for missing flags, and help output inclusion of environment variable names.
Smoke command CLI routing, parsing, and help
cmd/zero-release/main.go
New smoke subcommand with --root, --path/--binary (aliased), --goos, --version flags; consistent --help validation; help text generation via writeSmokeHelp.
Smoke command CLI tests
cmd/zero-release/main_test.go
Validates --path/--binary alias parsing and GOOS/version handling.
Release API: Build export and helpers
internal/release/release.go, internal/release/release_test.go
New BuildOptions/BuildResult types and exported Build function (resolves root, defaults GOOS/GOARCH/output, derives version via PackageVersion, runs buildZero); exports DefaultBuildOutput and BuildLdflags helpers.
Release API: Smoke export
internal/release/release.go, internal/release/release_test.go
New SmokeOptions/SmokeResult types and exported Smoke function (resolves root, validates artifact existence, runs smokeVersion check).
Release API: Version helper and integration
internal/release/release.go
Exports PackageVersion helper (renamed from packageVersion); updates Package and buildZero to use exported helpers and centralized ldflags generation.
Documentation examples, package.json, and test fixture updates
README.md, package.json, internal/testrunner/testrunner_test.go, internal/verify/verify_test.go, tests/build-scripts.test.ts
README cross-compilation examples use bun run build --goos/--goarch; package.json scripts invoke go run ./cmd/zero-release build/smoke; test fixtures expect Go build commands; removed deleted build-scripts.test.ts suite and TypeScript build/smoke scripts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Gitlawb/zero#85: Extends the same cmd/zero-release CLI and internal/release/release.go module, introducing build/smoke commands alongside existing package/checksum flow.
  • Gitlawb/zero#74: Updates testrunner-based check detection logic to recognize go run ./cmd/zero-release build as the workspace build check source.
  • Gitlawb/zero#53: Implements shared Go-based release-build contract with ZERO_BUILD_GOOS/GOARCH environment overrides and internal/cli.version ldflags injection.

Suggested reviewers

  • Vasanthdev2004
  • gnanam1990
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: moving build and smoke tooling from TypeScript/Bun scripts to Go implementations in the zero-release CLI.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/go-build-smoke-tools

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
cmd/zero-release/main_test.go (2)

53-64: ⚡ Quick win

Smoke parser coverage is missing the --path alias and default-source behavior.

Lines 53-64 only validate --binary with explicit --goos/--version. Add table cases for --path=... and for omitted flags to validate fallback/default resolution expected by the smoke CLI contract.

Suggested additional cases
 func TestParseSmokeArgsAcceptsPathAlias(t *testing.T) {
-  options, help, err := parseSmokeArgs([]string{"--binary=dist/zero", "--goos", "linux", "--version", "0.1.0"})
+  options, help, err := parseSmokeArgs([]string{"--binary=dist/zero", "--goos", "linux", "--version", "0.1.0"})
   ...
 }
+
+func TestParseSmokeArgsAcceptsPathFlagAlias(t *testing.T) {
+  options, help, err := parseSmokeArgs([]string{"--path=dist/zero", "--goos", "linux", "--version", "0.1.0"})
+  if err != nil || help {
+    t.Fatalf("parseSmokeArgs --path failed: help=%v err=%v", help, err)
+  }
+  if options.BinaryPath != "dist/zero" {
+    t.Fatalf("BinaryPath = %q", options.BinaryPath)
+  }
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/zero-release/main_test.go` around lines 53 - 64, Update the test coverage
for parseSmokeArgs by expanding TestParseSmokeArgsAcceptsPathAlias into
table-driven cases that include: (1) an input using the alias flag `--path=...`
(verify resulting options.BinaryPath matches the `--path` value), and (2) a case
where flags are omitted to assert default/fallback resolution for
BinaryPath/GOOS/Version (verify defaults match the smoke CLI contract). Locate
parseSmokeArgs and the test function TestParseSmokeArgsAcceptsPathAlias and add
table entries with expected outputs, looping over them and asserting err==nil,
help==false (or expected), and that options fields equal the expected values for
each case.

29-38: ⚡ Quick win

Build override test does not actually verify env override precedence.

Line 29 switches to emptyEnv, so this only tests CLI parsing, not “CLI overrides env” behavior under conflict. Add a case where env is set (e.g., linux/arm64) and CLI provides different values, then assert CLI wins.

Proposed test tightening
- options, help, err = parseBuildArgs([]string{"--goos=windows", "--goarch", "amd64", "--output", "dist/zero.exe"}, emptyEnv)
+ options, help, err = parseBuildArgs(
+   []string{"--goos=windows", "--goarch", "amd64", "--output", "dist/zero.exe"},
+   env, // keep conflicting env set to verify precedence
+ )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/zero-release/main_test.go` around lines 29 - 38, The test currently uses
emptyEnv so it only verifies CLI parsing; add a second subcase that supplies a
non-empty env map (e.g., set GOOS=linux, GOARCH=arm64, OUTPUT=dist/zero) and
then call parseBuildArgs with the same CLI args used here ("--goos=windows",
"--goarch", "amd64", "--output", "dist/zero.exe") to ensure CLI wins; after
calling parseBuildArgs(assert no error and help==false) assert that the returned
options (options.GOOS, options.GOARCH, options.Output) equal the CLI values
("windows", "amd64", "dist/zero.exe") not the env values so the test covers env
vs CLI precedence for parseBuildArgs.
internal/release/release.go (1)

114-122: 💤 Low value

Consider resolving relative output paths to absolute.

When options.Output is a non-empty relative path, it's passed through as-is and returned in BuildResult.OutputPath. While buildZero handles this correctly (since command.Dir = rootDir), the returned OutputPath remains relative. This differs from Smoke which explicitly resolves relative BinaryPath to absolute (lines 148-150).

For API consistency and caller convenience, consider resolving relative paths:

♻️ Optional: resolve relative output to absolute
 output := strings.TrimSpace(options.Output)
 if output == "" {
     output = DefaultBuildOutput(rootDir, goos)
+} else if !filepath.IsAbs(output) {
+    output = filepath.Join(rootDir, output)
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/release/release.go` around lines 114 - 122, The returned BuildResult
currently returns output as provided (variable output from options.Output or
DefaultBuildOutput) which may be a relative path; update the code that sets
output before calling buildZero so relative paths are resolved to absolute paths
for consistency with Smoke.BinaryPath: if output is not filepath.IsAbs(output)
then join it with rootDir (filepath.Join(rootDir, output)) and call filepath.Abs
or filepath.Clean+filepath.Abs to produce an absolute path, then pass that
absolute output into buildZero and set BuildResult.OutputPath to that absolute
value.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@cmd/zero-release/main_test.go`:
- Around line 53-64: Update the test coverage for parseSmokeArgs by expanding
TestParseSmokeArgsAcceptsPathAlias into table-driven cases that include: (1) an
input using the alias flag `--path=...` (verify resulting options.BinaryPath
matches the `--path` value), and (2) a case where flags are omitted to assert
default/fallback resolution for BinaryPath/GOOS/Version (verify defaults match
the smoke CLI contract). Locate parseSmokeArgs and the test function
TestParseSmokeArgsAcceptsPathAlias and add table entries with expected outputs,
looping over them and asserting err==nil, help==false (or expected), and that
options fields equal the expected values for each case.
- Around line 29-38: The test currently uses emptyEnv so it only verifies CLI
parsing; add a second subcase that supplies a non-empty env map (e.g., set
GOOS=linux, GOARCH=arm64, OUTPUT=dist/zero) and then call parseBuildArgs with
the same CLI args used here ("--goos=windows", "--goarch", "amd64", "--output",
"dist/zero.exe") to ensure CLI wins; after calling parseBuildArgs(assert no
error and help==false) assert that the returned options (options.GOOS,
options.GOARCH, options.Output) equal the CLI values ("windows", "amd64",
"dist/zero.exe") not the env values so the test covers env vs CLI precedence for
parseBuildArgs.

In `@internal/release/release.go`:
- Around line 114-122: The returned BuildResult currently returns output as
provided (variable output from options.Output or DefaultBuildOutput) which may
be a relative path; update the code that sets output before calling buildZero so
relative paths are resolved to absolute paths for consistency with
Smoke.BinaryPath: if output is not filepath.IsAbs(output) then join it with
rootDir (filepath.Join(rootDir, output)) and call filepath.Abs or
filepath.Clean+filepath.Abs to produce an absolute path, then pass that absolute
output into buildZero and set BuildResult.OutputPath to that absolute value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cf17e6db-cd3d-4264-b362-d850013c059d

📥 Commits

Reviewing files that changed from the base of the PR and between 6c41984 and c0f5791.

📒 Files selected for processing (12)
  • README.md
  • cmd/zero-release/main.go
  • cmd/zero-release/main_test.go
  • internal/release/release.go
  • internal/release/release_test.go
  • internal/testrunner/testrunner_test.go
  • internal/verify/verify_test.go
  • package.json
  • scripts/build.ts
  • scripts/smoke-build.ts
  • scripts/smoke-go.ts
  • tests/build-scripts.test.ts
💤 Files with no reviewable changes (4)
  • scripts/smoke-go.ts
  • scripts/build.ts
  • tests/build-scripts.test.ts
  • scripts/smoke-build.ts

@Vasanthdev2004

Copy link
Copy Markdown
Collaborator

Blockers

None found.

Non-Blocking

  • None.

Looks Good

  • The Go zero-release build/smoke commands preserve the release-facing script contracts while removing the replaced TS build/smoke scripts.
  • CLI parsing covers env overrides, missing/flag-shaped option values, help output, custom output paths, and smoke path aliases; package destructive-path guards from Move release packaging to Go #85 remain intact.
  • Validation passed locally: go test -count=1 ./internal/release ./cmd/zero-release, go test -count=1 ./..., CLI help/parser edge smokes, bun install --frozen-lockfile, bun test ./tests --timeout 15000, bun run typecheck, bun run build, bun run smoke:build, bun run build:go, bun run smoke:go, bun run package:release, bun run verify:release, bun run perf:smoke, archive-content inspection, native checksum verification, README cross-build command smoke, and git diff --check origin/main...HEAD. GitHub checks are green.

Verdict: Approve — Clean migration of build/smoke tooling to the Go release helper.

@Vasanthdev2004 Vasanthdev2004 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blockers

None found.

Non-Blocking

  • None.

Looks Good

  • The Go zero-release build/smoke commands preserve the release-facing script contracts while removing the replaced TS build/smoke scripts.
  • CLI parsing covers env overrides, missing/flag-shaped option values, help output, custom output paths, and smoke path aliases; package destructive-path guards from #85 remain intact.
  • Validation passed locally: go test -count=1 ./internal/release ./cmd/zero-release, go test -count=1 ./..., CLI help/parser edge smokes, bun install --frozen-lockfile, bun test ./tests --timeout 15000, bun run typecheck, bun run build, bun run smoke:build, bun run build:go, bun run smoke:go, bun run package:release, bun run verify:release, bun run perf:smoke, archive-content inspection, native checksum verification, README cross-build command smoke, and git diff --check origin/main...HEAD. GitHub checks are green.

Verdict: Approve — Clean migration of build/smoke tooling to the Go release helper.

@anandh8x
anandh8x merged commit 8b9b19b into main Jun 6, 2026
6 checks passed
@Vasanthdev2004
Vasanthdev2004 deleted the feat/go-build-smoke-tools branch June 28, 2026 08:27
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