@@ -12,6 +12,13 @@ GOARCH ?= amd64
12
12
# golang global flags
13
13
GO_FLAGS ?= -v -mod=vendor
14
14
15
+ # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
16
+ ifeq (,$(shell go env GOBIN) )
17
+ GOBIN =$(shell go env GOPATH) /bin
18
+ else
19
+ GOBIN =$(shell go env GOBIN)
20
+ endif
21
+
15
22
# configure zap based logr
16
23
ZAP_FLAGS ?= --zap-level=debug --zap-encoder=console
17
24
# extra flags passed to operator-sdk
@@ -108,25 +115,51 @@ verify-codegen: generate
108
115
# TODO: Verify vendor tree is accurate
109
116
git diff --quiet -- ' :(exclude)go.mod' ' :(exclude)go.sum' ' :(exclude)vendor/*'
110
117
111
- install-ginkgo :
112
- go get -u github.com/onsi/ginkgo/ginkgo
113
- go get -u github.com/onsi/gomega/...
114
- ginkgo version
115
-
116
- install-gocov :
117
- cd && GO111MODULE=on go get github.com/axw/gocov/
[email protected]
118
+ ginkgo :
119
+ ifeq (, $(shell which ginkgo) )
120
+ @{ \
121
+ set -e ;\
122
+ GINKGO_GEN_TMP_DIR=$$(mktemp -d) ;\
123
+ cd $$GINKGO_GEN_TMP_DIR ;\
124
+ go mod init tmp ;\
125
+ go get -u github.com/onsi/ginkgo/ginkgo ;\
126
+ go get -u github.com/onsi/gomega/... ;\
127
+ rm -rf $$GINKGO_GEN_TMP_DIR ;\
128
+ }
129
+ GINKGO =$(GOBIN ) /ginkgo
130
+ else
131
+ GINKGO =$(shell which ginkgo)
132
+ endif
133
+
134
+ gocov :
135
+ ifeq (, $(shell which gocov) )
136
+ @{ \
137
+ set -e ;\
138
+ GOCOV_GEN_TMP_DIR=$$(mktemp -d) ;\
139
+ cd $$GOCOV_GEN_TMP_DIR ;\
140
+ go mod init tmp ;\
141
+ go get github.com/axw/gocov/
[email protected] ;\
142
+ rm -rf $$GOCOV_GEN_TMP_DIR ;\
143
+ }
144
+ GOCOV =$(GOBIN ) /gocov
145
+ else
146
+ GOCOV =$(shell which gocov)
147
+ endif
118
148
119
149
install-counterfeiter :
120
150
hack/install-counterfeiter.sh
121
151
152
+ install-operator-sdk :
153
+ hack/install-operator-sdk.sh
154
+
122
155
# https://github.com/shipwright-io/build/issues/123
123
156
test : test-unit
124
157
125
158
.PHONY : test-unit
126
- test-unit :
159
+ test-unit : ginkgo
127
160
rm -rf build/coverage
128
161
mkdir build/coverage
129
- GO111MODULE=on ginkgo \
162
+ GO111MODULE=on $( GINKGO ) \
130
163
-randomizeAllSpecs \
131
164
-randomizeSuites \
132
165
-failOnPending \
@@ -140,16 +173,16 @@ test-unit:
140
173
internal/... \
141
174
pkg/...
142
175
143
- test-unit-coverage : test-unit
176
+ test-unit-coverage : test-unit gocov
144
177
echo " Combining coverage profiles"
145
178
cat build/coverage/* .coverprofile | sed -E ' s/([0-9])github.com/\1\ngithub.com/g' | sed -E ' s/([0-9])mode: atomic/\1/g' > build/coverage/coverprofile
146
- gocov convert build/coverage/coverprofile > build/coverage/coverprofile.json
147
- gocov report build/coverage/coverprofile.json
179
+ $( GOCOV ) convert build/coverage/coverprofile > build/coverage/coverprofile.json
180
+ $( GOCOV ) report build/coverage/coverprofile.json
148
181
149
182
# Based on https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/integration-tests.md
150
183
.PHONY : test-integration
151
- test-integration : install-apis
152
- GO111MODULE=on ginkgo \
184
+ test-integration : install-apis ginkgo
185
+ GO111MODULE=on $( GINKGO ) \
153
186
-randomizeAllSpecs \
154
187
-randomizeSuites \
155
188
-failOnPending \
@@ -163,7 +196,7 @@ test-integration: install-apis
163
196
test-e2e : install-strategies test-e2e-plain
164
197
165
198
.PHONY : test-e2e-plain
166
- test-e2e-plain :
199
+ test-e2e-plain : ginkgo
167
200
GO111MODULE=on \
168
201
TEST_OPERATOR_NAMESPACE=${TEST_NAMESPACE} \
169
202
TEST_WATCH_NAMESPACE=${TEST_NAMESPACE} \
@@ -172,7 +205,7 @@ test-e2e-plain:
172
205
TEST_E2E_SERVICEACCOUNT_NAME=${TEST_E2E_SERVICEACCOUNT_NAME} \
173
206
TEST_E2E_TIMEOUT_MULTIPLIER=${TEST_E2E_TIMEOUT_MULTIPLIER} \
174
207
TEST_E2E_VERIFY_TEKTONOBJECTS=${TEST_E2E_VERIFY_TEKTONOBJECTS} \
175
- ginkgo ${TEST_E2E_FLAGS} test/e2e
208
+ $( GINKGO ) ${TEST_E2E_FLAGS} test/e2e
176
209
177
210
.PHONY : install install-apis install-operator install-strategies
178
211
@@ -208,10 +241,13 @@ kubectl:
208
241
kind-registry :
209
242
./hack/install-registry.sh
210
243
244
+ kind-tekton :
245
+ ./hack/install-tekton.sh
246
+
211
247
kind :
212
248
./hack/install-kind.sh
213
249
./hack/install-registry.sh
214
250
215
- travis : install-counterfeiter install- ginkgo install- gocov kubectl kind
251
+ travis : install-counterfeiter ginkgo gocov kubectl kind
216
252
./hack/install-tekton.sh
217
253
./hack/install-operator-sdk.sh
0 commit comments