Skip to content

mocks: Speed up generation of mock interfaces

Administrator requested to merge ef/go-mockgen-manifest into main

Created by: efritz

Changes:

  • Move all mockgen invocations into a separate file.
  • Remove each such file with a manifest file for go-mockgen (one parse of the project instead of 75)
  • Do not pass import paths that do not contains a //go:generate directive

On this branch:

$ time go run ./dev/sg --verbose generate
👉 Running target "go" (Run go generate [packages...] on the codebase)
Generating dev/adr-docs...
Generating dev/sg...
Generating dev/team...
Generating enterprise/dev/ci...
Generating enterprise/internal/batches/search/syntax...
Generating internal/database...
Generating monitoring...
Generating schema...
ℹ️ go generate ./... (excluding doc/cli/references)
✅ Target "go" done (0s)
go run ./dev/sg --verbose generate  16.54s user 13.93s system 152% cpu 20.002 total

On main:

$ time go run ./dev/sg --verbose generate
👉 Running target "go" (Run go generate [packages...] on the codebase)
Generating cmd/frontend...
Generating cmd/frontend/auth...
Generating cmd/frontend/auth/providers...
Generating cmd/frontend/backend...
Generating cmd/frontend/enterprise...

< ... clipped ... >

Generating monitoring/definitions/shared...
Generating monitoring/monitoring...
Generating monitoring/monitoring/internal/grafana...
Generating schema...
Generating ui/assets...
✅ 500/501 packages generated  █████████████████████████████████████████████████████████████████████████████████████████
ℹ️ go generate ./... (excluding doc/cli/references)
ℹ️ goimports -w
ℹ️ go mod tidy
✅ Target "go" done (72s)
go run ./dev/sg --verbose generate  83.90s user 125.90s system 279% cpu 1:15.16 total

Test plan

Tested by hand.

Merge request reports

Loading