@@ -2,11 +2,14 @@ HAS_LINT := $(shell command -v golangci-lint;)
2
2
HAS_YAMLLINT := $(shell command -v yamllint;)
3
3
HAS_SHELLCHECK := $(shell command -v shellcheck;)
4
4
HAS_SETUP_ENVTEST := $(shell command -v setup-envtest;)
5
+ HAS_MOCKGEN := $(shell command -v mockgen;)
5
6
6
7
COMMIT := v1beta1-$(shell git rev-parse --short=7 HEAD)
7
8
KATIB_REGISTRY := docker.io/kubeflowkatib
8
9
CPU_ARCH ?= amd64
9
10
ENVTEST_K8S_VERSION ?= 1.25
11
+ MOCKGEN_VERSION ?= $(shell grep 'github.com/golang/mock' go.mod | cut -d ' ' -f 2)
12
+ GO_VERSION =$(shell grep '^go' go.mod | cut -d ' ' -f 2)
10
13
11
14
# for pytest
12
15
PYTHONPATH := $(PYTHONPATH ) :$(CURDIR ) /pkg/apis/manager/v1beta1/python:$(CURDIR ) /pkg/apis/manager/health/python
@@ -21,26 +24,26 @@ test: envtest
21
24
envtest :
22
25
ifndef HAS_SETUP_ENVTEST
23
26
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@2c3a6fa2996c026b284c7fe2b055274cd9a556bc # v0.13.0
24
- @echo "setup-envtest has been installed"
27
+ $(info "setup-envtest has been installed")
25
28
endif
26
- @echo "setup-envtest has already installed"
29
+ $(info "setup-envtest has already installed")
27
30
28
- check : generate fmt vet lint
31
+ check : generated-codes go-mod fmt vet lint
29
32
30
33
fmt :
31
34
hack/verify-gofmt.sh
32
35
33
36
lint :
34
37
ifndef HAS_LINT
35
38
go install github.com/golangci/golangci-lint/cmd/
[email protected]
36
- @echo "golangci-lint has been installed"
39
+ $(info "golangci-lint has been installed")
37
40
endif
38
41
hack/verify-golangci-lint.sh
39
42
40
43
yamllint :
41
44
ifndef HAS_YAMLLINT
42
45
pip install yamllint
43
- @echo "yamllint has been installed"
46
+ $(info "yamllint has been installed")
44
47
endif
45
48
hack/verify-yamllint.sh
46
49
50
53
shellcheck :
51
54
ifndef HAS_SHELLCHECK
52
55
bash hack/install-shellcheck.sh
53
- @echo "shellcheck has been installed"
56
+ $(info "shellcheck has been installed")
54
57
endif
55
58
hack/verify-shellcheck.sh
56
59
@@ -65,19 +68,38 @@ deploy:
65
68
undeploy :
66
69
bash scripts/v1beta1/undeploy.sh
67
70
71
+ generated-codes : generate
72
+ ifneq ($(shell bash hack/verify-generated-codes.sh '.'; echo $$? ) ,0)
73
+ $(error 'Please run "make generate" to generate codes')
74
+ endif
75
+
76
+ go-mod : sync-go-mod
77
+ ifneq ($(shell bash hack/verify-generated-codes.sh 'go.* '; echo $$? ) ,0)
78
+ $(error 'Please run "go mod tidy -go $(GO_VERSION)" to sync Go modules')
79
+ endif
80
+
81
+ sync-go-mod :
82
+ go mod tidy -go $(GO_VERSION )
83
+
68
84
# Run this if you update any existing controller APIs.
69
- # 1. Genereate deepcopy, clientset, listers, informers for the APIs (hack/update-codegen.sh)
85
+ # 1. Generate deepcopy, clientset, listers, informers for the APIs (hack/update-codegen.sh)
70
86
# 2. Generate open-api for the APIs (hack/update-openapigen)
71
87
# 3. Generate Python SDK for Katib (hack/gen-python-sdk/gen-sdk.sh)
72
88
# 4. Generate gRPC manager APIs (pkg/apis/manager/v1beta1/build.sh and pkg/apis/manager/health/build.sh)
89
+ # 5. Generate Go mock codes
73
90
generate :
74
91
ifndef GOPATH
75
92
$(error GOPATH not defined, please define GOPATH. Run "go help gopath" to learn more about GOPATH)
93
+ endif
94
+ ifndef HAS_MOCKGEN
95
+ go install github.com/golang/mock/mockgen@$(MOCKGEN_VERSION)
96
+ $(info "mockgen has been installed")
76
97
endif
77
98
go generate ./pkg/... ./cmd/...
78
99
hack/gen-python-sdk/gen-sdk.sh
79
100
pkg/apis/manager/v1beta1/build.sh
80
101
pkg/apis/manager/health/build.sh
102
+ hack/update-mockgen.sh
81
103
82
104
# Build images for the Katib v1beta1 components.
83
105
build : generate
0 commit comments