Skip to content

build(deps): bump mockery v2.53.6 → v3.7.2 - #9029

Merged
klesh merged 4 commits into
apache:mainfrom
DoDiODev:pr/wave4e-mockery
Aug 12, 2026
Merged

build(deps): bump mockery v2.53.6 → v3.7.2#9029
klesh merged 4 commits into
apache:mainfrom
DoDiODev:pr/wave4e-mockery

Conversation

@DoDiODev

@DoDiODev DoDiODev commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Bumps the mock-generation tool github.com/vektra/mockery from v2.53.6 to
v3.7.2 at every install site (backend/Makefile, backend/Dockerfile,
backend/Dockerfile.local, devops/docker/lake-builder/Dockerfile), and adds
the two YAML configs mockery v3 requires instead of CLI flags.

Current pinning (before this PR) is mockery v2.53.6 (released 2024); v3.7.2 is
a rewrite with a new CLI/config surface (no code-generation logic changes for
the mocks actually used by this repo — see "Behavioral changes" below).

What changed

File Change
backend/Makefile (go-dep, mock) mockery@v2.53.6@v3.7.2; mock target invokes the two new configs in a fixed order
backend/Dockerfile install site v2.53.6v3.7.2
backend/Dockerfile.local ditto
devops/docker/lake-builder/Dockerfile ditto
backend/.mockery.core.yml (new) v3 config for core/ + helpers/pluginhelper/subtaskmeta/sorter, reproducing the v2 layout 1:1
backend/.mockery.helpers.yml (new) v3 config for the remaining helpers/ interfaces
backend/scripts/install-mockery.sh (new) idempotent CI bootstrap for v3.7.2 with architecture-specific SHA-256 verification
.github/workflows/golangci-lint.yml runs the bootstrap before make mock, overriding the stale image's v2 binary via GITHUB_PATH

Why two configs? helpers/unithelper imports the generated
mocks/core/... packages. Unlike v2, v3 loads sources via go/packages
with type-checking, so the core mocks must exist before the helpers
tree is parsed. A single run across both trees fails after rm -rf mocks
with could not import .../mocks/core/... (invalid package name). Both
configs reproduce the v2 layout 1:1 (dir: mocks/{{.InterfaceDirRelative}},
filename: {{.InterfaceName}}.go, pkgname: mocks,
structname: {{.InterfaceName}}, template: testify,
template-data.unroll-variadic: false), so existing imports such as
mockdal "github.com/apache/incubator-devlake/mocks/core/dal" stay valid.

Behavioral changes of v3 (documented for reviewers)

  1. No generated-code churn to review: backend/mocks/ is untracked (see
    .gitignore), so this diff is exactly the 8 files listed above — nothing
    under backend/mocks/ is part of the PR.
  2. Function-type mocking is gone, interfaces only: 13 mocks disappear
    (e.g. plugin.ApiAsyncCallback, plugin.ApiResourceHandler,
    plugin.SubTaskEntryPoint, api.DataConvertHandler,
    api.DsListRemoteScopes, errors.Option). None of them is referenced by
    any test (verified via grep over all *_test.go files). Generated file
    count drops from 77 to 64.
  3. template-data.with-expecter is no longer a valid key: v3 always
    generates EXPECT()-style expectations — purely additive, no test changes
    needed.
  4. CLI flags are gone: --recursive/--keeptree/--dir/--output/--name no
    longer exist; configuration is YAML-only, hence the two new config files.

Validation

