|
| 1 | +MAKEFLAGS += --warn-undefined-variables |
| 2 | +SHELL := bash |
| 3 | +.SHELLFLAGS := -eu -o pipefail -c |
| 4 | +.DEFAULT_GOAL := all |
| 5 | +.DELETE_ON_ERROR: |
| 6 | +.SUFFIXES: |
| 7 | + |
| 8 | +include Makefile.vars.mk |
| 9 | + |
| 10 | +.PHONY: help |
| 11 | +help: ## Show this help |
| 12 | + @grep -E -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = "(: ).*?## "}; {gsub(/\\:/,":", $$1)}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' |
| 13 | + |
| 14 | +.PHONY: all |
| 15 | +all: lint |
| 16 | + |
| 17 | +.PHONY: lint |
| 18 | +lint: lint_jsonnet lint_yaml lint_adoc lint_kubent ## All-in-one linting |
| 19 | + |
| 20 | +.PHONY: lint_jsonnet |
| 21 | +lint_jsonnet: $(JSONNET_FILES) ## Lint jsonnet files |
| 22 | + $(JSONNET_DOCKER) $(JSONNETFMT_ARGS) --test -- $? |
| 23 | + |
| 24 | +.PHONY: lint_yaml |
| 25 | +lint_yaml: ## Lint yaml files |
| 26 | + $(YAMLLINT_DOCKER) -f parsable -c $(YAMLLINT_CONFIG) $(YAMLLINT_ARGS) -- . |
| 27 | + |
| 28 | +.PHONY: lint_adoc |
| 29 | +lint_adoc: ## Lint documentation |
| 30 | + $(VALE_CMD) $(VALE_ARGS) |
| 31 | +.PHONY: lint_kubent |
| 32 | +lint_kubent: ## Check for deprecated Kubernetes API versions |
| 33 | + $(KUBENT_DOCKER) $(KUBENT_ARGS) -f $(KUBENT_FILES) |
| 34 | + |
| 35 | +.PHONY: format |
| 36 | +format: format_jsonnet ## All-in-one formatting |
| 37 | + |
| 38 | +.PHONY: format_jsonnet |
| 39 | +format_jsonnet: $(JSONNET_FILES) ## Format jsonnet files |
| 40 | + $(JSONNET_DOCKER) $(JSONNETFMT_ARGS) -- $? |
| 41 | + |
| 42 | +.PHONY: docs-serve |
| 43 | +docs-serve: ## Preview the documentation |
| 44 | + $(ANTORA_PREVIEW_CMD) |
| 45 | + |
| 46 | +.PHONY: compile |
| 47 | +.compile: |
| 48 | + mkdir -p dependencies |
| 49 | + $(COMPILE_CMD) |
| 50 | + |
| 51 | +.PHONY: test |
| 52 | +test: commodore_args += -f tests/$(instance).yml |
| 53 | +test: .compile ## Compile the component |
| 54 | +.PHONY: gen-golden |
| 55 | +gen-golden: commodore_args += -f tests/$(instance).yml |
| 56 | +gen-golden: clean .compile ## Update the reference version for target `golden-diff`. |
| 57 | + @rm -rf tests/golden/$(instance) |
| 58 | + @mkdir -p tests/golden/$(instance) |
| 59 | + @cp -R compiled/. tests/golden/$(instance)/. |
| 60 | + |
| 61 | +.PHONY: golden-diff |
| 62 | +golden-diff: commodore_args += -f tests/$(instance).yml |
| 63 | +golden-diff: clean .compile ## Diff compile output against the reference version. Review output and run `make gen-golden golden-diff` if this target fails. |
| 64 | + @git diff --exit-code --minimal --no-index -- tests/golden/$(instance) compiled/ |
| 65 | + |
| 66 | +.PHONY: golden-diff-all |
| 67 | +golden-diff-all: recursive_target=golden-diff |
| 68 | +golden-diff-all: $(test_instances) ## Run golden-diff for all instances. Note: this doesn't work when running make with multiple parallel jobs (-j != 1). |
| 69 | + |
| 70 | +.PHONY: gen-golden-all |
| 71 | +gen-golden-all: recursive_target=gen-golden |
| 72 | +gen-golden-all: $(test_instances) ## Run gen-golden for all instances. Note: this doesn't work when running make with multiple parallel jobs (-j != 1). |
| 73 | + |
| 74 | +.PHONY: lint_kubent_all |
| 75 | +lint_kubent_all: recursive_target=lint_kubent |
| 76 | +lint_kubent_all: $(test_instances) ## Lint deprecated Kubernetes API versions for all golden test instances. Will exit on first error. Note: this doesn't work when running make with multiple parallel jobs (-j != 1). |
| 77 | + |
| 78 | +.PHONY: $(test_instances) |
| 79 | +$(test_instances): |
| 80 | + $(MAKE) $(recursive_target) -e instance=$(basename $(@F)) |
| 81 | + |
| 82 | +.PHONY: clean |
| 83 | +clean: ## Clean the project |
| 84 | + rm -rf .cache compiled dependencies vendor helmcharts jsonnetfile*.json || true |
0 commit comments