-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
134 lines (102 loc) · 4.23 KB
/
Copy pathMakefile
File metadata and controls
134 lines (102 loc) · 4.23 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
MDLINT ?= markdownlint-cli2
NIXIE ?= nixie
MDFORMAT_ALL ?= mdformat-all
export PATH := $(HOME)/.local/bin:$(HOME)/.bun/bin:$(PATH)
UV ?= $(shell command -v uv 2>/dev/null || printf '%s/.local/bin/uv' "$$HOME")
USER_CARGO := $(HOME)/.cargo/bin/cargo
USER_WHITAKER := $(HOME)/.local/bin/whitaker
USER_BIN_PATH := $(HOME)/.cargo/bin:$(HOME)/.local/bin:$(HOME)/.bun/bin
TOOLS = $(MDFORMAT_ALL) $(MDLINT)
VENV_TOOLS = pytest
UV_ENV = PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 UV_CACHE_DIR=.uv-cache UV_TOOL_DIR=.uv-tools
TYPOS_VERSION ?= 1.48.0
TYPOS = env $(UV_ENV) $(UV) tool run typos@$(TYPOS_VERSION)
MD_FILES_FIND = find . -type f -name '*.md' -not -path './.git/*' -print0
WITH_ACT ?= 0
ACT_TEST_ENV = $(if $(filter 1 true yes on,$(WITH_ACT)),RUN_ACT_VALIDATION=1,)
PYTEST_XDIST_WORKERS ?= auto
PYTHON_TARGETS ?= df12_python_lints tests
PYLINT_PYTHON ?= pypy
PYLINT_TARGETS ?= $(PYTHON_TARGETS)
PYLINT_PYPY_SHIM_REF ?= 726d09f968b4d729ee4b29c71fc732e744854f3b
PYLINT_PYPY_SHIM = git+https://github.com/leynos/pylint-pypy-shim.git@$(PYLINT_PYPY_SHIM_REF)
PYLINT = $(UV_ENV) $(UV) tool run --python $(PYLINT_PYTHON) --from '$(PYLINT_PYPY_SHIM)' pylint-pypy
.PHONY: help all audit clean build build-release crosshair lint lint-python fmt check-fmt \
markdownlint nixie spelling test typecheck $(TOOLS) $(VENV_TOOLS)
.DEFAULT_GOAL := all
all: build check-fmt lint typecheck test
+$(MAKE) spelling
define ensure_uv
@command -v $(UV) >/dev/null 2>&1 || { \
printf "Error: uv is required, but '%s' was not found or is not executable\n" "$(UV)" >&2; \
exit 1; \
}
endef
.venv: pyproject.toml
$(call ensure_uv)
$(UV_ENV) $(UV) venv --clear
build: .venv ## Build virtual-env and install deps
$(UV_ENV) $(UV) sync --group dev
build-release: ## Build artefacts (sdist & wheel)
$(call ensure_uv)
$(UV_ENV) $(UV) run python -m build --sdist --wheel
clean: ## Remove build artifacts
rm -rf build dist *.egg-info \
.mypy_cache .pytest_cache .coverage coverage.* \
lcov.info htmlcov .venv .uv-cache .uv-tools \
.typos-oxendict-base.json .typos-oxendict-base.toml
find . -type d -name '__pycache__' -print0 | xargs -0 -r rm -rf
define ensure_tool
@command -v $(1) >/dev/null 2>&1 || { \
printf "Error: '%s' is required, but not installed\n" "$(1)" >&2; \
exit 1; \
}
endef
define ensure_tool_venv
@$(UV_ENV) $(UV) run which $(1) >/dev/null 2>&1 || { \
printf "Error: '%s' is required in the virtualenv, but is not installed\n" "$(1)" >&2; \
exit 1; \
}
endef
ifneq ($(strip $(TOOLS)),)
$(TOOLS): ## Verify required CLI tools
$(call ensure_tool,$@)
endif
ifneq ($(strip $(VENV_TOOLS)),)
.PHONY: $(VENV_TOOLS)
$(VENV_TOOLS): build ## Verify required CLI tools in venv
$(call ensure_tool_venv,$@)
endif
fmt: build $(MDFORMAT_ALL) ## Format sources
$(UV_ENV) $(UV) run ruff format $(PYTHON_TARGETS)
$(UV_ENV) $(UV) run ruff check --select I --fix $(PYTHON_TARGETS)
$(MDFORMAT_ALL)
check-fmt: build ## Verify formatting
$(UV_ENV) $(UV) run ruff format --check $(PYTHON_TARGETS)
# mdformat-all doesn't currently do checking
lint: lint-python ## Run linters
lint-python: build ## Run Python linters
$(UV_ENV) $(UV) run ruff check $(PYTHON_TARGETS)
$(UV_ENV) $(UV) run interrogate --fail-under 100 $(PYTHON_TARGETS)
$(PYLINT) $(PYLINT_TARGETS)
typecheck: build ## Run typechecking
$(UV_ENV) $(UV) run ty --version
$(UV_ENV) $(UV) run ty check $(PYTHON_TARGETS)
audit: build ## Audit dependencies for known vulnerabilities
$(UV_ENV) $(UV) run pip-audit
markdownlint: $(MDLINT) ## Lint Markdown files and spelling
env -u NO_COLOR $(MDLINT) '**/*.md'
+$(MAKE) spelling
spelling: ## Enforce en-GB-oxendict spelling
$(UV) run scripts/generate_typos_config.py
$(MD_FILES_FIND) | xargs -0 $(TYPOS) --config typos.toml --force-exclude
nixie: ## Validate Mermaid diagrams
$(call ensure_tool,$(NIXIE))
$(NIXIE) --no-sandbox
test: build $(VENV_TOOLS) ## Run tests
$(UV_ENV) $(ACT_TEST_ENV) $(UV) run pytest -v -n $(PYTEST_XDIST_WORKERS)
crosshair: build ## Model-check pure kernels with CrossHair
$(UV_ENV) RUN_CROSSHAIR=1 $(UV) run pytest -v tests/test_crosshair.py
help: ## Show available targets
@grep -E '^[a-zA-Z_-]+:.*?##' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS=":.*##"; printf "Available targets:\n"} {gsub(/^[[:space:]]+/, "", $$2); printf " %-20s %s\n", $$1, $$2}'