|
| 1 | +SHELL := /bin/bash |
| 2 | + |
| 3 | +EXAMPLES := $(wildcard examples/*) |
| 4 | + |
| 5 | +.PHONY: help fmt fmt-check docs docs-check init validate test examples-init examples-validate check hooks |
| 6 | + |
| 7 | +help: |
| 8 | + @echo "Available targets:" |
| 9 | + @echo " make fmt Format all Terraform files" |
| 10 | + @echo " make fmt-check Check Terraform formatting" |
| 11 | + @echo " make docs Generate README Terraform docs" |
| 12 | + @echo " make docs-check Check README Terraform docs are current" |
| 13 | + @echo " make init Initialize the root module" |
| 14 | + @echo " make validate Validate the root module" |
| 15 | + @echo " make test Run native Terraform tests" |
| 16 | + @echo " make examples-init Initialize all examples" |
| 17 | + @echo " make examples-validate Validate all examples" |
| 18 | + @echo " make check Run local CI-style checks" |
| 19 | + @echo " make hooks Enable repo-local Git hooks" |
| 20 | + |
| 21 | +fmt: |
| 22 | + terraform fmt -recursive |
| 23 | + |
| 24 | +fmt-check: |
| 25 | + terraform fmt -check -recursive |
| 26 | + |
| 27 | +docs: |
| 28 | + scripts/terraform-docs.sh |
| 29 | + |
| 30 | +docs-check: |
| 31 | + scripts/terraform-docs.sh --check |
| 32 | + |
| 33 | +init: |
| 34 | + terraform init -backend=false |
| 35 | + |
| 36 | +validate: |
| 37 | + terraform validate |
| 38 | + |
| 39 | +test: |
| 40 | + terraform test -no-color |
| 41 | + |
| 42 | +examples-init: |
| 43 | + @for example in $(EXAMPLES); do \ |
| 44 | + if [ -d "$$example" ]; then \ |
| 45 | + echo "Initializing $$example"; \ |
| 46 | + terraform -chdir="$$example" init -backend=false; \ |
| 47 | + fi; \ |
| 48 | + done |
| 49 | + |
| 50 | +examples-validate: |
| 51 | + @for example in $(EXAMPLES); do \ |
| 52 | + if [ -d "$$example" ]; then \ |
| 53 | + echo "Validating $$example"; \ |
| 54 | + terraform -chdir="$$example" validate; \ |
| 55 | + fi; \ |
| 56 | + done |
| 57 | + |
| 58 | +check: fmt-check docs-check init validate test examples-init examples-validate |
| 59 | + |
| 60 | +hooks: |
| 61 | + git config core.hooksPath .githooks |
0 commit comments