@@ -36,12 +36,13 @@ export GO111MODULE=on
36
36
37
37
# Tools.
38
38
TOOLS_DIR := hack/tools
39
- TOOLS_BIN_DIR := $(TOOLS_DIR ) /bin
39
+ TOOLS_BIN_DIR := $(abspath $( TOOLS_DIR ) /bin)
40
40
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR ) /golangci-lint)
41
41
GO_APIDIFF := $(TOOLS_BIN_DIR ) /go-apidiff
42
42
CONTROLLER_GEN := $(TOOLS_BIN_DIR ) /controller-gen
43
43
ENVTEST_DIR := $(abspath tools/setup-envtest)
44
44
SCRATCH_ENV_DIR := $(abspath examples/scratch-env)
45
+ GO_INSTALL := ./hack/go-install.sh
45
46
46
47
# The help will print out all targets with their descriptions organized bellow their categories. The categories are represented by `##@` and the target descriptions by `##`.
47
48
# The awk commands is responsible to read the entire set of makefiles included in this invocation, looking for lines of the file as xyz: ## something, and then pretty-format the target and help. Then, if there's a line with ##@ something, that gets pretty-printed as a category.
@@ -67,16 +68,29 @@ test-tools: ## tests the tools codebase (setup-envtest)
67
68
# # Binaries
68
69
# # --------------------------------------
69
70
70
- $(GO_APIDIFF ) : $(TOOLS_DIR ) /go.mod # Build go-apidiff from tools folder.
71
- cd $(TOOLS_DIR ) && go build -tags=tools -o bin/go-apidiff github.com/joelanford/go-apidiff
71
+ GO_APIDIFF_VER := v0.8.2
72
+ GO_APIDIFF_BIN := go-apidiff
73
+ GO_APIDIFF := $(abspath $(TOOLS_BIN_DIR ) /$(GO_APIDIFF_BIN ) -$(GO_APIDIFF_VER ) )
74
+ GO_APIDIFF_PKG := github.com/joelanford/go-apidiff
72
75
73
- $(CONTROLLER_GEN ) : $( TOOLS_DIR ) /go.mod # Build controller-gen from tools folder.
74
- cd $(TOOLS_DIR ) && go build -tags=tools -o bin/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen
76
+ $(GO_APIDIFF ) : # Build go-apidiff from tools folder.
77
+ GOBIN= $( TOOLS_BIN_DIR ) $(GO_INSTALL ) $( GO_APIDIFF_PKG ) $( GO_APIDIFF_BIN ) $( GO_APIDIFF_VER )
75
78
76
- $(GOLANGCI_LINT ) : .github/workflows/golangci-lint.yml # Download golanci-lint using hack script into tools folder.
77
- hack/ensure-golangci-lint.sh \
78
- -b $(TOOLS_BIN_DIR ) \
79
- $(shell cat .github/workflows/golangci-lint.yml | grep "version: v" | sed 's/.* version: //')
79
+ CONTROLLER_GEN_VER := v0.14.0
80
+ CONTROLLER_GEN_BIN := controller-gen
81
+ CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR ) /$(CONTROLLER_GEN_BIN ) -$(CONTROLLER_GEN_VER ) )
82
+ CONTROLLER_GEN_PKG := sigs.k8s.io/controller-tools/cmd/controller-gen
83
+
84
+ $(CONTROLLER_GEN ) : # Build controller-gen from tools folder.
85
+ GOBIN=$(TOOLS_BIN_DIR ) $(GO_INSTALL ) $(CONTROLLER_GEN_PKG ) $(CONTROLLER_GEN_BIN ) $(CONTROLLER_GEN_VER )
86
+
87
+ GOLANGCI_LINT_BIN := golangci-lint
88
+ GOLANGCI_LINT_VER := $(shell cat .github/workflows/golangci-lint.yml | grep [[:space:]]version: | sed 's/.* version: //')
89
+ GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR ) /$(GOLANGCI_LINT_BIN ) -$(GOLANGCI_LINT_VER ) )
90
+ GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
91
+
92
+ $(GOLANGCI_LINT ) : # Build golangci-lint from tools folder.
93
+ GOBIN=$(TOOLS_BIN_DIR ) $(GO_INSTALL ) $(GOLANGCI_LINT_PKG ) $(GOLANGCI_LINT_BIN ) $(GOLANGCI_LINT_VER )
80
94
81
95
# # --------------------------------------
82
96
# # Linting
@@ -126,6 +140,12 @@ verify-modules: modules ## Verify go modules are up to date
126
140
echo " go module files are out of date, please run 'make modules'" ; exit 1; \
127
141
fi
128
142
143
+ APIDIFF_OLD_COMMIT ?= $(shell git rev-parse origin/main)
144
+
145
+ .PHONY : apidiff
146
+ verify-apidiff : $(GO_APIDIFF ) # # Check for API differences
147
+ $(GO_APIDIFF ) $(APIDIFF_OLD_COMMIT ) --print-compatible
148
+
129
149
.PHONY : verify-generate
130
150
verify-generate : generate # # Verify generated files are up to date
131
151
@if ! (git diff --quiet HEAD); then \
0 commit comments