-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (85 loc) · 2.5 KB
/
Makefile
File metadata and controls
104 lines (85 loc) · 2.5 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
.PHONY: all format lint test tests integration_tests help install clean build check spell_check spell_fix
# Default target executed when no arguments are given to make.
all: help
## Install the package and development dependencies
install:
uv sync --dev
## Run tests
test tests:
uv run pytest --disable-socket --allow-unix-socket tests/
## Run tests with watcher
test_watch:
uv run ptw --snapshot-update --now . -- -vv tests/
## Run integration tests (REST API + Workers, requires credentials)
integration_test integration_tests:
@echo "Loading .env and running integration tests..."
@bash -c 'set -a && source .env 2>/dev/null || true && set +a && \
export TEST_CF_API_TOKEN=$${TEST_CF_API_TOKEN:-$$CF_API_TOKEN} && \
unset VIRTUAL_ENV && \
uv run pytest tests/integration/ -v'
## Run all checks (lint + test)
check: lint test
######################
# LINTING AND FORMATTING
######################
## Run linting (ruff check + format check + mypy)
lint:
uv run ruff check .
uv run ruff format . --diff
uv run mypy src/
## Run linting on specific files
lint_diff:
@if [ -n "$$(git diff --name-only --diff-filter=d HEAD^ | grep -E '\.py$$')" ]; then \
echo "Linting changed files..."; \
uv run ruff check $$(git diff --name-only --diff-filter=d HEAD^ | grep -E '\.py$$' | tr '\n' ' '); \
uv run ruff format $$(git diff --name-only --diff-filter=d HEAD^ | grep -E '\.py$$' | tr '\n' ' ') --diff; \
uv run mypy $$(git diff --name-only --diff-filter=d HEAD^ | grep -E '\.py$$' | tr '\n' ' '); \
else \
echo "No Python files changed."; \
fi
## Fix formatting and linting issues
format:
uv run ruff format .
uv run ruff check . --fix
## Spell check
spell_check:
uv run codespell
## Fix spelling issues
spell_fix:
uv run codespell --write-changes
######################
# BUILD AND PUBLISH
######################
## Clean build artifacts
clean:
rm -rf dist/
rm -rf build/
rm -rf *.egg-info/
find . -type d -name __pycache__ -delete
find . -type f -name "*.pyc" -delete
## Build the package
build: clean
uv build
## Install pre-commit hooks
setup_hooks:
uv run pre-commit install
## Run pre-commit on all files
pre_commit_all:
uv run pre-commit run --all-files
######################
# HELP
######################
## Show help
help:
@echo ''
@echo 'Usage:'
@echo ' make <target>'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) { \
helpCommand = $$1; \
helpMessage = $$2; \
printf " %-20s %s\n", helpCommand, helpMessage; \
} \
}' $(MAKEFILE_LIST)