Improve Makefile help and implementation

This allows more granular tasks and composition.

Also improved the documentation.

Signed-off-by: Marco Franssen <[email protected]>
This commit is contained in:
Marco Franssen
2023-07-19 22:49:25 +02:00
parent db0603825c
commit 4848c48b1f
+15 -12
View File
@@ -2,7 +2,7 @@ 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%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
@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:
@@ -15,10 +15,10 @@ lint-release: ## Lint the charts using chart-testing for release
@echo Linting charts…
@ct lint --config ct.yaml --target-branch $(TARGET_BRANCH)
##@ Testing:
##@ Testing: (ensure to run on dedicated test cluster)
.PHONY: clean-lingering-resources
clean-lingering-resources:
.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
@@ -30,17 +30,20 @@ clean-lingering-resources:
&>/dev/null || true
.PHONY: test
test: install-test-dependencies ## Run tests using Helm chart-testing (ensure to run on dedicated test cluster)
@echo Running tests…
@ct install --config ct.yaml
test: install-test-deps test-charts test-examples ## Run all chart tests and example tests
.PHONY: install-test-dependencies
install-test-dependencies: ## Install test dependency resources
.PHONY: install-test-deps
install-test-deps: ## Install test dependency resources
@echo Installing test dependencies…
@.github/tests/pre-install.sh
.PHONY: cleanup-test-dependencies
cleanup-test-dependencies: ## Cleans up all test dependencies resources
.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
@@ -59,4 +62,4 @@ test-example-%:
@echo
.PHONY: test-examples
test-examples: $(patsubst examples/%/values.yaml,test-example-%,$(wildcard examples/*/values.yaml)) ## Run helm install for and helm test for all the 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`