-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
114 lines (79 loc) · 4.16 KB
/
Copy pathMakefile
File metadata and controls
114 lines (79 loc) · 4.16 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
.DEFAULT_GOAL := help
UV ?= uv
UV_PYTHON ?=
PACKAGE ?=
COVERAGE_FAIL_UNDER ?= 80
TEST_ARGS ?=
RUN = $(if $(UV_PYTHON),UV_PYTHON=$(UV_PYTHON)) $(UV) run
.PHONY: all help install install-all install-dev install-test install-test-extras install-docs check verify diff-check lint format-check format fix type-check dependency-check workflow-check manifest-check test test-serial test-parallel coverage build package-check package-verify docs docs-check linkcheck build-docs serve-docs hooks clean
help: ## Show available commands
@awk 'BEGIN {FS = ":.*## "}; /^[a-zA-Z0-9_-]+:.*## / {printf "%-18s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
install: install-all ## Install all development dependencies
install-all: ## Install every optional dependency group
$(UV) sync --all-groups --locked
install-dev: ## Install dependencies for static checks
$(UV) sync --group dev --locked
install-test: ## Install dependencies for tests
$(UV) sync --group test --locked $(if $(UV_PYTHON),--python $(UV_PYTHON))
install-test-extras: ## Install optional test utilities
$(UV) sync --group test --group test-extras --locked $(if $(UV_PYTHON),--python $(UV_PYTHON))
install-docs: ## Install dependencies for documentation
$(UV) sync --group docs --locked
all: verify ## Run the complete verification suite
check: diff-check lint format-check type-check dependency-check workflow-check ## Run fast, non-mutating code checks
verify: check test manifest-check build docs-check ## Run all local CI checks
diff-check: ## Check the diff for whitespace errors
git diff --check
lint: ## Check code with Ruff
$(RUN) ruff check
format-check: ## Check formatting with Ruff
$(RUN) ruff format --check
format: ## Format code with Ruff
$(RUN) ruff format
fix: ## Apply Ruff lint fixes and formatting
$(RUN) ruff check --fix
$(RUN) ruff format
type-check: ## Check static types with ty
$(RUN) ty check
dependency-check: ## Check dependency declarations with Deptry
$(RUN) deptry .
workflow-check: ## Audit GitHub Actions workflows with Zizmor
$(RUN) zizmor .github/workflows
manifest-check: ## Check source distribution contents
$(RUN) check-manifest
test: ## Run tests serially
$(RUN) pytest $(TEST_ARGS)
test-serial: test ## Run tests without parallel workers
test-parallel: ## Run independent tests with parallel workers
$(RUN) pytest -n auto $(TEST_ARGS)
coverage: ## Enforce coverage for PACKAGE
@test -n "$(PACKAGE)" || { echo "Set PACKAGE to the library import name."; exit 2; }
$(RUN) pytest $(TEST_ARGS) --cov="$(PACKAGE)" --cov-branch --cov-report=term-missing:skip-covered --cov-fail-under="$(COVERAGE_FAIL_UNDER)"
build: ## Build source and wheel distributions
rm -rf dist
$(UV) build --sdist --wheel
$(RUN) twine check dist/*
package-check: ## Build, install, and import PACKAGE in an isolated environment
@test -n "$(PACKAGE)" || { echo "Set PACKAGE to the library import name."; exit 2; }
@temp_dir=$$(mktemp -d); trap 'rm -rf "$$temp_dir"' EXIT; \
$(UV) build --wheel --out-dir "$$temp_dir/dist"; \
$(RUN) check-wheel-contents "$$temp_dir"/dist/*.whl; \
$(UV) venv --no-project "$$temp_dir/venv"; \
$(UV) pip install --python "$$temp_dir/venv/bin/python" "$$temp_dir"/dist/*.whl; \
cd "$$temp_dir" && "$$temp_dir/venv/bin/python" -c 'import importlib; importlib.import_module("$(PACKAGE)")'
package-verify: package-check coverage ## Run package import and coverage checks
docs: ## Build HTML documentation
$(RUN) sphinx-build -M html docs docs/_build
docs-check: ## Build documentation and fail on warnings
$(RUN) sphinx-build -M html docs docs/_build -W --keep-going
linkcheck: ## Check documentation links and fail on warnings
$(RUN) sphinx-build -M linkcheck docs docs/_build -W --keep-going
build-docs: docs ## Build HTML documentation
serve-docs: ## Serve documentation with live reload
$(RUN) sphinx-autobuild -b html docs docs/_build/html
hooks: ## Run all pre-commit hooks (may modify files)
$(RUN) pre-commit run --all-files
clean: ## Remove generated files and caches
rm -rf build dist docs/_build .coverage htmlcov .pytest_cache .ruff_cache .ty
find . -maxdepth 1 -type d -name "*.egg-info" -prune -exec rm -rf {} +
find . -path ./.venv -prune -o -type d -name __pycache__ -prune -exec rm -rf {} +