forked from kubestellar/kubestellar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
474 lines (400 loc) · 18.5 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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# Copyright 2021 The KubeStellar Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# We need bash for some conditional logic below.
SHELL := /usr/bin/env bash -e
GO_INSTALL = ./hack/go-install.sh
TOOLS_DIR=hack/tools
TOOLS_GOBIN_DIR := $(abspath $(TOOLS_DIR))
GOBIN_DIR=$(abspath ./bin )
PATH := $(GOBIN_DIR):$(TOOLS_GOBIN_DIR):$(PATH)
TMPDIR := $(shell mktemp -d)
# Detect the path used for the install target
ifeq (,$(shell go env GOBIN))
INSTALL_GOBIN=$(shell go env GOPATH)/bin
else
INSTALL_GOBIN=$(shell go env GOBIN)
endif
CONTROLLER_GEN_VER := v0.10.0
CONTROLLER_GEN_BIN := controller-gen
CONTROLLER_GEN := $(TOOLS_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER)
export CONTROLLER_GEN # so hack scripts can use it
API_GEN_VER := v0.0.0-20230124223207-cb8dd3c46470
API_GEN_BIN := apigen
API_GEN := $(TOOLS_DIR)/$(API_GEN_BIN)-$(API_GEN_VER)
export API_GEN # so hack scripts can use it
YAML_PATCH_VER ?= v0.0.11
YAML_PATCH_BIN := yaml-patch
YAML_PATCH := $(TOOLS_DIR)/$(YAML_PATCH_BIN)-$(YAML_PATCH_VER)
export YAML_PATCH # so hack scripts can use it
OPENSHIFT_GOIMPORTS_VER := 4cd858e694d7dfa32a2e697e0e4bab245c215cf3
OPENSHIFT_GOIMPORTS_BIN := openshift-goimports
OPENSHIFT_GOIMPORTS := $(TOOLS_DIR)/$(OPENSHIFT_GOIMPORTS_BIN)-$(OPENSHIFT_GOIMPORTS_VER)
export OPENSHIFT_GOIMPORTS # so hack scripts can use it
GOLANGCI_LINT_VER := v1.50.1
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(TOOLS_GOBIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
STATICCHECK_VER := 2022.1
STATICCHECK_BIN := staticcheck
STATICCHECK := $(TOOLS_GOBIN_DIR)/$(STATICCHECK_BIN)-$(STATICCHECK_VER)
GOTESTSUM_VER := v1.8.1
GOTESTSUM_BIN := gotestsum
GOTESTSUM := $(abspath $(TOOLS_DIR))/$(GOTESTSUM_BIN)-$(GOTESTSUM_VER)
LOGCHECK_VER := v0.4.1
LOGCHECK_BIN := logcheck
LOGCHECK := $(TOOLS_GOBIN_DIR)/$(LOGCHECK_BIN)-$(LOGCHECK_VER)
export LOGCHECK # so hack scripts can use it
CODE_GENERATOR_VER := v2.0.0-alpha.1
CODE_GENERATOR_BIN := code-generator
CODE_GENERATOR := $(TOOLS_GOBIN_DIR)/$(CODE_GENERATOR_BIN)-$(CODE_GENERATOR_VER)
export CODE_GENERATOR # so hack scripts can use it
ARCH := $(shell go env GOARCH)
OS := $(shell go env GOOS)
KUBE_MAJOR_VERSION := $(shell go mod edit -json | jq '.Require[] | select(.Path == "k8s.io/kubernetes") | .Version' --raw-output | sed 's/v\([0-9]*\).*/\1/')
KUBE_MINOR_VERSION := $(shell go mod edit -json | jq '.Require[] | select(.Path == "k8s.io/kubernetes") | .Version' --raw-output | sed "s/v[0-9]*\.\([0-9]*\).*/\1/")
GIT_COMMIT := $(shell git rev-parse --short HEAD || echo 'local')
GIT_DIRTY := $(shell [ $$(git status --porcelain=v2 | wc -l) == 0 ] && echo 'clean' || echo 'dirty')
GIT_VERSION := $(shell go mod edit -json | jq '.Require[] | select(.Path == "k8s.io/kubernetes") | .Version' --raw-output)+kcp-$(shell git describe --tags --match='v*' --abbrev=14 "$(GIT_COMMIT)^{commit}" 2>/dev/null || echo v0.0.0-$(GIT_COMMIT))
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
LDFLAGS := \
-X k8s.io/client-go/pkg/version.gitCommit=${GIT_COMMIT} \
-X k8s.io/client-go/pkg/version.gitTreeState=${GIT_DIRTY} \
-X k8s.io/client-go/pkg/version.gitVersion=${GIT_VERSION} \
-X k8s.io/client-go/pkg/version.gitMajor=${KUBE_MAJOR_VERSION} \
-X k8s.io/client-go/pkg/version.gitMinor=${KUBE_MINOR_VERSION} \
-X k8s.io/client-go/pkg/version.buildDate=${BUILD_DATE} \
\
-X k8s.io/component-base/version.gitCommit=${GIT_COMMIT} \
-X k8s.io/component-base/version.gitTreeState=${GIT_DIRTY} \
-X k8s.io/component-base/version.gitVersion=${GIT_VERSION} \
-X k8s.io/component-base/version.gitMajor=${KUBE_MAJOR_VERSION} \
-X k8s.io/component-base/version.gitMinor=${KUBE_MINOR_VERSION} \
-X k8s.io/component-base/version.buildDate=${BUILD_DATE} \
-extldflags '-static'
all: build
.PHONY: all
ldflags:
@echo $(LDFLAGS)
.PHONY: require-%
require-%:
@if ! command -v $* 1> /dev/null 2>&1; then echo "$* not found in \$$PATH"; exit 1; fi
build: WHAT ?= ./cmd/...
#./tmc/cmd/...
build: require-jq require-go require-git verify-go-versions ## Build the project
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build $(BUILDFLAGS) -ldflags="$(LDFLAGS)" -o bin $(WHAT)
# ln -sf kubectl-workspace bin/kubectl-workspaces
# ln -sf kubectl-workspace bin/kubectl-ws
cp scripts/* bin/
.PHONY: build
.PHONY: build-all
build-all:
GOOS=$(OS) GOARCH=$(ARCH) $(MAKE) build WHAT='./cmd/...'
#' ./tmc/cmd/...'
# .PHONY: build-kind-images
# build-kind-images-ko: require-ko
# $(eval SYNCER_IMAGE=$(shell KO_DOCKER_REPO=kind.local ko build --platform=linux/$(ARCH) ./cmd/syncer))
# $(eval TEST_IMAGE=$(shell KO_DOCKER_REPO=kind.local ko build --platform=linux/$(ARCH) ./test/e2e/fixtures/kcp-test-image))
# build-kind-images: build-kind-images-ko
# test -n "$(SYNCER_IMAGE)" || (echo Failed to create syncer image; exit 1)
# test -n "$(TEST_IMAGE)" || (echo Failed to create test image; exit 1)
# build and push kubestellar-syncer image by ko
# e.g. usage:
# make build-kubestellar-syncer-image DOCKER_REPO=ghcr.io/yana1205/edge-mc/syncer IMAGE_TAG=dev-2023-04-24-x ARCHS=linux/amd64,linux/arm64
# This example builds ghcr.io/yana1205/edge-mc/syncer:dev-2023-04-24-x image with linux/amd64 and linux/arm64 and push it to ghcr.io/yana1205/edge-mc/syncer:dev-2023-04-24-x
.PHONY: build-kubestellar-syncer-image
build-kubestellar-syncer-image: DOCKER_REPO ?=
build-kubestellar-syncer-image: IMAGE_TAG ?= latest
build-kubestellar-syncer-image: ARCHS ?= linux/$(ARCH)
build-kubestellar-syncer-image: require-ko
echo KO_DOCKER_REPO=$(DOCKER_REPO) ko build --platform=$(ARCHS) --bare --tags $(IMAGE_TAG) ./cmd/syncer
$(eval SYNCER_IMAGE=$(shell KO_DOCKER_REPO=$(DOCKER_REPO) ko build --platform=$(ARCHS) --bare --tags $(IMAGE_TAG) ./cmd/syncer))
@echo "$(SYNCER_IMAGE)"
.PHONY: build-kubestellar-syncer-image-local
build-kubestellar-syncer-image-local: require-ko
$(eval SYNCER_IMAGE=$(shell ko build --local --platform=linux/$(ARCH) ./cmd/syncer))
@echo "$(SYNCER_IMAGE)"
install: WHAT ?= ./cmd/...
install:
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go install -ldflags="$(LDFLAGS)" $(WHAT)
ln -sf $(INSTALL_GOBIN)/kubectl-workspace $(INSTALL_GOBIN)/kubectl-ws
ln -sf $(INSTALL_GOBIN)/kubectl-workspace $(INSTALL_GOBIN)/kubectl-workspaces
.PHONY: install
$(GOLANGCI_LINT):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)
$(STATICCHECK):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) honnef.co/go/tools/cmd/staticcheck $(STATICCHECK_BIN) $(STATICCHECK_VER)
$(LOGCHECK):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) sigs.k8s.io/logtools/logcheck $(LOGCHECK_BIN) $(LOGCHECK_VER)
$(CODE_GENERATOR):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/kcp-dev/code-generator/v2 $(CODE_GENERATOR_BIN) $(CODE_GENERATOR_VER)
lint: $(GOLANGCI_LINT) $(STATICCHECK) $(LOGCHECK)
# $(GOLANGCI_LINT) run ./...
# $(STATICCHECK) -checks ST1019,ST1005 ./...
./hack/verify-contextual-logging.sh
.PHONY: lint
update-contextual-logging: $(LOGCHECK)
UPDATE=true ./hack/verify-contextual-logging.sh
.PHONY: update-contextual-logging
# generate-docs:
# go run hack/generate/cli-doc/gen-cli-doc.go
# ./hack/generate/crd-ref/run-crd-ref-gen.sh
vendor: ## Vendor the dependencies
go mod tidy
go mod vendor
.PHONY: vendor
VENVDIR=$(abspath docs/venv)
REQUIREMENTS_TXT=docs/requirements.txt
.PHONY: serve-docs
serve-docs: venv
. $(VENV)/activate; \
VENV=$(VENV) REMOTE=$(REMOTE) BRANCH=$(BRANCH) docs/scripts/serve-docs.sh
.PHONY: deploy-docs
deploy-docs: venv
. $(VENV)/activate; \
REMOTE=$(REMOTE) BRANCH=$(BRANCH) docs/scripts/deploy-docs.sh
.PHONY: docs-ecutable
docs-ecutable:
MANIFEST=$(MANIFEST) docs/scripts/docs-ecutable.sh
.PHONY: write-time-to-file
write-time-to-file:
FILENAME=$(FILENAME) docs/scripts/get-elapsed-time.sh
tools: $(GOLANGCI_LINT) $(CONTROLLER_GEN) $(API_GEN) $(YAML_PATCH) $(GOTESTSUM) $(OPENSHIFT_GOIMPORTS) $(CODE_GENERATOR)
.PHONY: tools
$(CONTROLLER_GEN):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) sigs.k8s.io/controller-tools/cmd/controller-gen $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER)
$(API_GEN):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/kcp-dev/kcp/cmd/apigen $(API_GEN_BIN) $(API_GEN_VER)
$(YAML_PATCH):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/pivotal-cf/yaml-patch/cmd/yaml-patch $(YAML_PATCH_BIN) $(YAML_PATCH_VER)
$(GOTESTSUM):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) gotest.tools/gotestsum $(GOTESTSUM_BIN) $(GOTESTSUM_VER)
crds: $(CONTROLLER_GEN) $(API_GEN) $(YAML_PATCH)
./hack/update-codegen-crds.sh
.PHONY: crds
codegen: crds $(CODE_GENERATOR)
go mod download
./hack/update-codegen-clients.sh
$(MAKE) imports
.PHONY: codegen
# Note, running this locally if you have any modified files, even those that are not generated,
# will result in an error. This target is mostly for CI jobs.
.PHONY: verify-codegen
verify-codegen:
if [[ -n "${GITHUB_WORKSPACE}" ]]; then \
mkdir -p $$(go env GOPATH)/src/github.com/kcp-dev; \
ln -s ${GITHUB_WORKSPACE} $$(go env GOPATH)/src/github.com/kcp-dev/edge-mc; \
fi
$(MAKE) codegen
if ! git diff --quiet HEAD; then \
git diff; \
echo "You need to run 'make codegen' to update generated files and commit them"; \
exit 1; \
fi
.PHONY: verify-syncer-codegen
verify-syncer-codegen:
if [[ -n "${GITHUB_WORKSPACE}" ]]; then \
mkdir -p $$(go env GOPATH)/src/github.com/kcp-dev; \
ln -s ${GITHUB_WORKSPACE} $$(go env GOPATH)/src/github.com/kcp-dev/edge-mc; \
fi
# $(MAKE) syncer-codegen
if ! git diff --quiet HEAD; then \
git diff; \
echo "You need to run 'make codegen' to update generated files and commit them"; \
exit 1; \
fi
$(OPENSHIFT_GOIMPORTS):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/openshift-eng/openshift-goimports $(OPENSHIFT_GOIMPORTS_BIN) $(OPENSHIFT_GOIMPORTS_VER)
.PHONY: imports
imports: $(OPENSHIFT_GOIMPORTS) verify-go-versions
$(OPENSHIFT_GOIMPORTS) -i github.com/kcp-dev -m github.com/kcp-dev/edge-mc
$(TOOLS_DIR)/verify_boilerplate.py:
mkdir -p $(TOOLS_DIR)
curl --fail --retry 3 -L -o $(TOOLS_DIR)/verify_boilerplate.py https://raw.githubusercontent.com/kubernetes/repo-infra/master/hack/verify_boilerplate.py
chmod +x $(TOOLS_DIR)/verify_boilerplate.py
.PHONY: verify-boilerplate
verify-boilerplate: $(TOOLS_DIR)/verify_boilerplate.py
$(TOOLS_DIR)/verify_boilerplate.py --boilerplate-dir=hack/boilerplate --skip docs
ifdef ARTIFACT_DIR
GOTESTSUM_ARGS += --junitfile=$(ARTIFACT_DIR)/junit.xml
endif
GO_TEST = go test
ifdef USE_GOTESTSUM
GO_TEST = $(GOTESTSUM) $(GOTESTSUM_ARGS) --
endif
COUNT ?=
COUNT_ARG =
ifdef COUNT
COUNT_ARG = -count $(COUNT)
endif
E2E_PARALLELISM ?=
ifdef E2E_PARALLELISM
PARALLELISM_ARG = -p $(E2E_PARALLELISM) -parallel $(E2E_PARALLELISM)
endif
SUITES ?=
SUITES_ARG =
COMPLETE_SUITES_ARG =
ifdef SUITES
SUITES_ARG = --suites $(SUITES)
COMPLETE_SUITES_ARG = -args $(SUITES_ARG)
endif
# .PHONY: test-e2e
# ifdef USE_GOTESTSUM
# test-e2e: $(GOTESTSUM)
# endif
# test-e2e: TEST_ARGS ?=
# test-e2e: WHAT ?= ./test/e2e...
# test-e2e: build-all
# UNSAFE_E2E_HACK_DISABLE_ETCD_FSYNC=true NO_GORUN=1 GOOS=$(OS) GOARCH=$(ARCH) $(GO_TEST) -race $(COUNT_ARG) $(PARALLELISM_ARG) $(WHAT) $(TEST_ARGS) $(COMPLETE_SUITES_ARG)
# .PHONY: test-e2e-shared
# ifdef USE_GOTESTSUM
# test-e2e-shared: $(GOTESTSUM)
# endif
# test-e2e-shared: TEST_ARGS ?=
# test-e2e-shared: WHAT ?= ./test/e2e...
# test-e2e-shared: WORK_DIR ?= .
# ifdef ARTIFACT_DIR
# test-e2e-shared: LOG_DIR ?= $(ARTIFACT_DIR)/kcp
# else
# test-e2e-shared: LOG_DIR ?= $(WORK_DIR)/.kcp
# endif
# test-e2e-shared: require-kind build-all build-kind-images
# mkdir -p "$(LOG_DIR)" "$(WORK_DIR)/.kcp"
# kind get kubeconfig > "$(WORK_DIR)/.kcp/kind.kubeconfig"
# rm -f "$(WORK_DIR)/.kcp/admin.kubeconfig"
# UNSAFE_E2E_HACK_DISABLE_ETCD_FSYNC=true NO_GORUN=1 ./bin/test-server --quiet --log-file-path="$(LOG_DIR)/kcp.log" $(TEST_SERVER_ARGS) 2>&1 & PID=$$! && echo "PID $$PID" && \
# trap 'kill -TERM $$PID' TERM INT EXIT && \
# while [ ! -f "$(WORK_DIR)/.kcp/admin.kubeconfig" ]; do sleep 1; done && \
# NO_GORUN=1 GOOS=$(OS) GOARCH=$(ARCH) $(GO_TEST) -race $(COUNT_ARG) $(PARALLELISM_ARG) $(WHAT) $(TEST_ARGS) \
# -args --use-default-kcp-server --syncer-image="$(SYNCER_IMAGE)" --kcp-test-image="$(TEST_IMAGE)" --pcluster-kubeconfig="$(abspath $(WORK_DIR)/.kcp/kind.kubeconfig)" $(SUITES_ARG) \
# $(if $(value WAIT),|| { echo "Terminated with $$?"; wait "$$PID"; },)
# .PHONY: test-e2e-shared-minimal
# ifdef USE_GOTESTSUM
# test-e2e-shared-minimal: $(GOTESTSUM)
# endif
# test-e2e-shared-minimal: TEST_ARGS ?=
# test-e2e-shared-minimal: WHAT ?= ./test/e2e...
# test-e2e-shared-minimal: WORK_DIR ?= .
# ifdef ARTIFACT_DIR
# test-e2e-shared-minimal: LOG_DIR ?= $(ARTIFACT_DIR)/kcp
# else
# test-e2e-shared-minimal: LOG_DIR ?= $(WORK_DIR)/.kcp
# endif
# test-e2e-shared-minimal: build-all
# mkdir -p "$(LOG_DIR)" "$(WORK_DIR)/.kcp"
# rm -f "$(WORK_DIR)/.kcp/admin.kubeconfig"
# UNSAFE_E2E_HACK_DISABLE_ETCD_FSYNC=true NO_GORUN=1 ./bin/test-server --quiet --log-file-path="$(LOG_DIR)/kcp.log" $(TEST_SERVER_ARGS) 2>&1 & PID=$$! && echo "PID $$PID" && \
# trap 'kill -TERM $$PID' TERM INT EXIT && \
# while [ ! -f "$(WORK_DIR)/.kcp/admin.kubeconfig" ]; do sleep 1; done && \
# NO_GORUN=1 GOOS=$(OS) GOARCH=$(ARCH) $(GO_TEST) -race $(COUNT_ARG) $(PARALLELISM_ARG) $(WHAT) $(TEST_ARGS) \
# -args --use-default-kcp-server $(SUITES_ARG) \
# $(if $(value WAIT),|| { echo "Terminated with $$?"; wait "$$PID"; },)
# .PHONY: test-e2e-sharded
# ifdef USE_GOTESTSUM
# test-e2e-sharded: $(GOTESTSUM)
# endif
# test-e2e-sharded: TEST_ARGS ?=
# test-e2e-sharded: WHAT ?= ./test/e2e...
# test-e2e-sharded: WORK_DIR ?= .
# ifdef ARTIFACT_DIR
# test-e2e-sharded: LOG_DIR ?= $(ARTIFACT_DIR)/kcp
# else
# test-e2e-sharded: LOG_DIR ?= $(WORK_DIR)/.kcp
# endif
# test-e2e-sharded: require-kind build-all build-kind-images
# mkdir -p "$(LOG_DIR)" "$(WORK_DIR)/.kcp"
# kind get kubeconfig > "$(WORK_DIR)/.kcp/kind.kubeconfig"
# rm -f "$(WORK_DIR)/.kcp/admin.kubeconfig"
# UNSAFE_E2E_HACK_DISABLE_ETCD_FSYNC=true NO_GORUN=1 ./bin/sharded-test-server --quiet --v=2 --log-dir-path="$(LOG_DIR)" --work-dir-path="$(WORK_DIR)" $(TEST_SERVER_ARGS) --number-of-shards=2 2>&1 & PID=$$!; echo "PID $$PID" && \
# trap 'kill -TERM $$PID' TERM INT EXIT && \
# while [ ! -f "$(WORK_DIR)/.kcp/admin.kubeconfig" ]; do sleep 1; done && \
# NO_GORUN=1 GOOS=$(OS) GOARCH=$(ARCH) $(GO_TEST) -race $(COUNT_ARG) $(PARALLELISM_ARG) $(WHAT) $(TEST_ARGS) \
# -args --use-default-kcp-server --root-shard-kubeconfig=$(PWD)/.kcp-0/admin.kubeconfig $(SUITES_ARG) \
# --syncer-image="$(SYNCER_IMAGE)" --kcp-test-image="$(TEST_IMAGE)" --pcluster-kubeconfig="$(abspath $(WORK_DIR)/.kcp/kind.kubeconfig)" \
# $(if $(value WAIT),|| { echo "Terminated with $$?"; wait "$$PID"; },)
# .PHONY: test-e2e-sharded-minimal
# ifdef USE_GOTESTSUM
# test-e2e-sharded-minimal: $(GOTESTSUM)
# endif
# test-e2e-sharded-minimal: TEST_ARGS ?=
# test-e2e-sharded-minimal: WHAT ?= ./test/e2e...
# test-e2e-sharded-minimal: WORK_DIR ?= .
# ifdef ARTIFACT_DIR
# test-e2e-sharded-minimal: LOG_DIR ?= $(ARTIFACT_DIR)/kcp
# else
# test-e2e-sharded-minimal: LOG_DIR ?= $(WORK_DIR)/.kcp
# endif
# test-e2e-sharded-minimal: build-all
# mkdir -p "$(LOG_DIR)" "$(WORK_DIR)/.kcp"
# rm -f "$(WORK_DIR)/.kcp/admin.kubeconfig"
# UNSAFE_E2E_HACK_DISABLE_ETCD_FSYNC=true NO_GORUN=1 ./bin/sharded-test-server --quiet --v=2 --log-dir-path="$(LOG_DIR)" --work-dir-path="$(WORK_DIR)" $(TEST_SERVER_ARGS) --number-of-shards=2 2>&1 & PID=$$!; echo "PID $$PID" && \
# trap 'kill -TERM $$PID' TERM INT EXIT && \
# while [ ! -f "$(WORK_DIR)/.kcp/admin.kubeconfig" ]; do sleep 1; done && \
# NO_GORUN=1 GOOS=$(OS) GOARCH=$(ARCH) $(GO_TEST) -race $(COUNT_ARG) $(PARALLELISM_ARG) $(WHAT) $(TEST_ARGS) \
# -args --use-default-kcp-server --root-shard-kubeconfig=$(PWD)/.kcp-0/admin.kubeconfig $(SUITES_ARGS) \
# $(if $(value WAIT),|| { echo "Terminated with $$?"; wait "$$PID"; },)
kcp/bin/kcp:
bash ./bootstrap/install-kcp-with-plugins.sh
.PHONY: e2e-test-kubestellar-syncer
e2e-test-kubestellar-syncer: WORK_DIR ?= $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
e2e-test-kubestellar-syncer: TEST_ARGS ?=
e2e-test-kubestellar-syncer: KIND_CLUSTER_NAME ?= e2e-kubestellar
e2e-test-kubestellar-syncer: e2e-test-kubestellar-syncer-cleanup kcp/bin/kcp
export PATH=$(PWD)/kcp/bin:$$PATH && \
kcp start --root-directory=$(WORK_DIR)/.kcp > $(WORK_DIR)/.kcp/kcp.log 2>&1 & PID=$$! && echo "PID $$PID" && \
trap 'kill -TERM $$PID' TERM INT EXIT && \
while [ ! -f "$(WORK_DIR)/.kcp/admin.kubeconfig" ]; do sleep 1; echo "kcp is not ready. wait for 1s...";done && \
echo 'Starting test(s)' && \
NO_GORUN=1 GOOS=$(OS) GOARCH=$(ARCH) \
$(GO_TEST) -race $(COUNT_ARG) ./test/e2e/kubestellar-syncer/... $(TEST_ARGS) \
--kcp-kubeconfig $(WORK_DIR)/.kcp/admin.kubeconfig --suites kubestellar-syncer \
$(if $(value WAIT),|| { echo "Terminated with $$?"; wait "$$PID"; },)
.PHONY: e2e-test-kubestellar-syncer-cleanup
e2e-test-kubestellar-syncer-cleanup:
rm -rf $(WORK_DIR)/.kcp/etcd-server
rm -rf $(WORK_DIR)/.kcp/.admin-token-store $(WORK_DIR)/.kcp/admin.kubeconfig
rm -rf $(WORK_DIR)/.kcp/apiserver.* $(WORK_DIR)/.kcp/sa.key
.PHONY: test-syncer
test-syncer:
$(GO_TEST) $(COUNT_ARG) `go list ./... | grep "/pkg/cliplugins\|/pkg/syncer"`
.PHONY: test
ifdef USE_GOTESTSUM
test: $(GOTESTSUM)
endif
test: WHAT ?= ./...
# We will need to move into the sub package, of pkg/apis to run those tests.
test:
# $(GO_TEST) -race $(COUNT_ARG) -coverprofile=coverage.txt -covermode=atomic $(TEST_ARGS) $$(go list "$(WHAT)" | grep -v ./test/e2e/)
# cd pkg/apis && $(GO_TEST) -race $(COUNT_ARG) -coverprofile=coverage.txt -covermode=atomic $(TEST_ARGS) $(WHAT)
.PHONY: verify-k8s-deps
verify-k8s-deps:
hack/validate-k8s.sh
.PHONY: verify-imports
verify-imports:
hack/verify-imports.sh
.PHONY: verify-go-versions
verify-go-versions:
hack/verify-go-versions.sh
.PHONY: modules
modules: ## Run go mod tidy to ensure modules are up to date
go mod tidy
cd pkg/apis; go mod tidy
.PHONY: verify-modules
verify-modules: modules ## Verify go modules are up to date
@if !(git diff --quiet HEAD -- go.sum go.mod pkg/apis/go.mod pkg/apis/go.sum); then \
git diff; \
echo "go module files are out of date"; exit 1; \
fi
.PHONY: help
help: ## Show this help.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
include Makefile.venv