Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Improve Makefile help and implementation
Browse files Browse the repository at this point in the history
This allows more granular tasks and composition.

Also improved the documentation.

Signed-off-by: Marco Franssen <marco.franssen@gmail.com>
  • Loading branch information
marcofranssen committed Jul 19, 2023
1 parent db06038 commit 4848c48
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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`

0 comments on commit 4848c48

Please sign in to comment.