A recent merge request revealed that the continuous‑integration (CI) pipeline for the go‑tool‑base project was executing a test‑only binary (gtb‑e2e) instead of the production‑ready gtb generator, leading to a configuration‑file error that broke one of eighty‑five end‑to‑end scenarios.
The stunt‑double binary masquerading as the star
go‑tool‑base builds two executables from the same repository: ./cmd/gtb, the real generator that ships to users, and ./cmd/e2e, a test rig that enables every optional framework feature. Both binaries identify themselves as "gtb" and read the same configuration paths, which makes the e2e binary appear identical to the real tool in casual use.
The test harness originally used a helper called BinaryPath that claimed to return the compiled gtb binary, but its implementation actually built ./cmd/e2e and stored it under a temporary name "gtb‑e2e". As a result, all generator‑related scenarios were inadvertently running against the stunt‑double binary.
Why the wrong binary triggered a config failure
The framework treats missing configuration files differently depending on whether the tool can create them. A tool that exposes an init command must have run init; therefore a missing config is fatal. Conversely, a tool without init may start with an empty configuration. The real gtb disables the init command, so it tolerates the absence of ~/.gtb/config.yaml in production.
The e2e binary, however, enables init by default. When CI ran the e2e binary on a clean runner that lacked a user configuration directory, the framework raised the error "failed to load configuration: no configuration files found", causing the pipeline to fail. On the developer’s workstation the error did not appear because a personal ~/.gtb/config.yaml was present.
Corrective changes to the helper functions
The first proposed mitigation was to add a dedicated config file to the failing scenario, which would have silenced the error but also mis‑tested the generator by enabling init in a context where the production binary never does. Instead, the author introduced a new helper, GeneratorBinaryPath, that explicitly builds ./cmd/gtb and documents that this binary disables InitCmd, matching production behaviour.
With the corrected helper in place, the pipeline turned green and the e2e binary’s package documentation was updated to clarify its role as a stunt‑double used only for tests that require all optional features.
Further isolation of test environment
A follow‑up issue surfaced in August when a documentation‑generation path behaved differently on a developer machine (which had an AI provider configured) versus CI (which did not). The root cause was the generator steps inheriting the developer’s home directory, thereby exposing personal configuration to the test run.
The resolution involved explicitly setting HOME for the generator steps, isolating caches, and pinning module and lint caches to shared locations. Although the naive isolation increased test duration from 193 seconds to 809 seconds, the subsequent cache relocation trimmed the runtime back to 119 seconds, comfortably within CI limits.
Analysis: why build‑target hygiene matters for CI reliability
Both sources agree that the mix‑up between the production binary and the e2e test binary was the catalyst for a flaky CI pipeline. The incident highlights a broader risk for projects that ship multiple executables from a single codebase: helper functions that abstract binary construction can silently switch targets if their documentation or naming is ambiguous. When such helpers are used in end‑to‑end suites, the resulting tests may pass locally—because the developer’s environment supplies implicit configuration—while failing on clean CI runners that lack those implicit files. The fix in go‑tool‑base underscores two best practices: (1) keep production‑grade and test‑grade binaries separate in both build scripts and helper naming, and (2) explicitly control environment variables such as HOME, XDG_CONFIG_HOME, and cache locations for each test scenario. By doing so, teams can avoid hidden dependencies on a developer’s personal setup and ensure that a green local run truly reflects CI behaviour. The updated documentation and dedicated GeneratorBinaryPath function now make the intent clear, reducing the likelihood of similar regressions in future audits.
Cover: AI-generated illustration with headline text; not a documentary photograph.
Source: The E2E test that built the wrong binary · The E2E test that built the wrong binary

Leave a Reply