build: move dev tools into per-tool Go modules#20293
Conversation
Move the dev tools (gofumpt, goimports, gotestsum, goyacc, golangci-lint) out of the main module graph into isolated, pinned modules under tools/, invoked via `go tool -modfile=...`. The protoc plugins become tool directives in the main go.mod so that protoc-gen-go and protoc-gen-go-vtproto always build at the same version as the protobuf/vtprotobuf runtime libraries; the install_protoc-gen-go make target is replaced by resolving plugin binaries straight from the Go build cache with `go tool -n`. Every tool stays at exactly the version in use before; goimports gets a go.sum-verified pin for the first time, replacing four ad-hoc `go install` steps in CI. golangci-lint is now pinned in its tool module instead of build.env, and the lint-fmt git hook builds it on demand instead of comparing versions of a PATH-installed binary. protoc-gen-go-grpc becomes an honest direct require at v1.2.0 (the version the Makefile actually installed) instead of the unused v1.6.2 that dependabot had been bumping. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
There was a problem hiding this comment.
Pull request overview
This PR restructures Vitess developer tooling dependencies so they no longer participate in (or get influenced by) the main module’s dependency graph, while keeping tool versions pinned and reproducible across local dev and CI.
Changes:
- Moved several dev tools (gofumpt, goimports, gotestsum, goyacc, golangci-lint) into dedicated
tools/<tool>/Go modules and updated scripts/Make targets to run them viago tool -modfile=.... - Replaced the legacy
tools/tools.go“tools” pattern by usingtooldirectives in the rootgo.modfor protoc plugins, and adjustedmake prototo locate plugin binaries viago tool -n. - Updated CI caching, change detection, tidy checks, and Dependabot configuration to account for the new tool modules.
Reviewed changes
Copilot reviewed 22 out of 28 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tools/unit_test_runner.sh | Runs gotestsum via the pinned tool-module modfile. |
| tools/e2e_go_test.sh | Runs gotestsum via the pinned tool-module modfile for e2e harness. |
| tools/check_make_parser.sh | Switches parser regeneration checks to pinned goyacc/goimports/gofumpt tool modules. |
| misc/git/hooks/lint-fmt | Runs golangci-lint via pinned tool-module modfile instead of $PATH/version checks. |
| Makefile | Uses pinned tool modules for lint/format; removes install target for protoc plugins and resolves them via go tool -n. |
| go/vt/vtctl/vtctldclient/Makefile | Formats generated client code via pinned gofumpt modfile. |
| go/vt/sqlparser/generate.go | Updates go:generate directives to use pinned tool-module modfiles. |
| go/tools/codegen/goimports.go | Executes goimports/gofumpt via go tool -modfile=... using repo-root resolution. |
| tools/tools.go | Removes the legacy “tools” build-tag file that pinned tool deps in the main module graph. |
| tools/gofumpt/go.mod | Adds a dedicated Go module to pin gofumpt as a tool. |
| tools/gofumpt/go.sum | Checksums for the pinned gofumpt tool module. |
| tools/goimports/go.mod | Adds a dedicated Go module to pin goimports as a tool. |
| tools/goimports/go.sum | Checksums for the pinned goimports tool module. |
| tools/gotestsum/go.mod | Adds a dedicated Go module to pin gotestsum as a tool. |
| tools/gotestsum/go.sum | Checksums for the pinned gotestsum tool module. |
| tools/goyacc/go.mod | Adds a dedicated Go module to pin goyacc as a tool. |
| tools/goyacc/go.sum | Checksums for the pinned goyacc tool module. |
| tools/golangci-lint/go.mod | Adds a dedicated Go module to pin golangci-lint as a tool. |
| tools/golangci-lint/go.sum | Checksums for the pinned golangci-lint tool module. |
| go.mod | Replaces tool pinning approach: removes tool pins for formatting/testing tools; adds tool directives for protoc plugins and pins protoc-gen-go-grpc. |
| go.sum | Drops now-unneeded tool-related sums from the main module; updates sums for the new root requirements. |
| build.env | Removes golangci-lint version export since lint version is now pinned by tool module. |
| .github/workflows/unit_test.yml | Updates Go cache dependency paths; removes ad-hoc goimports install; uses pinned gotestsum modfile. |
| .github/workflows/static_checks_etc.yml | Expands change filters and cache deps for tool modules; runs go mod tidy across tool modules; derives golangci-lint version from tool module. |
| .github/workflows/codecov.yml | Updates Go cache dependency paths; removes ad-hoc goimports install. |
| .github/workflows/check_make_vtadmin_authz_testgen.yml | Updates Go cache dependency paths; removes ad-hoc goimports install. |
| .github/dependabot.yml | Adds separate update groups for tool modules; ignores protoc-gen-go-grpc auto-bumps. |
| .github/actions/setup-go/action.yml | Includes tools/**/go.sum in Go cache key hashing to avoid stale caches. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #20293 +/- ##
===========================================
- Coverage 69.67% 56.26% -13.41%
===========================================
Files 1614 46 -1568
Lines 216793 14176 -202617
===========================================
- Hits 151044 7976 -143068
+ Misses 65749 6200 -59549
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The hook passes every directory with staged .go files to a single golangci-lint run in the main module. Files in nested Go modules (e.g. test/antithesis) make that run fail with a typechecking error, aborting the commit even when there are no lint findings. Filter the changed packages down to those whose nearest go.mod is the repo root's, and print a notice for skipped directories. CI doesn't lint nested modules either, so this matches existing coverage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
Add tools/check_license_headers.sh, which checks that every tracked Go file carries a license header, and run it from the static checks workflow. Generated files (marked with "DO NOT EDIT") are skipped. The check uses github.com/google/addlicense, pinned as a per-tool Go module under tools/addlicense following the layout from #20293. addlicense accepts any existing copyright notice, so files derived from third-party code keep their original attribution. Backfill headers for the 90 Go files that were missing one: - the standard Vitess header for hand-written files - the dual Vitess/Yiling-J header for the go/cache/theine files, matching their package siblings - the upstream "Code generated" marker for two collation data tables copied from golang.org/x/text, rather than inventing a copyright Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Arthur Schreiber <arthur@planetscale.com>
#20298) Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Arthur Schreiber <arthur@planetscale.com>
#20296) Signed-off-by: Arthur Schreiber <arthur@planetscale.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Arthur Schreiber <arthur@planetscale.com>
Description
This moves our dev tools out of the main module graph so tool dependencies can't influence application dependency resolution (and vice versa):
tools/, invoked viago tool -modfile=.... Everything stays at exactly the version we use today, so this is pure plumbing — no reformatting or lint fallout.protoc-gen-go,protoc-gen-go-grpc,protoc-gen-go-vtproto) becometooldirectives in the maingo.mod. The first and last are packages inside the protobuf/vtprotobuf runtime modules, so the generated code can no longer drift from the runtime libraries — same require line. Theinstall_protoc-gen-gomake target is gone;make protoresolves the plugin binaries straight out of the Go build cache withgo tool -n.Some inconsistencies this cleans up along the way:
go.sum-verified pin. Now it does, and the install steps are deleted —go/tools/codegenresolves the formatters via their modfiles instead of$PATH.protoc-gen-go-grpcsat in the maingo.modat v1.6.2 (kept alive bytools/tools.go, dutifully bumped by dependabot) while the Makefile hardcoded@v1.2.0. It's now an honest require at v1.2.0 with a dependabot ignore, since bumping it changes the generated API and needs to be a conscious decision.lint-fmtgit hook no longer version-compares a$PATH-installed golangci-lint againstbuild.env—go toolbuilds the pinned version on demand. That also fixes the hook accepting a newer local lint version than CI uses.A nice property for git worktrees: all tool resolution is anchored to the current checkout (relative
-modfilepaths,go env GOMODin the codegen wrapper,git rev-parse --show-toplevelin the hook), so each worktree uses its owntools/*/go.modat its own commit — a worktree on an older release branch automatically gets that branch's pinned tool versions. With$PATH-installed tools that was never guaranteed. The module and build caches stay per-user, so a given tool version is still only downloaded and compiled once across all worktrees.CI changes: the tidy check now covers the tool modules, the
go_filesfilter triggers on tool-module changes, and the Go caches hashtools/**/go.sumtoo. Dependabot bumps the light tools as a group and golangci-lint in its own PR (lint bumps can change findings).Verified that proto, sqlparser, sizegen, and vtctldclient regeneration all produce byte-identical output, including
make protofrom a clean build cache.Related Issue(s)
N/A
Checklist
Deployment Notes
N/A — developer tooling and CI only, no runtime changes.
Backporting
I'd like to backport this to
release-23.0andrelease-24.0, because it's a significant QoL improvement when switching between branches / working on backports.AI Disclosure
This PR was written primarily by Claude Code — I provided direction and review.
🤖 Generated with Claude Code