-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (35 loc) · 1.83 KB
/
Copy pathMakefile
File metadata and controls
47 lines (35 loc) · 1.83 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
.PHONY: dev test test-all test-e2e lint format migrate seed audit backup-db restore-db help
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
dev: ## Start local dev (DB + API)
docker compose up db -d
uv run fastapi dev src/pic/main.py
test: ## Run unit tests with coverage
uv run pytest -m unit --cov=src/pic --cov-report=term -v
test-all: ## Run all tests
uv run pytest -m "unit or integration" -v
test-e2e: ## Run e2e tests against running API (set PIC_E2E_BASE_URL)
uv run pytest -m e2e -v
lint: ## Run linting and type checks
uv run ruff check src/ tests/ scripts/
uv run ruff format --check src/ tests/ scripts/
uv run mypy src/pic/ --ignore-missing-imports
format: ## Auto-format code
uv run ruff check --fix src/ tests/ scripts/
uv run ruff format src/ tests/ scripts/
migrate: ## Run Alembic migrations
uv run alembic upgrade head
seed: ## Upload images and auto-cluster (pass DIR=path)
python scripts/seed.py $(DIR)
audit: ## Run dependency vulnerability scan
uv run pip-audit
backup-db: ## Create a logical PostgreSQL backup (set PIC_POSTGRES_URL)
@test -n "$(PIC_POSTGRES_URL)" || (echo "PIC_POSTGRES_URL is required"; exit 1)
@mkdir -p backups
@backup_file="backups/pic_$$(date +%Y%m%d_%H%M%S).sql"; \
pg_dump --no-owner --no-privileges --format=plain --file="$$backup_file" "$(PIC_POSTGRES_URL)" && \
echo "Backup created: $$backup_file"
restore-db: ## Restore a logical backup (set PIC_POSTGRES_URL and BACKUP_FILE=path.sql)
@test -n "$(PIC_POSTGRES_URL)" || (echo "PIC_POSTGRES_URL is required"; exit 1)
@test -n "$(BACKUP_FILE)" || (echo "BACKUP_FILE is required, e.g. make restore-db BACKUP_FILE=backups/pic_20260216_120000.sql"; exit 1)
@psql "$(PIC_POSTGRES_URL)" -v ON_ERROR_STOP=1 -f "$(BACKUP_FILE)"