Makefile
| 1 | .PHONY: help test test-fast test-cov typecheck seed docker-up docker-down docker-logs |
| 2 | |
| 3 | PYTHON ?= python |
| 4 | PYTEST ?= pytest |
| 5 | MYPY ?= mypy |
| 6 | DOCKER ?= docker compose |
| 7 | |
| 8 | help: ## Show this help message |
| 9 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-18s\033[0m %s\n",$$1,$$2}' |
| 10 | |
| 11 | # Local Postgres exposed by docker-compose on a non-default port (5433) |
| 12 | # to avoid clashing with any locally-installed Postgres instance. |
| 13 | # Set DATABASE_URL in your shell or .env to override. |
| 14 | LOCAL_PG_URL ?= postgresql+asyncpg://musehub:musehub@localhost:5434/musehub |
| 15 | |
| 16 | # ── Testing ────────────────────────────────────────────────────────────────── |
| 17 | |
| 18 | test: ## Run full parallel test suite with coverage (uses Docker Postgres on :5433) |
| 19 | DATABASE_URL=$(LOCAL_PG_URL) $(PYTEST) -n auto --cov=musehub --cov-report=term-missing --tb=short -q |
| 20 | |
| 21 | test-fast: ## Run tests without coverage (faster feedback loop) |
| 22 | DATABASE_URL=$(LOCAL_PG_URL) $(PYTEST) -n auto --tb=short -q |
| 23 | |
| 24 | test-cov: ## Run tests and open HTML coverage report |
| 25 | DATABASE_URL=$(LOCAL_PG_URL) $(PYTEST) -n auto --cov=musehub --cov-report=html --tb=short -q |
| 26 | open htmlcov/index.html 2>/dev/null || xdg-open htmlcov/index.html 2>/dev/null || true |
| 27 | |
| 28 | test-single: ## Run a single test file: make test-single FILE=tests/test_musehub_repos.py |
| 29 | DATABASE_URL=$(LOCAL_PG_URL) $(PYTEST) $(FILE) -v --tb=short |
| 30 | |
| 31 | test-k: ## Run tests matching a keyword: make test-k K=harmony |
| 32 | DATABASE_URL=$(LOCAL_PG_URL) $(PYTEST) -k "$(K)" -v --tb=short |
| 33 | |
| 34 | # ── Type checking ───────────────────────────────────────────────────────────── |
| 35 | |
| 36 | typecheck: ## Run mypy static type check over musehub/ |
| 37 | $(MYPY) musehub/ --ignore-missing-imports |
| 38 | |
| 39 | # ── Database ────────────────────────────────────────────────────────────────── |
| 40 | |
| 41 | seed: ## Run seed script against the running Docker DB |
| 42 | $(DOCKER) exec musehub python /app/scripts/seed_musehub.py --force |
| 43 | |
| 44 | seed-local: ## Run seed script locally (requires DATABASE_URL env var) |
| 45 | $(PYTHON) scripts/seed_musehub.py --force |
| 46 | |
| 47 | migrate: ## Apply Alembic migrations in Docker |
| 48 | $(DOCKER) exec musehub alembic upgrade head |
| 49 | |
| 50 | migrate-local: ## Apply Alembic migrations locally (requires DATABASE_URL env var) |
| 51 | alembic upgrade head |
| 52 | |
| 53 | # ── Docker ──────────────────────────────────────────────────────────────────── |
| 54 | |
| 55 | docker-up: ## Start all Docker services |
| 56 | $(DOCKER) up -d |
| 57 | |
| 58 | docker-down: ## Stop and remove containers (keeps volumes) |
| 59 | $(DOCKER) down |
| 60 | |
| 61 | docker-rebuild: ## Rebuild images and restart |
| 62 | $(DOCKER) up -d --build |
| 63 | |
| 64 | docker-nuke: ## Tear down containers AND volumes (wipes DB) |
| 65 | $(DOCKER) down -v |
| 66 | |
| 67 | docker-logs: ## Tail app logs |
| 68 | $(DOCKER) logs -f musehub |
| 69 | |
| 70 | # ── Cleanup ─────────────────────────────────────────────────────────────────── |
| 71 | |
| 72 | clean: ## Remove __pycache__, .pyc, coverage artefacts |
| 73 | find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null; true |
| 74 | find . -name '*.pyc' -delete 2>/dev/null; true |
| 75 | rm -rf .coverage coverage.xml htmlcov .pytest_cache |