CI equivalent (all green): after merging the current upstream/main
(including #9028), the identical job matrix was run in a fork workflow
(fork-ci.yml) on the throwaway ci/wave4e branch —
run 31478068705,
8/8 jobs successful: builder image, lint (go), unit-test, e2e (mysql),
migration-script-lint, config-ui, ASF license header, grafana dashboards.

The bootstrap was also exercised twice in the unmodified published
mericodev/lake-builder:latest image: it replaced mockery v2.20.0 with
v3.7.2, verified the release SHA-256, and the second invocation was a no-op.
A clean rm -rf mocks && make mock then regenerated all 64 mock files.

Additionally, locally on macOS (arm64), against the unmodified
upstream/main toolchain (git2go v33 / libgit2 1.3.x — this PR does not touch
that pairing, see "Out of scope"):

  • make mock — regenerates all 64 mock files cleanly (rm -rf mocks +
    both configs in order)
  • go build ./... — compiles
  • ./scripts/unit-test-go.sh — 64 packages, exit 0, no failures
  • make migration-script-lint

Out of scope on purpose

Rollback

Revert the four version hunks, delete the two .mockery.*.yml files, restore
the mock target's v2 CLI flags. No runtime, schema, or API impact —
backend/mocks/ is generated and untracked either way.

CI compatibility with the stale mericodev/lake-builder:latest image

The lint job (golangci-lint.yml) runs make mock inside the prebuilt
container mericodev/lake-builder:latest. The published image still ships
mockery v2.20.0 (and Go 1.20.4), i.e. it is older than the
devops/docker/lake-builder/Dockerfile in this repo, so the new v3 YAML config
is rejected:

mockery --config .mockery.core.yml
Error: failed to get config: 1 error(s) decoding:
* '' has invalid keys: pkgname, template, template-data
github.com/vektra/mockery/v2@v2.20.0/cmd/mockery.go:164

This PR now bootstraps mockery v3.7.2 in the affected lint job before
make mock. The script verifies the architecture-specific release SHA-256,
installs into /opt/mockery/3.7.2, prepends that directory through
GITHUB_PATH, and is idempotent. The PR is therefore no longer coupled to a
maintainer republish of the image.

Republishing mericodev/lake-builder:latest from the updated Dockerfile is
still the desirable post-merge cleanup, but it is no longer a prerequisite
for this PR's CI.

Upgrade the mock generator from mockery v2.53.6 to v3.7.2 at every install
site (backend/Makefile, backend/Dockerfile, backend/Dockerfile.local,
devops/docker/lake-builder/Dockerfile).

mockery v3 dropped the CLI flags used by the `mock` target and is configured
via YAML instead, so two config files are added:

- backend/.mockery.core.yml
- backend/.mockery.helpers.yml

They reproduce the exact layout produced by the previous v2 invocations
(--recursive --keeptree --dir=./<tree> --output=./mocks/<tree>
--unroll-variadic=false --name='.*'): backend/mocks/<src-dir>/<Interface>.go,
package `mocks`, un-prefixed mock struct names. Existing test imports such as
`mockdal "github.com/apache/incubator-devlake/mocks/core/dal"` therefore keep
working unchanged.

Two configs (instead of one) are required because `helpers/unithelper` imports
the generated `mocks/core/...` packages: unlike v2, v3 type-checks sources via
go/packages, so the core mocks must exist before the helpers tree can be
loaded. The `mock` target runs them in that order.

Note: v3 only generates mocks for interfaces, no longer for function types.
The affected mocks (e.g. plugin.ApiAsyncCallback, api.DataConvertHandler,
errors.Option) were not used by any test. `backend/mocks/` is gitignored, so
there is no generated-code churn in this diff.

Validation: `make mock`, `go build ./...` and `scripts/unit-test-go.sh`
(60 packages) all pass.

Signed-off-by: DoDiODev <DoDiDev@proton.me>
Signed-off-by: DoDiODev <DoDiDev@proton.me>
Signed-off-by: DoDiODev <DoDiDev@proton.me>
Signed-off-by: DoDiODev <DoDiDev@proton.me>

@klesh klesh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM
Thanks for your contribution.

@klesh
klesh merged commit 79b262b into apache:main Aug 12, 2026
10 checks passed
@DoDiODev
DoDiODev deleted the pr/wave4e-mockery branch August 12, 2026 09:01
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