-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
108 lines (89 loc) · 3.58 KB
/
Copy pathMakefile
File metadata and controls
108 lines (89 loc) · 3.58 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
.PHONY: help install lint test test-slow test-durations coverage clean docs docs-serve docs-build
# ==============================================================================
# Venv
# ==============================================================================
UV := $(shell command -v uv 2> /dev/null)
VENV_DIR?=.venv
PYTHON := $(VENV_DIR)/bin/python
# ==============================================================================
# Targets
# ==============================================================================
help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " install Install dependencies"
@echo " lint Run linter and type checker"
@echo " test Run tests (excludes slow tests)"
@echo " test-slow Run slow CLI scaffolding tests"
@echo " test-durations Show 20 slowest tests"
@echo " coverage Run tests with coverage reporting"
@echo " migrate Generate a new migration (use MSG='description')"
@echo " upgrade Apply pending migrations"
@echo " downgrade Revert last migration"
@echo " docs-serve Serve documentation locally with live reload"
@echo " docs-build Build documentation site"
@echo " docs Alias for docs-serve"
@echo " clean Clean up temporary files"
@echo ""
@echo "Docker images for 'chapkit run' live in dhis2-chap/chapkit-images;"
@echo "this repo no longer builds them."
install:
@echo ">>> Installing dependencies"
@$(UV) sync --all-extras
lint:
@echo ">>> Running linter"
@$(UV) run ruff format .
@$(UV) run ruff check . --fix
@echo ">>> Running type checker"
@$(UV) run mypy --explicit-package-bases src tests examples
@$(UV) run pyright
test:
@echo ">>> Running tests (excluding slow)"
@$(UV) run pytest -q -m "not slow"
test-slow:
@echo ">>> Running slow CLI scaffolding tests"
@$(UV) run pytest -v -m slow tests/test_cli_scaffolding.py
test-durations:
@echo ">>> Running tests and showing 20 slowest"
@$(UV) run pytest -q -m "not slow" --durations=20
coverage:
@echo ">>> Running tests with coverage (excluding slow)"
@$(UV) run coverage run -m pytest -q -m "not slow"
@$(UV) run coverage report
@$(UV) run coverage xml
migrate:
@echo ">>> Generating migration: $(MSG)"
@$(UV) run alembic revision --autogenerate -m "$(MSG)"
@echo ">>> Formatting migration file"
@$(UV) run ruff format src/chapkit/alembic/versions
upgrade:
@echo ">>> Applying pending migrations"
@$(UV) run alembic upgrade head
downgrade:
@echo ">>> Reverting last migration"
@$(UV) run alembic downgrade -1
# NO_MKDOCS_2_WARNING silences the Material for MkDocs promotional banner.
docs-serve:
@echo ">>> Serving documentation at http://127.0.0.1:8000"
@NO_MKDOCS_2_WARNING=1 $(UV) run mkdocs serve
docs-build:
@echo ">>> Building documentation site"
@NO_MKDOCS_2_WARNING=1 $(UV) run mkdocs build
docs: docs-serve
clean:
@echo ">>> Cleaning up"
@find . -type f -name "*.pyc" -delete
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".mypy_cache" -exec rm -rf {} + 2>/dev/null || true
@rm -rf .coverage htmlcov coverage.xml
@rm -rf .pyright
@rm -rf dist build *.egg-info
@find examples -type f -name "uv.lock" -delete
@find examples -type d -name ".venv" -exec rm -rf {} + 2>/dev/null || true
# ==============================================================================
# Default
# ==============================================================================
.DEFAULT_GOAL := help