-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile
70 lines (57 loc) · 2.84 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
TARGET_BRANCH ?= main
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Linting:
.PHONY: lint
lint: ## Lint the charts using chart-testing
@echo Linting charts…
@ct lint --config ct.yaml --target-branch $(TARGET_BRANCH) --check-version-increment=false
lint-release: ## Lint the charts using chart-testing for release
@echo Linting charts…
@ct lint --config ct.yaml --target-branch $(TARGET_BRANCH)
##@ Testing: (ensure to run on dedicated test cluster)
.PHONY: clean-test-leftovers
clean-test-leftovers: ## Cleans up any lingering resources in case tests fail massively
@echo Cleanup potential leftovers…
@-kubectl delete csidrivers.storage.k8s.io csi.spiffe.io \
&>/dev/null || true
@-kubectl delete ns \
$$(kubectl get ns -o json | jq -r '.items[] | .metadata.name' | grep spire) \
&>/dev/null || true
@-kubectl delete validatingwebhookconfigurations.admissionregistration.k8s.io \
$$(kubectl get validatingwebhookconfigurations.admissionregistration.k8s.io -o json | jq -r '.items[] | .metadata.name' | grep spire) \
&>/dev/null || true
.PHONY: test
test: install-test-deps test-charts test-examples ## Run all chart tests and example tests
.PHONY: install-test-deps
install-test-deps: ## Install test dependency resources
@echo Installing test dependencies…
@.github/tests/pre-install.sh
.PHONY: test-charts
test-charts: ## Run tests on charts using Helm chart-testing
@echo Running tests…
@ct install --config ct.yaml
.PHONY: cleanup-test-deps
cleanup-test-deps: ## Cleans up all test dependencies resources
@echo Uninstalling test dependencies…
@helm uninstall -n cert-manager cert-manager 2>/dev/null || true
@kubectl delete ns cert-manager 2>/dev/null || true
@helm uninstall -n prometheus kube-prometheus-stack 2>/dev/null || true
@kubectl delete ns prometheus 2>/dev/null || true
@helm uninstall -n mysql mysql 2>/dev/null|| true
@kubectl delete ns mysql 2>/dev/null || true
@helm uninstall -n postgresql postgresql 2>/dev/null || true
@kubectl delete ns postgresql 2>/dev/null || true
@helm uninstall -n ingress-nginx ingress-nginx 2>/dev/null || true
@kubectl delete ns ingress-nginx 2>/dev/null || true
test-example-%:
@echo Running tests for $* example…
@examples/$*/run-tests.sh
@echo
.PHONY: test-examples
test-examples: $(patsubst examples/%/values.yaml,test-example-%,$(wildcard examples/*/values.yaml)) ## Run `helm install` and `helm test` for all the examples containing `run-tests.sh`
.PHONY: diagrams
diagrams: ## Builds diagrams
@dot -Tpng examples/nested/singlehardened.dot > examples/nested/singlehardened.png
@dot -Tpng examples/nested/multicluster.dot > examples/nested/multicluster.png