Skip to content

Commit 859dc1c

Browse files
committed
Add scripts to generate Go mock files to Makefile
Signed-off-by: tenzen-y <[email protected]>
1 parent 68ecb1c commit 859dc1c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Makefile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ HAS_LINT := $(shell command -v golangci-lint;)
22
HAS_YAMLLINT := $(shell command -v yamllint;)
33
HAS_SHELLCHECK := $(shell command -v shellcheck;)
44
HAS_SETUP_ENVTEST := $(shell command -v setup-envtest;)
5+
HAS_MOCKGEN := $(shell command -v mockgen;)
56

67
COMMIT := v1beta1-$(shell git rev-parse --short=7 HEAD)
78
KATIB_REGISTRY := docker.io/kubeflowkatib
89
CPU_ARCH ?= amd64
910
ENVTEST_K8S_VERSION ?= 1.24
11+
MOCKGEN_VERSION ?= $(shell grep 'github.com/golang/mock' go.mod | cut -d ' ' -f 2)
1012

1113
# for pytest
1214
PYTHONPATH := $(PYTHONPATH):$(CURDIR)/pkg/apis/manager/v1beta1/python:$(CURDIR)/pkg/apis/manager/health/python
@@ -21,9 +23,9 @@ test: envtest
2123
envtest:
2224
ifndef HAS_SETUP_ENVTEST
2325
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@c7a98aa706379c4e5c79ea675c7f333192677971 # v0.12.3
24-
@echo "setup-envtest has been installed"
26+
$(info "setup-envtest has been installed")
2527
endif
26-
@echo "setup-envtest has already installed"
28+
$(info "setup-envtest has already installed")
2729

2830
check: generate fmt vet lint
2931

@@ -33,14 +35,14 @@ fmt:
3335
lint:
3436
ifndef HAS_LINT
3537
go install github.com/golangci/golangci-lint/cmd/[email protected]
36-
@echo "golangci-lint has been installed"
38+
$(info "golangci-lint has been installed")
3739
endif
3840
hack/verify-golangci-lint.sh
3941

4042
yamllint:
4143
ifndef HAS_YAMLLINT
4244
pip install yamllint
43-
@echo "yamllint has been installed"
45+
$(info "yamllint has been installed")
4446
endif
4547
hack/verify-yamllint.sh
4648

@@ -50,7 +52,7 @@ vet:
5052
shellcheck:
5153
ifndef HAS_SHELLCHECK
5254
bash hack/install-shellcheck.sh
53-
@echo "shellcheck has been installed"
55+
$(info "shellcheck has been installed")
5456
endif
5557
hack/verify-shellcheck.sh
5658

@@ -66,18 +68,24 @@ undeploy:
6668
bash scripts/v1beta1/undeploy.sh
6769

6870
# Run this if you update any existing controller APIs.
69-
# 1. Genereate deepcopy, clientset, listers, informers for the APIs (hack/update-codegen.sh)
71+
# 1. Generate deepcopy, clientset, listers, informers for the APIs (hack/update-codegen.sh)
7072
# 2. Generate open-api for the APIs (hack/update-openapigen)
7173
# 3. Generate Python SDK for Katib (hack/gen-python-sdk/gen-sdk.sh)
7274
# 4. Generate gRPC manager APIs (pkg/apis/manager/v1beta1/build.sh and pkg/apis/manager/health/build.sh)
75+
# 5. Generate Go mock codes
7376
generate:
7477
ifndef GOPATH
7578
$(error GOPATH not defined, please define GOPATH. Run "go help gopath" to learn more about GOPATH)
79+
endif
80+
ifndef HAS_MOCKGEN
81+
go install github.com/golang/mock/mockgen@$(MOCKGEN_VERSION)
82+
$(info "mockgen has been installed")
7683
endif
7784
go generate ./pkg/... ./cmd/...
7885
hack/gen-python-sdk/gen-sdk.sh
7986
pkg/apis/manager/v1beta1/build.sh
8087
pkg/apis/manager/health/build.sh
88+
hack/update-mockgen.sh
8189

8290
# Build images for the Katib v1beta1 components.
8391
build: generate

0 commit comments

Comments
 (0)