Skip to content

build(mocks): Generate mocks with the pinned mockgen and check them in CI - #849

Merged
behinddwalls merged 1 commit into
mainfrom
manjari/pin-mockgen
Oct 14, 2026
Merged

behinddwalls merged 1 commit into
mainfrom
manjari/pin-mockgen

Conversation

@manjari25

Copy link
Copy Markdown
Contributor

Why?

make mocks resolved mockgen from PATH, and nothing in the repo pinned or documented which one to use. On a machine with a different mockgen (for example the older github.com/golang/mock binary), it rewrote every checked-in mock with no real changes and failed on generic interfaces such as stovepipe/extension/sourcecontrol. The contributor then had to work out which of the changed files mattered.

CI also never ran make check-mocks, so a PR that changed an interface without regenerating its mock was only caught if a test happened to use the stale mock.

What?

  • make mocks builds the mockgen pinned in go.mod through Bazel (@org_uber_go_mock//mockgen), copies it to the git-ignored bin/mockgen/, and puts it first on PATH for the go generate run. No local install is needed, and the //go:generate directives are unchanged.
  • The Tidy CI job runs make check-mocks, so stale mocks fail the required checks.
  • doc/howto/DEVELOPMENT.md notes both behaviors.

Test Plan

On a machine where the mockgen on PATH is not the pinned one (this was verified on one such machine):

  1. Run make mocks and check that it completes and git status is clean.
  2. Run make check-mocks, make lint, make check-gazelle, and make check-tidy on the committed branch. All pass.

The new CI step hasn't run on GitHub yet, so this PR's Tidy job is its first run.

Issue

@manjari25
manjari25 requested review from a team and sbalabanov as code owners October 13, 2026 19:17
@behinddwalls
behinddwalls added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit 6d4a25f Oct 14, 2026
21 checks passed
@behinddwalls
behinddwalls deleted the manjari/pin-mockgen branch October 14, 2026 19:58
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