forked from Azure/karpenter-provider-azure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
128 lines (100 loc) · 4.52 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
include Makefile-az.mk
## Inject the app version into operator.Version
LDFLAGS ?= -ldflags=-X=sigs.k8s.io/karpenter/pkg/operator.Version=$(shell git describe --tags --always | cut -d"v" -f2)
GOFLAGS ?= $(LDFLAGS)
WITH_GOFLAGS = GOFLAGS="$(GOFLAGS)"
# # CR for local builds of Karpenter
KARPENTER_NAMESPACE ?= kube-system
# Common Directories
# TODO: revisit testing tools (temporarily excluded here, for make verify)
MOD_DIRS = $(shell find . -name go.mod -type f ! -path "./test/*" | xargs dirname)
KARPENTER_CORE_DIR = $(shell go list -m -f '{{ .Dir }}' sigs.k8s.io/karpenter)
# TEST_SUITE enables you to select a specific test suite directory to run "make e2etests" or "make test" against
TEST_SUITE ?= "..."
TEST_TIMEOUT ?= "3h"
help: ## Display help
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
presubmit: verify test ## Run all steps in the developer loop
ci-test: battletest coverage ## Runs tests and submits coverage
ci-non-test: verify vulncheck ## Runs checks other than tests
test: ## Run tests
ginkgo -v --focus="${FOCUS}" ./pkg/$(shell echo $(TEST_SUITE) | tr A-Z a-z)
battletest: ## Run randomized, racing, code-covered tests
ginkgo -v \
-race \
-cover -coverprofile=coverage.out -output-dir=. -coverpkg=./pkg/... \
--focus="${FOCUS}" \
--randomize-all \
-tags random_test_delay \
./pkg/...
e2etests: ## Run the e2e suite against your local cluster
# Notes:
# -p: the number of programs, such as build commands or test binaries, that can be run in parallel?
# -count 1: prevents caching
# -timeout: If a test binary runs longer than TEST_TIMEOUT, panic
# -v: verbose output
cd test && CLUSTER_NAME=${CLUSTER_NAME} AZURE_ACR_NAME=${AZURE_ACR_NAME} go test \
-p 1 \
-count 1 \
-timeout ${TEST_TIMEOUT} \
-v \
./suites/$(shell echo $(TEST_SUITE) | tr A-Z a-z)/... \
--ginkgo.focus="${FOCUS}" \
--ginkgo.timeout=${TEST_TIMEOUT} \
--ginkgo.grace-period=3m \
--ginkgo.vv
benchmark:
go test -tags=test_performance -run=NoTests -bench=. ./...
deflake: ## Run randomized, racing, code-covered tests to deflake failures
for i in $(shell seq 1 5); do make battletest || exit 1; done
deflake-until-it-fails: ## Run randomized, racing tests until the test fails to catch flakes
ginkgo \
--race \
--focus="${FOCUS}" \
--randomize-all \
--until-it-fails \
-v \
./pkg/...
coverage:
go tool cover -html coverage.out -o coverage.html
verify: toolchain tidy download ## Verify code. Includes dependencies, linting, formatting, etc
make az-swagger-generate-clients-raw
go generate ./...
hack/boilerplate.sh
cp $(KARPENTER_CORE_DIR)/pkg/apis/crds/* pkg/apis/crds
yq -i '(.spec.versions[0].additionalPrinterColumns[] | select (.name=="Zone")) .jsonPath=".metadata.labels.karpenter\.azure\.com/zone"' \
pkg/apis/crds/karpenter.sh_nodeclaims.yaml
hack/validation/kubelet.sh
hack/validation/labels.sh
hack/validation/requirements.sh
hack/validation/common.sh
cp pkg/apis/crds/* charts/karpenter-crd/templates
hack/mutation/conversion_webhooks_injection.sh
hack/github/dependabot.sh
$(foreach dir,$(MOD_DIRS),cd $(dir) && golangci-lint run $(newline))
@git diff --quiet ||\
{ echo "New file modification detected in the Git working tree. Please check in before commit."; git --no-pager diff --name-only | uniq | awk '{print " - " $$0}'; \
if [ "${CI}" = true ]; then\
exit 1;\
fi;}
# TODO: restore codegen if needed; decide on the future of docgen
#@echo "Validating codegen/docgen build scripts..."
#@find hack/code hack/docs -name "*.go" -type f -print0 | xargs -0 -I {} go build -o /dev/null {}
actionlint -oneline
vulncheck: ## Verify code vulnerabilities
@govulncheck ./pkg/...
codegen: ## Auto generate files based on Azure API responses
./hack/codegen.sh
snapshot: az-login ## Builds and publishes snapshot release
$(WITH_GOFLAGS) ./hack/release/snapshot.sh
release: az-login ## Builds and publishes stable release
$(WITH_GOFLAGS) ./hack/release/release.sh
toolchain: ## Install developer toolchain
./hack/toolchain.sh
tidy: ## Recursively "go mod tidy" on all directories where go.mod exists
$(foreach dir,$(MOD_DIRS),cd $(dir) && go mod tidy $(newline))
download: ## Recursively "go mod download" on all directories where go.mod exists
$(foreach dir,$(MOD_DIRS),cd $(dir) && go mod download $(newline))
.PHONY: help test battletest e2etests verify tidy download codegen toolchain vulncheck snapshot release
define newline
endef