-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (75 loc) · 3.82 KB
/
Makefile
File metadata and controls
97 lines (75 loc) · 3.82 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
# Canonical hawk-eco Makefile for Python repos.
# Source of truth: .shared-templates/Makefile.python.tmpl at the eco root.
# Placeholders rendered per repo: hawk-sdk.
# ---------------------------------------------------------------------------
# Project metadata
# ---------------------------------------------------------------------------
NAME := hawk-sdk
# ---------------------------------------------------------------------------
# Versioning — sourced from VERSION file at repo root (single source of
# truth, also consumed by hatch + release-please).
# ---------------------------------------------------------------------------
VERSION ?= $(shell cat VERSION 2>/dev/null | head -n1 | tr -d '[:space:]' || echo "dev")
PYTHON ?= python3
PIP ?= $(PYTHON) -m pip
# ---------------------------------------------------------------------------
# Phony declarations (alphabetical).
# ---------------------------------------------------------------------------
.PHONY: all bench build ci clean cover fmt help install lint lint-fix \
release security test test-race tidy version vet
# ---------------------------------------------------------------------------
# Default target.
# ---------------------------------------------------------------------------
all: lint test build ## Default — lint, test, build.
# ---------------------------------------------------------------------------
# Build / install / release.
# ---------------------------------------------------------------------------
build: ## Build wheel + sdist into dist/.
$(PYTHON) -m build
install: ## Install in editable mode with dev extras.
$(PIP) install -e ".[dev]"
release: build ## Upload to PyPI (expects $TWINE_USERNAME / $TWINE_PASSWORD).
$(PYTHON) -m twine upload dist/*
# ---------------------------------------------------------------------------
# Tests.
# ---------------------------------------------------------------------------
test: ## Run unit tests.
$(PYTHON) -m pytest
test-race: test ## Alias for `test` (Python has no race detector).
cover: ## Run tests with coverage report.
$(PYTHON) -m pytest --cov=src --cov-report=term-missing --cov-report=html
@echo "Coverage report: htmlcov/index.html"
bench: ## Run benchmarks (requires pytest-benchmark).
$(PYTHON) -m pytest --benchmark-only
# ---------------------------------------------------------------------------
# Quality gates.
# ---------------------------------------------------------------------------
fmt: ## Format with ruff.
$(PYTHON) -m ruff format .
vet: ## Type-check with mypy.
$(PYTHON) -m mypy src/
lint: ## Lint with ruff.
$(PYTHON) -m ruff check .
lint-fix: ## Lint with ruff --fix.
$(PYTHON) -m ruff check --fix .
security: ## Run pip-audit on resolved dependencies.
@command -v pip-audit >/dev/null 2>&1 || (echo "install: pip install pip-audit" && exit 1)
pip-audit
tidy: ## No-op for Python (lockfile management is via pyproject.toml).
@echo "tidy: nothing to do for Python repos."
# ---------------------------------------------------------------------------
# Composite gate used by CI and pre-push.
# ---------------------------------------------------------------------------
ci: fmt vet lint test security ## Run everything CI runs.
@echo "All CI checks passed."
# ---------------------------------------------------------------------------
# Misc.
# ---------------------------------------------------------------------------
version: ## Print the version that will be packaged.
@echo "Version: $(VERSION)"
clean: ## Remove build artefacts and caches.
rm -rf dist/ build/ *.egg-info htmlcov/ .coverage
rm -rf .pytest_cache .mypy_cache .ruff_cache
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
help: ## Show this help.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'