-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.jinja
More file actions
43 lines (37 loc) · 1.54 KB
/
Makefile.jinja
File metadata and controls
43 lines (37 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
.PHONY: help install clean{% if "pytest" in dev_deps %} test{% endif %}
CLEAN_ROOT_DIRS := build/ dist/ .pytest_cache .ruff_cache htmlcov .coverage
CLEAN_DIRS := __pycache__ *.egg-info
CLEAN_FILES := *.pyc
help: ## Display available commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
check: ## Verify required tools and Git repository
@set -eu; \
if ! git rev-parse --git-dir >/dev/null 2>&1; then \
printf "ERROR: Not a Git repository — run 'git init' first\n" >&2; \
exit 1; \
fi
for cmd in uv pre-commit; do \
if ! command -v "$$cmd" >/dev/null 2>&1; then \
printf "ERROR: %s missing — install it\n" "$$cmd" >&2; \
exit 1; \
fi; \
done; \
install: check ## Install project dependencies
@printf "Installing pre-commit hooks...\n"
@pre-commit install || { printf "ERROR: pre-commit installation failed\n" >&2; exit 1; }
@printf "Installing project dependencies...\n"
@uv sync --extra dev || { printf "ERROR: uv sync failed\n" >&2; exit 1; }
@printf "\u2713 Installation complete\n"
{% if "pytest" in dev_deps -%}
test: check ## Run all unit tests
@set -eu; \
if [[ ! -d ".venv" ]]; then \
printf "ERROR: .venv not found — run 'make install' first\n" >&2; \
exit 1; \
fi; \
uv run pytest tests/unit/
{% endif %}
clean: ## Clean build and cache artifacts
@rm -rf $(CLEAN_ROOT_DIRS)
@for dir in $(CLEAN_DIRS); do find . -type d -name "$$dir" -exec rm -rf {} +; done
@for file in $(CLEAN_FILES); do find . -type f -name "$$file" -delete; done