forked from bsteciuk/kismatic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
387 lines (335 loc) · 15.8 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# Setup some useful vars
PKG = github.com/apprenda/kismatic
BUILD_OUTPUT = out-$(GOOS)
# Set the build version
ifeq ($(origin VERSION), undefined)
VERSION := $(shell git describe --tags --always --dirty)
endif
# Set the build branch
ifeq ($(origin BRANCH), undefined)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
endif
# build date
ifeq ($(origin BUILD_DATE), undefined)
BUILD_DATE := $(shell date -u)
endif
# If no target is defined, assume the host is the target.
ifeq ($(origin GOOS), undefined)
GOOS := $(shell go env GOOS)
endif
# Lots of these target goarches probably won't work,
# since we depend on vendored packages also being built for the correct arch
ifeq ($(origin GOARCH), undefined)
GOARCH := $(shell go env GOARCH)
endif
# If no target is defined, assume the host is the target.
ifeq ($(origin HOST_GOOS), undefined)
HOST_GOOS := $(shell go env GOOS)
endif
# Lots of these target goarches probably won't work,
# since we depend on vendored packages also being built for the correct arch
ifeq ($(origin HOST_GOARCH), undefined)
HOST_GOARCH := $(shell go env GOARCH)
endif
# Used by the integration tests to tag nodes
ifeq ($(origin CREATED_BY), undefined)
CREATED_BY := $(shell hostname)
endif
# Versions of external dependencies
GLIDE_VERSION = v0.13.1
ANSIBLE_VERSION = 2.3.0.0
PROVISIONER_VERSION = v1.13.0
KUBERANG_VERSION = v1.3.0
GO_VERSION = 1.10.3
KUBECTL_VERSION = v1.10.5
HELM_VERSION = v2.9.1
install:
@echo Building kismatic in container
@docker run \
--rm \
-e GOOS="$(GOOS)" \
-e HOST_GOOS="linux" \
-e VERSION="$(VERSION)" \
-e BUILD_DATE="$(BUILD_DATE)" \
-u root:root \
-v "$(shell pwd)":"/go/src/$(PKG)" \
-w /go/src/$(PKG) \
circleci/golang:$(GO_VERSION) \
make bin/$(GOOS)/kismatic build-inspector-host copy-kismatic copy-playbooks copy-inspector
dist: shallow-clean
@echo "Running dist inside contianer"
@docker run \
--rm \
-e GOOS="$(GOOS)" \
-e HOST_GOOS="linux" \
-e VERSION="$(VERSION)" \
-e BUILD_DATE="$(BUILD_DATE)" \
-u root:root \
-v "$(shell pwd)":"/go/src/$(PKG)" \
-w "/go/src/$(PKG)" \
circleci/golang:$(GO_VERSION) \
make dist-common
clean:
rm -rf bin
rm -rf out-*
rm -rf vendor
rm -rf vendor-*
rm -rf tools
rm -rf tmp
test:
@docker run \
--rm \
-e HOST_GOOS="linux" \
-u root:root \
-v "$(shell pwd)":/go/src/$(PKG) \
-w /go/src/$(PKG) \
circleci/golang:$(GO_VERSION) \
make test-host
integration-test:
mkdir -p tmp
@echo "Running integration tests inside contianer"
@docker run \
--rm \
-e GOOS="linux" \
-e HOST_GOOS="linux" \
-e VERSION="$(VERSION)" \
-e BUILD_DATE="$(BUILD_DATE)" \
-e AWS_ACCESS_KEY_ID="$(AWS_ACCESS_KEY_ID)" \
-e AWS_SECRET_ACCESS_KEY="$(AWS_SECRET_ACCESS_KEY)" \
-e LEAVE_ARTIFACTS="$(LEAVE_ARTIFACTS)" \
-e CREATED_BY="$(CREATED_BY)" \
-u root:root \
-v "$(shell pwd)":"/go/src/$(PKG)" \
-v "$(HOME)/.ssh/kismatic-integration-testing.pem":"/root/.ssh/kismatic-integration-testing.pem:ro" \
-v "$(shell pwd)/tmp":"/tmp/kismatic" \
-w "/go/src/$(PKG)" \
circleci/golang:$(GO_VERSION) \
make integration-test-host
focus-integration-test:
mkdir -p tmp
@echo "Running integration tests inside contianer"
@docker run \
--rm \
-e FOCUS="$(FOCUS)" \
-e GOOS="linux" \
-e HOST_GOOS="linux" \
-e VERSION="$(VERSION)" \
-e BUILD_DATE="$(BUILD_DATE)" \
-e AWS_ACCESS_KEY_ID="$(AWS_ACCESS_KEY_ID)" \
-e AWS_SECRET_ACCESS_KEY="$(AWS_SECRET_ACCESS_KEY)" \
-e LEAVE_ARTIFACTS="$(LEAVE_ARTIFACTS)" \
-e CREATED_BY="$(CREATED_BY)" \
-u root:root \
-v "$(shell pwd)":"/go/src/$(PKG)" \
-v "$(HOME)/.ssh/kismatic-integration-testing.pem":"/root/.ssh/kismatic-integration-testing.pem:ro" \
-v "$(shell pwd)/tmp":"/tmp/kismatic" \
-w "/go/src/$(PKG)" \
circleci/golang:$(GO_VERSION) \
make focus-integration-test-host
slow-integration-test:
mkdir -p tmp
@echo "Running integration tests inside contianer"
@docker run \
--rm \
-e GOOS="linux" \
-e HOST_GOOS="linux" \
-e VERSION="$(VERSION)" \
-e BUILD_DATE="$(BUILD_DATE)" \
-e AWS_ACCESS_KEY_ID="$(AWS_ACCESS_KEY_ID)" \
-e AWS_SECRET_ACCESS_KEY="$(AWS_SECRET_ACCESS_KEY)" \
-e LEAVE_ARTIFACTS="$(LEAVE_ARTIFACTS)" \
-e CREATED_BY="$(CREATED_BY)" \
-u root:root \
-v "$(shell pwd)":"/go/src/$(PKG)" \
-v "$(HOME)/.ssh/kismatic-integration-testing.pem":"/root/.ssh/kismatic-integration-testing.pem:ro" \
-v "$(shell pwd)/tmp":"/tmp/kismatic" \
-w "/go/src/$(PKG)" \
circleci/golang:$(GO_VERSION) \
make slow-integration-test-host
# YOU SHOULDN'T NEED TO USE ANYTHING BENEATH THIS LINE
# UNLESS YOU REALLY KNOW WHAT YOU'RE DOING
# ---------------------------------------------------------------------
all:
@$(MAKE) GOOS=darwin dist
@$(MAKE) GOOS=linux dist
shallow-clean:
rm -rf $(BUILD_OUTPUT)
tar-clean:
rm kismatic-*.tar.gz
build:
@echo Building kismatic in container
@docker run \
--rm \
-e GOOS="$(GOOS)" \
-e HOST_GOOS="linux" \
-e VERSION="$(VERSION)" \
-e BUILD_DATE="$(BUILD_DATE)" \
-u root:root \
-v "$(shell pwd)":"/go/src/$(PKG)" \
-w /go/src/$(PKG) \
circleci/golang:$(GO_VERSION) \
make build-host
build-inspector:
@echo Building inspector in container
@docker run \
--rm \
-e GOOS="$(GOOS)" \
-e HOST_GOOS="linux" \
-e VERSION="$(VERSION)" \
-e BUILD_DATE="$(BUILD_DATE)" \
-u root:root \
-v "$(shell pwd)":"/go/src/$(PKG)" \
-w /go/src/$(PKG) \
circleci/golang:$(GO_VERSION) \
make build-inspector-host
glide-install:
@echo Glide installing in container
@docker run \
--rm \
-e GOOS="$(GOOS)" \
-e HOST_GOOS="linux" \
-e VERSION="$(VERSION)" \
-e BUILD_DATE="$(BUILD_DATE)" \
-u root:root \
-v "$(shell pwd)":"/go/src/$(PKG)" \
-w /go/src/$(PKG) \
circleci/golang:$(GO_VERSION) \
make glide-install-host
glide-update:
@echo Glide updating in container
@docker run \
--rm \
-e GOOS="$(GOOS)" \
-e HOST_GOOS="linux" \
-e VERSION="$(VERSION)" \
-e BUILD_DATE="$(BUILD_DATE)" \
-u root:root \
-v "$(shell pwd)":"/go/src/$(PKG)" \
-w /go/src/$(PKG) \
circleci/golang:$(GO_VERSION) \
make glide-update-host
copy-all: copy-vendors copy-inspector copy-playbooks copy-kismatic
copy-kismatic:
mkdir -p $(BUILD_OUTPUT)
cp bin/$(GOOS)/kismatic $(BUILD_OUTPUT)
copy-inspector:
rm -rf $(BUILD_OUTPUT)/ansible/playbooks/inspector
mkdir -p $(BUILD_OUTPUT)/ansible/playbooks/inspector
cp -r bin/inspector/* $(BUILD_OUTPUT)/ansible/playbooks/inspector
copy-playbooks:
mkdir -p $(BUILD_OUTPUT)/ansible
rm -rf $(filter-out $(BUILD_OUTPUT)/ansible/playbooks/inspector $(BUILD_OUTPUT)/ansible/playbooks/kuberang, $(wildcard $(BUILD_OUTPUT)/ansible/playbooks/*))
cp -r $(wildcard ansible/*) $(BUILD_OUTPUT)/ansible/playbooks
copy-vendors: # omit kismatic, inspector, terraform since we provide configs for those.
mkdir -p $(BUILD_OUTPUT)/ansible
cp -r vendor-ansible/out/ansible/* $(BUILD_OUTPUT)/ansible
cp vendor-kubectl/out/kubectl-$(KUBECTL_VERSION)-$(GOOS)-$(GOARCH) $(BUILD_OUTPUT)/kubectl
cp vendor-helm/out/helm-$(HELM_VERSION)-$(GOOS)-$(GOARCH) $(BUILD_OUTPUT)/helm
cp vendor-provision/out/provision-$(PROVISIONER_VERSION)-$(GOOS)-$(GOARCH) $(BUILD_OUTPUT)/provision
mkdir -p $(BUILD_OUTPUT)/ansible/playbooks/kuberang/linux/$(GOARCH)/
cp vendor-kuberang/$(KUBERANG_VERSION)/kuberang-linux-$(GOARCH) $(BUILD_OUTPUT)/ansible/playbooks/kuberang/linux/$(GOARCH)/kuberang
tarball:
rm -f kismatic-$(GOOS).tar.gz
tar -czf kismatic-$(GOOS).tar.gz -C $(BUILD_OUTPUT) .
# RECIPES BELOW THIS LINE ARE INTENDED FOR CI ONLY. RUN LOCALLY AT YOUR OWN RISK.
# ---------------------------------------------------------------------
all-host:
@$(MAKE) GOOS=darwin dist-host
@$(MAKE) GOOS=linux dist-host
test-host:
go test ./cmd/... ./pkg/... $(TEST_OPTS)
build-host: tools/glide-$(HOST_GOOS)-$(HOST_GOARCH) glide-install-host bin/$(GOOS)/kismatic
.PHONY: bin/$(GOOS)/kismatic
bin/$(GOOS)/kismatic:
go build -o $@ \
-ldflags "-X main.version=$(VERSION) -X 'main.buildDate=$(BUILD_DATE)'" \
./cmd/kismatic
build-inspector-host:
@$(MAKE) GOOS=linux bin/inspector/linux/$(GOARCH)/kismatic-inspector
.PHONY: bin/inspector/$(GOOS)/$(GOARCH)/kismatic-inspector
bin/inspector/$(GOOS)/$(GOARCH)/kismatic-inspector:
go build -o $@ \
-ldflags "-X main.version=$(VERSION) -X 'main.buildDate=$(BUILD_DATE)'" \
./cmd/kismatic-inspector
glide-install-host:
tools/glide-$(HOST_GOOS)-$(HOST_GOARCH) cc
tools/glide-$(HOST_GOOS)-$(HOST_GOARCH) install
glide-update-host:
tools/glide-$(HOST_GOOS)-$(HOST_GOARCH) update
vendor: vendor-tools vendor-ansible/out vendor-provision/out/provision-$(PROVISIONER_VERSION)-$(GOOS)-$(GOARCH) vendor-kuberang/$(KUBERANG_VERSION) vendor-kubectl/out/kubectl-$(KUBECTL_VERSION)-$(GOOS)-$(GOARCH) vendor-helm/out/helm-$(HELM_VERSION)-$(GOOS)-$(GOARCH)
vendor-tools: tools/glide-$(HOST_GOOS)-$(HOST_GOARCH)
tools/glide-$(HOST_GOOS)-$(HOST_GOARCH):
mkdir -p tools
curl -L https://github.com/Masterminds/glide/releases/download/$(GLIDE_VERSION)/glide-$(GLIDE_VERSION)-$(HOST_GOOS)-$(HOST_GOARCH).tar.gz | tar -xz -C tools
mv tools/$(HOST_GOOS)-$(HOST_GOARCH)/glide tools/glide-$(HOST_GOOS)-$(HOST_GOARCH)
rm -r tools/$(HOST_GOOS)-$(HOST_GOARCH)
vendor-ansible/out:
mkdir -p vendor-ansible/out
curl -L https://github.com/apprenda/vendor-ansible/releases/download/v$(ANSIBLE_VERSION)/ansible.tar.gz -o vendor-ansible/out/ansible.tar.gz
tar -zxf vendor-ansible/out/ansible.tar.gz -C vendor-ansible/out
rm vendor-ansible/out/ansible.tar.gz
vendor-provision/out/provision-$(PROVISIONER_VERSION)-$(GOOS)-$(GOARCH):
mkdir -p vendor-provision/out/
curl -L https://github.com/apprenda/kismatic-provision/releases/download/$(PROVISIONER_VERSION)/provision-$(GOOS)-$(GOARCH) -o vendor-provision/out/provision-$(PROVISIONER_VERSION)-$(GOOS)-$(GOARCH)
chmod +x vendor-provision/out/provision-$(PROVISIONER_VERSION)-$(GOOS)-$(GOARCH)
vendor-kuberang/$(KUBERANG_VERSION):
mkdir -p vendor-kuberang/$(KUBERANG_VERSION)
curl -L https://github.com/apprenda/kuberang/releases/download/$(KUBERANG_VERSION)/kuberang-linux-$(GOARCH) -o vendor-kuberang/$(KUBERANG_VERSION)/kuberang-linux-$(GOARCH)
vendor-kubectl/out/kubectl-$(KUBECTL_VERSION)-$(GOOS)-$(GOARCH):
mkdir -p vendor-kubectl/out/
curl -L https://storage.googleapis.com/kubernetes-release/release/$(KUBECTL_VERSION)/bin/$(GOOS)/$(GOARCH)/kubectl -o vendor-kubectl/out/kubectl-$(KUBECTL_VERSION)-$(GOOS)-$(GOARCH)
chmod +x vendor-kubectl/out/kubectl-$(KUBECTL_VERSION)-$(GOOS)-$(GOARCH)
vendor-helm/out/helm-$(HELM_VERSION)-$(GOOS)-$(GOARCH):
mkdir -p vendor-helm/out/
curl -L https://storage.googleapis.com/kubernetes-helm/helm-$(HELM_VERSION)-$(GOOS)-$(GOARCH).tar.gz | tar zx -C vendor-helm
cp vendor-helm/$(GOOS)-$(GOARCH)/helm vendor-helm/out/helm-$(HELM_VERSION)-$(GOOS)-$(GOARCH)
rm -rf vendor-helm/$(GOOS)-$(GOARCH)
chmod +x vendor-helm/out/helm-$(HELM_VERSION)-$(GOOS)-$(GOARCH)
dist-common: vendor build-host build-inspector-host copy-all
dist-host: shallow-clean dist-common
get-ginkgo:
go get github.com/onsi/ginkgo/ginkgo
cd integration-tests
integration-test-host: get-ginkgo
@$(MAKE) GOOS=linux tarball
ginkgo --skip "\[slow\]" -p $(GINKGO_OPTS) -v integration-tests
slow-integration-test-host: get-ginkgo
@$(MAKE) GOOS=linux tarball
ginkgo --focus "\[slow\]" -p $(GINKGO_OPTS) -v integration-tests
focus-integration-test-host: get-ginkgo
@$(MAKE) GOOS=linux tarball
ginkgo --focus $(FOCUS) $(GINKGO_OPTS) -v integration-tests
docs/generate-kismatic-cli:
mkdir -p docs/kismatic-cli
go run cmd/kismatic-docs/main.go
cp docs/kismatic-cli/kismatic.md docs/kismatic-cli/README.md
docs/update-plan-file-reference.md:
@$(MAKE) docs/generate-plan-file-reference.md > docs/plan-file-reference.md
docs/generate-plan-file-reference.md:
@go run cmd/gen-kismatic-ref-docs/*.go -o markdown pkg/install/plan_types.go Plan
version:
@echo VERSION=$(VERSION)
@echo GLIDE_VERSION=$(GLIDE_VERSION)
@echo ANSIBLE_VERSION=$(ANSIBLE_VERSION)
@echo PROVISIONER_VERSION=$(PROVISIONER_VERSION)
CIRCLE_ENDPOINT=
ifndef CIRCLE_CI_BRANCH
CIRCLE_ENDPOINT=https://circleci.com/api/v1.1/project/github/apprenda/kismatic
else
CIRCLE_ENDPOINT=https://circleci.com/api/v1.1/project/github/apprenda/kismatic/tree/$(CIRCLE_CI_BRANCH)
endif
trigger-pr:
@echo Triggering PR tests
curl -u $(CIRCLE_CI_TOKEN): -X POST --header "Content-Type: application/json" \
-d '{ "revision": "$(PR_COMMIT)", "build_parameters": {}}' \
https://circleci.com/api/v1.1/project/github/apprenda/kismatic/tree/pull/$(PR_NUMBER)
trigger-ci-slow-tests:
@echo Triggering build with slow tests
curl -u $(CIRCLE_CI_TOKEN): -X POST --header "Content-Type: application/json" \
-d '{"build_parameters": {"RUN_SLOW_TESTS": "true"}}' \
$(CIRCLE_ENDPOINT)
trigger-ci-focused-tests:
@echo Triggering focused test
curl -u $(CIRCLE_CI_TOKEN): -X POST --header "Content-Type: application/json" \
-d "{\"build_parameters\": {\"FOCUS\": \"$(FOCUS)\"}}" \
$(CIRCLE_ENDPOINT)