Makefile
| 1 | .PHONY: help test test-fast test-cov typecheck seed seed-local seed-prs seed-narratives 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 test suite inside Docker (no local deps required) |
| 19 | $(DOCKER) exec musehub pytest tests/ -q --tb=short |
| 20 | |
| 21 | test-fast: ## Run tests without coverage inside Docker (faster feedback) |
| 22 | $(DOCKER) exec musehub pytest tests/ -q --tb=short -p no:cov |
| 23 | |
| 24 | test-cov: ## Run tests with coverage inside Docker |
| 25 | $(DOCKER) exec musehub pytest tests/ -q --tb=short --cov=musehub --cov-report=term-missing |
| 26 | |
| 27 | test-single: ## Run a single test file inside Docker: make test-single FILE=tests/test_musehub_repos.py |
| 28 | $(DOCKER) exec musehub pytest $(FILE) -v --tb=short |
| 29 | |
| 30 | test-k: ## Run tests matching a keyword inside Docker: make test-k K=harmony |
| 31 | $(DOCKER) exec musehub pytest -k "$(K)" -v --tb=short |
| 32 | |
| 33 | # Local targets (require Docker Postgres reachable on :5434 from host) |
| 34 | test-local: ## Run full test suite locally against Docker Postgres |
| 35 | DATABASE_URL=$(LOCAL_PG_URL) $(PYTEST) -n auto --cov=musehub --cov-report=term-missing --tb=short -q |
| 36 | |
| 37 | # ── Type checking ───────────────────────────────────────────────────────────── |
| 38 | |
| 39 | typecheck: ## Run mypy static type check over musehub/ |
| 40 | $(MYPY) musehub/ --ignore-missing-imports |
| 41 | |
| 42 | # ── Database ────────────────────────────────────────────────────────────────── |
| 43 | |
| 44 | seed: ## Run all three seed scripts against the running Docker DB |
| 45 | $(DOCKER) exec musehub python /app/scripts/seed_musehub.py --force |
| 46 | $(DOCKER) exec musehub python /app/scripts/seed_pull_requests.py --force |
| 47 | $(DOCKER) exec musehub python /app/scripts/seed_narratives.py --force |
| 48 | |
| 49 | seed-prs: ## Re-seed pull requests only (requires seed_musehub to have run first) |
| 50 | $(DOCKER) exec musehub python /app/scripts/seed_pull_requests.py --force |
| 51 | |
| 52 | seed-narratives: ## Re-seed narrative scenarios only (requires seed_musehub to have run first) |
| 53 | $(DOCKER) exec musehub python /app/scripts/seed_narratives.py --force |
| 54 | |
| 55 | seed-local: ## Run all seed scripts locally (requires DATABASE_URL env var) |
| 56 | $(PYTHON) scripts/seed_musehub.py --force |
| 57 | $(PYTHON) scripts/seed_pull_requests.py --force |
| 58 | $(PYTHON) scripts/seed_narratives.py --force |
| 59 | |
| 60 | migrate: ## Apply Alembic migrations in Docker |
| 61 | $(DOCKER) exec musehub alembic upgrade head |
| 62 | |
| 63 | migrate-local: ## Apply Alembic migrations locally (requires DATABASE_URL env var) |
| 64 | alembic upgrade head |
| 65 | |
| 66 | # ── Docker ──────────────────────────────────────────────────────────────────── |
| 67 | |
| 68 | docker-up: ## Start all Docker services |
| 69 | $(DOCKER) up -d |
| 70 | |
| 71 | docker-down: ## Stop and remove containers (keeps volumes) |
| 72 | $(DOCKER) down |
| 73 | |
| 74 | docker-rebuild: ## Rebuild images and restart |
| 75 | $(DOCKER) up -d --build |
| 76 | |
| 77 | docker-nuke: ## Tear down containers AND volumes (wipes DB) |
| 78 | $(DOCKER) down -v |
| 79 | |
| 80 | docker-logs: ## Tail app logs |
| 81 | $(DOCKER) logs -f musehub |
| 82 | |
| 83 | # ── Cleanup ─────────────────────────────────────────────────────────────────── |
| 84 | |
| 85 | clean: ## Remove __pycache__, .pyc, coverage artefacts |
| 86 | find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null; true |
| 87 | find . -name '*.pyc' -delete 2>/dev/null; true |
| 88 | rm -rf .coverage coverage.xml htmlcov .pytest_cache |