-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (94 loc) · 2.94 KB
/
Makefile
File metadata and controls
112 lines (94 loc) · 2.94 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
SHELL := sh
.ONESHELL:
.SHELLFLAGS := -eu -c
.DELETE_ON_ERROR:
SOURCES_PATH := src
TESTS_PATH := tests
# load environment config from .env if able
-include .env
ifndef UV_VERSION
UV_VERSION := 0.11.7
endif
.PHONY: uv_check venv sync update format lint test docs docs-server docs-format docs-lint release
# Check installed UV version and install if needed
uv_check:
@echo 'Checking uv version...'
# Install if not present
@if ! command -v uv > /dev/null; then \
echo '...installing uv...'; \
curl -fLsS https://astral.sh/uv/install.sh | sh; \
if [ $$? -ne 0 ]; then \
echo "...installing uv failed!"; \
exit 1; \
fi; \
fi
# Check version and update if needed
@if command -v uv > /dev/null; then \
CURRENT_VERSION=$$(uv --version | head -n1 | cut -d" " -f2); \
if [ "$$(printf "%s\n%s" "$(UV_VERSION)" "$$CURRENT_VERSION" | sort -V | head -n1)" != "$(UV_VERSION)" ]; then \
echo '...updating uv...'; \
curl -fLsS https://astral.sh/uv/install.sh | sh; \
if [ $$? -ne 0 ]; then \
echo "...updating uv failed!"; \
exit 1; \
fi; \
else \
echo '...uv version is up-to-date!'; \
fi; \
fi
# Setup virtual environment for local development.
venv: uv_check
@echo '# Preparing development environment...'
@echo '...cloning .env...'
@cp -n ./config/.env.example ./.env || :
@echo '...preparing git hooks...'
@cp -n ./config/pre-push ./.git/hooks/pre-push || :
@echo '...preparing venv...'
@uv sync --all-groups --all-extras --frozen --reinstall
@echo '...development environment ready! Activate venv using `. ./.venv/bin/activate`.'
# Sync environment with uv based on constraints
sync: uv_check
@echo '# Synchronizing dependencies...'
@uv sync --all-groups --all-extras --frozen
@echo '...finished!'
# Update and lock dependencies from pyproject.toml
update: uv_check
@echo '# Updating dependencies...'
@uv sync --all-groups --all-extras --upgrade
@echo '...finished!'
# Run formatter.
format:
@ruff check --quiet --fix $(SOURCES_PATH) $(TESTS_PATH)
@ruff format --quiet $(SOURCES_PATH) $(TESTS_PATH)
# Run linters and code checks.
lint: sync
@bandit -r $(SOURCES_PATH)
@ruff check $(SOURCES_PATH) $(TESTS_PATH)
@pyright --project ./
# Format Markdown docs and README
docs-format:
@echo '# Formatting Markdown...'
@uv run mdformat README.md docs
@echo '...finished!'
# Lint Markdown docs and README
docs-lint:
@echo '# Linting Markdown...'
@uv run pymarkdown --config .pymarkdown.json scan README.md docs
@echo '...finished!'
# Run tests suite.
test: sync
@python -B -m pytest -v --cov=$(SOURCES_PATH) --rootdir=$(TESTS_PATH)
# Build documentation for production
docs:
@echo '# Building documentation...'
@mkdocs build --clean --strict
@echo '...documentation built in site/ directory!'
# Build and serve documentation locally
docs-server:
@echo '# Starting documentation server...'
@mkdocs serve --dev-addr 127.0.0.1:8000
release: lint test
@echo '# Preparing release...'
@uv build
@uv publish
@echo '...finished!'