-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (82 loc) · 3.37 KB
/
Copy pathMakefile
File metadata and controls
102 lines (82 loc) · 3.37 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
SHELL := /bin/bash
PYTHON := .venv/bin/python
PYTEST := .venv/bin/pytest
RUFF := .venv/bin/ruff
IMPORT_LINTER := .venv/bin/lint-imports
UVICORN := .venv/bin/uvicorn
ALEMBIC := .venv/bin/alembic
POETRY := poetry
COMPOSE_FILE := docker-compose.yml
.DEFAULT_GOAL := help
.PHONY: help install run test lint lint-imports import-check security-scan check migrate seed downgrade revision db-up db-down db-logs clean
help:
@echo "[make:help] Available commands:"
@echo " [make:install] Install project dependencies with Poetry"
@echo " [make:run] Run the FastAPI development server"
@echo " [make:test] Run pytest"
@echo " [make:lint] Run Ruff checks"
@echo " [make:lint-imports] Enforce import boundary contracts"
@echo " [make:import-check] Verify src.main imports"
@echo " [make:security-scan] Run dependency vulnerability scan with pip-audit"
@echo " [make:check] Run tests, lint, and import check"
@echo " [make:migrate] Apply Alembic migrations"
@echo " [make:seed] Seed baseline database records"
@echo " [make:downgrade] Roll back one Alembic migration"
@echo " [make:revision] Create an Alembic migration: make revision name=\"describe change\""
@echo " [make:db-up] Start Docker Compose services"
@echo " [make:db-down] Stop Docker Compose services"
@echo " [make:db-logs] Follow Docker Compose logs"
@echo " [make:clean] Remove local Python cache files"
install:
@echo "[make:install] Installing dependencies with Poetry"
@$(POETRY) install
run:
@echo "[make:run] Starting FastAPI development server on http://localhost:8000"
@$(UVICORN) src.main:app --reload --host 0.0.0.0 --port 8000
test:
@echo "[make:test] Running pytest"
@$(PYTEST) -q
lint:
@echo "[make:lint] Running Ruff checks"
@$(RUFF) check src tests scripts
lint-imports:
@echo "[make:lint-imports] Enforcing import boundary contracts"
@$(IMPORT_LINTER)
import-check:
@echo "[make:import-check] Verifying src.main imports"
@PYTHONDONTWRITEBYTECODE=1 $(PYTHON) -c "import src.main; print('import ok')"
security-scan:
@echo "[make:security-scan] Running dependency vulnerability scan"
@PIP_CACHE_DIR=.cache/pip $(POETRY) run pip-audit --cache-dir .cache/pip-audit
check: test lint lint-imports import-check
@echo "[make:check] All checks completed"
migrate:
@echo "[make:migrate] Applying Alembic migrations"
@$(ALEMBIC) upgrade head
seed:
@echo "[make:seed] Running database seeders"
@$(PYTHON) scripts/seed.py
downgrade:
@echo "[make:downgrade] Rolling back one Alembic migration"
@$(ALEMBIC) downgrade -1
revision:
@if [ -z "$(name)" ]; then \
echo "[make:revision] Usage: make revision name=\"describe change\""; \
exit 1; \
fi
@echo "[make:revision] Creating Alembic migration: $(name)"
@$(ALEMBIC) revision --autogenerate -m "$(name)"
db-up:
@echo "[make:db-up] Starting Docker Compose services"
@docker compose -f $(COMPOSE_FILE) up -d
db-down:
@echo "[make:db-down] Stopping Docker Compose services"
@docker compose -f $(COMPOSE_FILE) down
db-logs:
@echo "[make:db-logs] Following Docker Compose logs"
@docker compose -f $(COMPOSE_FILE) logs -f
clean:
@echo "[make:clean] Removing local Python cache files"
@find . -type d -name "__pycache__" -prune -exec rm -rf {} +
@find . -type d -name ".pytest_cache" -prune -exec rm -rf {} +
@find . -type d -name ".ruff_cache" -prune -exec rm -rf {} +