Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (74 loc) · 3.78 KB
/
Copy pathMakefile
File metadata and controls
99 lines (74 loc) · 3.78 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
.PHONY: help install upgrade hooks lint lint-ruff lint-format lint-ty lint-imports lint-typos format check run migrate seed docker-up docker-down docker-down-destroy test test-unit test-integration test-cov openapi-snapshot profile
help:
@echo "Available targets:"
@echo " make install - Install all dependencies for development"
@echo " make upgrade - Upgrade all dependencies"
@echo " make hooks - Install the pre-commit hooks"
@echo " make check - Run every lint gate and the unit tests (same as CI)"
@echo " make lint - Run ruff, ruff format, ty, import-linter and typos"
@echo " make lint-imports - Run import-linter architecture checks"
@echo " make format - Auto-fix ruff findings and format the code"
@echo " make migrate - Apply Alembic migrations to the configured database"
@echo " make seed - Load fixture data; safe to run repeatedly"
@echo " make run - Apply migrations, then start FastAPI dev server with hot reload"
@echo " make docker-up - Start full project locally"
@echo " make docker-down - Stop full project locally"
@echo " make docker-down-destroy - Stop full project locally and destroy volumes"
@echo " make test - Run all tests"
@echo " make test-unit - Run unit tests only"
@echo " make test-integration - Run integration tests only (needs Docker)"
@echo " make test-cov - Run all tests with the coverage gate"
@echo " make openapi-snapshot - Regenerate tests/contract/openapi.json"
@echo " make profile - Profile the unit tests (or PROFILE_ARGS) into profile.html"
install:
uv sync --group lint --group migration --group test --group profile --all-packages
upgrade:
uv sync --group lint --group migration --group test --group profile --all-packages -U
hooks:
uvx pre-commit install --install-hooks
check: lint test-unit
lint: lint-ruff lint-format lint-ty lint-imports lint-typos
lint-ruff:
uv run --group lint --all-packages ruff check app tests alembic seed scenario-tests .docker
lint-format:
uv run --group lint --all-packages ruff format --check app tests alembic seed scenario-tests .docker
lint-ty:
uv run --group lint --group migration --group test --all-packages ty check --error-on-warning app tests alembic seed scenario-tests
lint-imports:
uv run --group lint --all-packages lint-imports --config .importlinter
lint-typos:
uvx typos
format:
uv run --group lint --all-packages ruff check --fix app tests alembic seed scenario-tests .docker
uv run --group lint --all-packages ruff format app tests alembic seed scenario-tests .docker
run:
@if [ ! -f .env ]; then \
echo "Creating .env from .env.example..."; \
cp .env.example .env; \
echo "Fill in the .env file"
fi
uv run --group migration --env-file .env alembic -c alembic.ini upgrade head
uv run --env-file .env python -m app.main
migrate:
uv run --group migration --env-file .env alembic -c alembic.ini upgrade head
seed:
uv run --group migration --env-file .env python -m seed
docker-up:
docker compose up --build
docker-down:
docker compose down
docker-down-destroy:
docker compose down -v
test:
uv run --group test pytest
test-unit:
uv run --group test pytest -m unit
test-integration:
uv run --group test pytest -m integration
test-cov:
uv run --group test pytest --cov --cov-report=term-missing
openapi-snapshot:
uv run --group test pytest tests/unit/test_openapi_contract.py -q --update-openapi-snapshot
PROFILE_ARGS ?= -m unit
profile:
uv run --group test --group profile pyinstrument -r html -o profile.html -m pytest -p no:randomly -q $(PROFILE_ARGS)