@@ -8,6 +8,13 @@ ifeq ($(BUILD_VERBOSE),1)
8
8
else
9
9
Q = @
10
10
endif
11
+
12
+ # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
13
+ ifeq (,$(shell go env GOBIN) )
14
+ GOBIN =$(shell go env GOPATH) /bin
15
+ else
16
+ GOBIN =$(shell go env GOBIN)
17
+ endif
11
18
12
19
REPO = github.com/operator-framework/api
13
20
BUILD_PATH = $(REPO ) /cmd/operator-verify
@@ -23,7 +30,7 @@ help: ## Show this help screen
23
30
24
31
.PHONY : install
25
32
26
- install : # # Build & install the operator-verify
33
+ install : # # Build & install operator-verify
27
34
28
35
$(Q ) go install \
29
36
-gcflags " all=-trimpath=${GOPATH} " \
@@ -35,22 +42,22 @@ install: ## Build & install the operator-verify
35
42
$(BUILD_PATH )
36
43
37
44
# Code management.
38
- .PHONY : format tidy clean
45
+ .PHONY : format tidy clean vendor generate
39
46
40
47
format : # # Format the source code
41
48
$(Q ) go fmt $(PKGS )
42
49
43
50
tidy : # # Update dependencies
44
51
$(Q ) go mod tidy -v
45
52
53
+ vendor : tidy # # Update vendor directory
54
+ $(Q ) go mod vendor
55
+
46
56
clean : # # Clean up the build artifacts
47
57
$(Q ) rm -rf build
48
58
49
- # #############################
50
- # Tests #
51
- # #############################
52
-
53
- # #@ Tests
59
+ generate : controller-gen # # Generate code
60
+ $(CONTROLLER_GEN ) object:headerFile=./hack/boilerplate.go.txt paths=" ./..."
54
61
55
62
# Static tests.
56
63
.PHONY : test test-unit
@@ -59,4 +66,11 @@ test: test-unit ## Run the tests
59
66
60
67
TEST_PKGS: =$(shell go list ./...)
61
68
test-unit : # # Run the unit tests
62
- $(Q ) go test -short ${TEST_PKGS}
69
+ $(Q ) go test -count=1 -short ${TEST_PKGS}
70
+
71
+ # Utilities.
72
+ .PHONY : controller-gen
73
+
74
+ controller-gen : vendor # # Find or download controller-gen
75
+ CONTROLLER_GEN =$(Q ) go run -mod=vendor ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen
76
+
0 commit comments