Skip to content

[TE-5843] Encode v2 major version in go.mod module path#510

Merged
gchan merged 1 commit into
mainfrom
te-5843-gomod-v2-module-path
May 15, 2026
Merged

[TE-5843] Encode v2 major version in go.mod module path#510
gchan merged 1 commit into
mainfrom
te-5843-gomod-v2-module-path

Conversation

@gchan
Copy link
Copy Markdown
Contributor

@gchan gchan commented May 15, 2026

Description

The go.mod in this repo declares module github.com/buildkite/test-engine-client at every v2.x tag (v2.0.0 through v2.5.0 and main). Go's module versioning rules require modules at v2+ to encode the major version in the module path, so v2.x tags should read module github.com/buildkite/test-engine-client/v2.

The current state makes v2.x releases unfetchable via go get and uninstallable as a go tool. The +incompatible escape hatch doesn't apply because that only works for modules without a go.mod file:

$ go get github.com/buildkite/test-engine-client@v2.5.0
go: ... invalid version: module contains a go.mod file, so module path must
    match major version ("github.com/buildkite/test-engine-client/v2")

$ go get github.com/buildkite/test-engine-client/v2@v2.5.0
go: ... invalid version: module contains a go.mod file, so module path must
    match major version ("github.com/buildkite/test-engine-client/v2")

Downstream Go projects can install bktec as a tool (via the tool ( ... ) directive in go.mod) only against v1.x. buildkite/agent is pinned to v1.6.0 for exactly this reason — that's the most recent v1.x release, and predates the plan subcommand (v2.0.0) and --collect-git-metadata (v2.4.0).

This PR:

  1. Updates go.mod to module github.com/buildkite/test-engine-client/v2.
  2. Rewrites the 56 internal import paths in *.go files from github.com/buildkite/test-engine-client/internal/... to github.com/buildkite/test-engine-client/v2/internal/....
  3. Updates the version ldflags path in .goreleaser.yaml from .../internal/version.Version to .../v2/internal/version.Version so release builds continue to stamp internal/version.Version correctly.

Once a v2.x tag is cut on top of this commit, go get github.com/buildkite/test-engine-client/v2@vX.Y.Z resolves and downstream go tool setups work. Historical v2.0.0–v2.5.0 tags don't need to move; downstream consumers should pin to the new tag (e.g. v2.5.1) and update their import paths to include the /v2 suffix.

Context

Resolves TE-5843.

Surfaced in TE-5842 while trying to unify two bktec call sites in buildkite/agent:

  • .buildkite/steps/tests.sh uses go tool test-engine-client against v1.6.0 from go.mod.
  • .buildkite/steps/collect-commit-metadata.sh (landed via TE-5828, agent#3924) downloads the v2.5.0 binary from the GitHub release at step time.

Changes

Single commit:

  • [TE-5843] Encode v2 major version in go.mod module path

Verification

Backed by the existing test suite. The internal import rewrite is mechanical (sed-driven) so the diff is large but uniform.

go build ./...
go vet ./...
go test ./...

go build and go vet are clean. go test is clean on every package except internal/runner, which has the same pre-existing local-env failures on main (missing cypress, gotestsum, and cucumber binaries) — not regressions from this change.

AI assisted.

Deployment

Low risk. No behavioural change — only the module identifier and import paths move. The compiled binary is byte-equivalent modulo the internal/version.Version ldflag string, which is rewritten to match the new path in the same change.

Unblocks

  • TE-5842 — bump test-engine-client in buildkite/agent and unify both call sites on go tool once v2.5.1 (or later) is tagged on top of this commit.

Rollback

Yes. Revert the merge; downstream consumers haven't been migrated yet because no v2.x tag exists with the corrected path.

Go's major version suffix rules require modules at v2+ to encode the
major version in the module path. Without the /v2 suffix, v2.x tags are
unfetchable via 'go get' and uninstallable as a 'go tool', so downstream
consumers (e.g. buildkite/agent) have been pinned to v1.6.0 — which
predates the 'plan' subcommand and --collect-git-metadata.

Change module path in go.mod to github.com/buildkite/test-engine-client/v2
and rewrite all internal import paths to match. Also update the version
ldflags path in .goreleaser.yaml so release builds continue to stamp the
version string into internal/version.Version.

Once this lands and a v2.x tag is cut, downstream projects can switch to:

    go get github.com/buildkite/test-engine-client/v2@vX.Y.Z

Unblocks TE-5842 (unify both bktec call sites in buildkite/agent onto
'go tool' against a current v2.x release).
@gchan gchan requested a review from a team as a code owner May 15, 2026 00:46
@gchan gchan mentioned this pull request May 15, 2026
@pda
Copy link
Copy Markdown
Member

pda commented May 15, 2026

@codex review

Copy link
Copy Markdown
Member

@pda pda left a comment

Choose a reason for hiding this comment

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

🚀 assuming Codex review doesn't spot anything unexpected.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@gchan gchan merged commit 0769f86 into main May 15, 2026
3 checks passed
@gchan gchan deleted the te-5843-gomod-v2-module-path branch May 15, 2026 02:55
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