This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 452029899 build(backend): pin mockery in one place and resolve it via
go run (#9180)
452029899 is described below
commit 452029899c74502f83370b69698c6a5f5287e7e0
Author: Dirk <[email protected]>
AuthorDate: Sun Oct 4 12:14:08 2026 +0200
build(backend): pin mockery in one place and resolve it via go run (#9180)
`backend/Dockerfile` still installed mockery v3.7.2 while the Makefile,
`Dockerfile.local` and `scripts/install-mockery.sh` (used by CI) are on
v3.7.4, so the generated mocks depended on which build path was used.
- Bump the `backend/Dockerfile` pin to v3.7.4.
- Introduce `MOCKERY_VERSION` (default v3.7.4) and
`MOCKERY ?= GOOS= GOARCH= CGO_ENABLED=0 go run
github.com/vektra/mockery/v3@$(MOCKERY_VERSION)` in the Makefile;
`make mock` and `make go-dep` use them. `make mock` thus no longer
depends on whatever `mockery` is on the PATH (the CI builder image
`mericodev/lake-builder:latest` ships mockery v2, which cannot read the
v3 YAML configuration). GOOS/GOARCH are cleared so the tool is built for
the host even when `backend/Dockerfile` cross-compiles `make all`.
`MOCKERY=mockery make mock` keeps the old behaviour.
---
backend/Dockerfile | 2 +-
backend/Makefile | 14 +++++++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/backend/Dockerfile b/backend/Dockerfile
index 19ab59a2b..219e29c6f 100644
--- a/backend/Dockerfile
+++ b/backend/Dockerfile
@@ -49,7 +49,7 @@ RUN if [ "$(arch)" != "x86_64" ] ; then \
apt-get install -y gcc-x86-64-linux-gnu binutils-x86-64-linux-gnu ; \
fi
-RUN go install github.com/vektra/mockery/[email protected]
+RUN go install github.com/vektra/mockery/[email protected]
RUN go install github.com/swaggo/swag/cmd/[email protected]
COPY --from=debian-amd64 /usr/include /rootfs-amd64/usr/include
diff --git a/backend/Makefile b/backend/Makefile
index e5aa539d5..d721309d3 100644
--- a/backend/Makefile
+++ b/backend/Makefile
@@ -22,12 +22,20 @@ TAG ?= $(shell if [ -d .git ]; then git tag --points-at
HEAD; else echo "local_b
IMAGE_REPO ?= "apache"
VERSION = $(TAG)@$(SHA)
PYTHON_DIR ?= "./python"
+MOCKERY_VERSION ?= v3.7.4
+# Always resolve mockery through the module cache instead of relying on
whatever
+# `mockery` happens to be on the PATH: the CI builder image ships mockery v2,
+# which cannot read the v3 YAML configuration.
+# The tool must be built for the host, not for the cross-compile target that
+# `backend/Dockerfile` exports (GOARCH/CC for `make all`), hence the empty
+# GOOS/GOARCH and CGO_ENABLED=0.
+MOCKERY ?= GOOS= GOARCH= CGO_ENABLED=0 go run
github.com/vektra/mockery/v3@$(MOCKERY_VERSION)
all: build
go-dep:
- go install github.com/vektra/mockery/[email protected]
+ go install github.com/vektra/mockery/v3@$(MOCKERY_VERSION)
go install github.com/swaggo/swag/cmd/[email protected]
go install
github.com/golangci/golangci-lint/v2/cmd/[email protected]
@@ -77,8 +85,8 @@ mock:
# required (and must run in this order): `helpers/unithelper` imports
the
# generated `mocks/core/...` packages, and v3 type-checks the sources it
# parses, so the core mocks have to exist before the helpers tree loads.
- mockery --config .mockery.core.yml
- mockery --config .mockery.helpers.yml
+ $(MOCKERY) --config .mockery.core.yml
+ $(MOCKERY) --config .mockery.helpers.yml
test: unit-test e2e-test