Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (66 loc) · 2.77 KB
/
Copy pathMakefile
File metadata and controls
81 lines (66 loc) · 2.77 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
# Simple Makefile for use with a uv-based development environment
# The at (@) prefix tells make to suppress output from the command
# The hyphen (-) prefix tells make to ignore errors (e.g., if a directory doesn't exist)
.PHONY: install
install: ## Install the virtual environment, the Git hooks, and Prettier for use by an editor
@echo "🚀 Creating uv Python virtual environment"
@uv sync
@echo "🚀 Installing Git prek hooks locally"
@uv run prek install -f
@echo "🚀 Installing Prettier using npm"
@npm install -q --no-fund --include=dev
.PHONY: check
check: ## Run the quality checks on the documents and the code
@echo "🚀 Checking lock file consistency with 'pyproject.toml'"
@uv lock --locked
@echo "🚀 Auto-formatting/Linting documents and code: Running prek"
@uv run prek run -a
@echo "🚀 Static type checking: Running ty"
@uv run ty check
.PHONY: format
format: ## Format the code with ruff and the documents with Prettier
@echo "🚀 Formatting code: Running ruff"
@uv run ruff format
@echo "🚀 Formatting documents: Running Prettier"
@npx prettier --write --ignore-unknown .
.PHONY: lint
lint: ## Lint the code with ruff, fixing what it can
@uv run ruff check --fix
.PHONY: ty
ty: ## Type check the code with ty
@uv run ty check
.PHONY: test
test: ## Test the documents and the harness with pytest
@echo "🚀 Testing documents and code: Running pytest"
@uv run pytest
# Define variables for files/directories to clean
TY_DIRS = .ty_cache
TEST_DIRS = .cache .pytest_cache
.PHONY: clean-ty
clean-ty: ## Clean ty artifacts
@echo "🚀 Removing ty artifacts"
@uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(TY_DIRS)'.split() if os.path.isdir(d)]"
.PHONY: clean-pycache
clean-pycache: ## Clean pycache artifacts
@echo "🚀 Removing pycache artifacts"
@-find . -type d -name "__pycache__" -not -path "./.venv/*" -not -path "./node_modules/*" -exec rm -r {} +
.PHONY: clean-ruff
clean-ruff: ## Clean ruff artifacts
@echo "🚀 Removing ruff artifacts"
@uv run ruff clean
.PHONY: clean-test
clean-test: ## Clean test artifacts
@echo "🚀 Removing test artifacts"
@uv run python -c "import shutil; import os; [shutil.rmtree(d, ignore_errors=True) for d in '$(TEST_DIRS)'.split() if os.path.isdir(d)]"
.PHONY: clean-node
clean-node: ## Clean what npm installed
@echo "🚀 Removing node_modules"
@rm -rf node_modules package-lock.json
.PHONY: clean
clean: clean-ty clean-pycache clean-ruff clean-test clean-node ## Clean all artifacts
@echo "🚀 Cleaned all artifacts"
.PHONY: help
help:
@uv run python -c "import re; \
[[print(f'\033[36m{m[0]:<20}\033[0m {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open(makefile).read(), re.M)] for makefile in ('$(MAKEFILE_LIST)').strip().split()]"
.DEFAULT_GOAL := help