From 4848c48b1f8d64356a32a5425a8a40ba51e6685a Mon Sep 17 00:00:00 2001 From: Marco Franssen Date: Fri, 23 Jun 2023 11:22:11 +0200 Subject: [PATCH] Improve Makefile help and implementation This allows more granular tasks and composition. Also improved the documentation. Signed-off-by: Marco Franssen --- Makefile | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 7b4705e7a..c3ad2d647 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ TARGET_BRANCH ?= main .PHONY: help help: ## Display this help. - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\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\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`