|
| 1 | +# boilplate — local dev convenience targets |
| 2 | +# Run `make help` to see what's available. |
| 3 | +# |
| 4 | +# All Python work is done through `uv`, which manages the .venv automatically. |
| 5 | +# Install uv: https://docs.astral.sh/uv/getting-started/installation/ |
| 6 | + |
| 7 | +UV ?= uv |
| 8 | +PORT ?= 8000 |
| 9 | +VENV := .venv |
| 10 | +RUN := $(UV) run |
| 11 | + |
| 12 | +.DEFAULT_GOAL := help |
| 13 | + |
| 14 | +# ---- meta ------------------------------------------------------------------ |
| 15 | + |
| 16 | +.PHONY: help |
| 17 | +help: ## Show this help. |
| 18 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage: \033[36mmake <target>\033[0m\n\nTargets:\n"} \ |
| 19 | + /^[a-zA-Z0-9_.-]+:.*##/ { printf " \033[36m%-16s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) |
| 20 | + @echo |
| 21 | + |
| 22 | +.PHONY: check-uv |
| 23 | +check-uv: |
| 24 | + @command -v $(UV) >/dev/null 2>&1 || { \ |
| 25 | + echo "error: 'uv' is not installed."; \ |
| 26 | + echo " install it from https://docs.astral.sh/uv/getting-started/installation/"; \ |
| 27 | + exit 1; \ |
| 28 | + } |
| 29 | + |
| 30 | +# ---- environment ----------------------------------------------------------- |
| 31 | + |
| 32 | +$(VENV): pyproject.toml |
| 33 | + $(UV) sync |
| 34 | + @touch $(VENV) |
| 35 | + |
| 36 | +.PHONY: install |
| 37 | +install: check-uv $(VENV) ## Create .venv and install all dependencies (incl. dev). |
| 38 | + |
| 39 | +.PHONY: lock |
| 40 | +lock: check-uv ## Refresh uv.lock from pyproject.toml. |
| 41 | + $(UV) lock |
| 42 | + |
| 43 | +.PHONY: upgrade |
| 44 | +upgrade: check-uv ## Upgrade all dependencies to the latest allowed versions. |
| 45 | + $(UV) lock --upgrade |
| 46 | + $(UV) sync |
| 47 | + |
| 48 | +# ---- docs ------------------------------------------------------------------ |
| 49 | + |
| 50 | +.PHONY: serve |
| 51 | +serve: install ## Run the docs site locally with live reload (http://localhost:$(PORT)). |
| 52 | + $(RUN) mkdocs serve -a 0.0.0.0:$(PORT) |
| 53 | + |
| 54 | +.PHONY: build |
| 55 | +build: install ## Build the static site into ./site (strict mode + htmlproofer). |
| 56 | + $(RUN) mkdocs build --strict |
| 57 | + |
| 58 | +.PHONY: links |
| 59 | +links: ## Run lychee link checker against docs/ and README. Requires lychee in PATH. |
| 60 | + @command -v lychee >/dev/null 2>&1 || { \ |
| 61 | + echo "error: 'lychee' is not installed."; \ |
| 62 | + echo " install it from https://lychee.cli.rs/installation/"; \ |
| 63 | + exit 1; \ |
| 64 | + } |
| 65 | + lychee --config lychee.toml --cache --max-cache-age 7d 'docs/**/*.md' README.md |
| 66 | + |
| 67 | +# ---- quality --------------------------------------------------------------- |
| 68 | + |
| 69 | +.PHONY: lint |
| 70 | +lint: install ## Run ruff lint. |
| 71 | + $(RUN) ruff check . |
| 72 | + |
| 73 | +.PHONY: format |
| 74 | +format: install ## Format Python files with ruff. |
| 75 | + $(RUN) ruff format . |
| 76 | + $(RUN) ruff check --fix . |
| 77 | + |
| 78 | +.PHONY: hooks |
| 79 | +hooks: install ## Install pre-commit git hooks. |
| 80 | + $(RUN) pre-commit install |
| 81 | + |
| 82 | +.PHONY: pre-commit |
| 83 | +pre-commit: install ## Run all pre-commit hooks against every file. |
| 84 | + $(RUN) pre-commit run --all-files |
| 85 | + |
| 86 | +# ---- terraform / opentofu -------------------------------------------------- |
| 87 | + |
| 88 | +.PHONY: tf-fmt |
| 89 | +tf-fmt: ## Format all Terraform / OpenTofu files in-tree. |
| 90 | + @command -v terraform >/dev/null 2>&1 && terraform fmt -recursive terragrunt || \ |
| 91 | + (command -v tofu >/dev/null 2>&1 && tofu fmt -recursive terragrunt) || \ |
| 92 | + (echo "neither terraform nor tofu is installed" >&2; exit 1) |
| 93 | + |
| 94 | +.PHONY: tg-fmt |
| 95 | +tg-fmt: ## Format all Terragrunt HCL files in-tree. |
| 96 | + @command -v terragrunt >/dev/null 2>&1 || (echo "terragrunt is not installed" >&2; exit 1) |
| 97 | + terragrunt hcl format |
| 98 | + |
| 99 | +# ---- housekeeping ---------------------------------------------------------- |
| 100 | + |
| 101 | +.PHONY: clean |
| 102 | +clean: ## Remove build artifacts and the virtualenv. |
| 103 | + rm -rf site $(VENV) .ruff_cache .cache |
| 104 | + |
| 105 | +.PHONY: clean-site |
| 106 | +clean-site: ## Remove only the built site. |
| 107 | + rm -rf site |
0 commit comments