gabriel / musehub public
Makefile
70 lines 3.2 KB
7923a405 test(supercharge): comprehensive test suite overhaul — all 11 points Gabriel Cardona <gabriel@tellurstori.com> 6d ago
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 # ── Testing ──────────────────────────────────────────────────────────────────
12
13 test: ## Run full parallel test suite with coverage
14 $(PYTEST) -n auto --cov=musehub --cov-report=term-missing --tb=short -q
15
16 test-fast: ## Run tests without coverage (faster feedback loop)
17 $(PYTEST) -n auto --tb=short -q
18
19 test-cov: ## Run tests and open HTML coverage report
20 $(PYTEST) -n auto --cov=musehub --cov-report=html --tb=short -q
21 open htmlcov/index.html 2>/dev/null || xdg-open htmlcov/index.html 2>/dev/null || true
22
23 test-single: ## Run a single test file: make test-single FILE=tests/test_musehub_repos.py
24 $(PYTEST) $(FILE) -v --tb=short
25
26 test-k: ## Run tests matching a keyword: make test-k K=harmony
27 $(PYTEST) -k "$(K)" -v --tb=short
28
29 # ── Type checking ─────────────────────────────────────────────────────────────
30
31 typecheck: ## Run mypy static type check over musehub/
32 $(MYPY) musehub/ --ignore-missing-imports
33
34 # ── Database ──────────────────────────────────────────────────────────────────
35
36 seed: ## Run seed script against the running Docker DB
37 $(DOCKER) exec musehub python /app/scripts/seed_musehub.py --force
38
39 seed-local: ## Run seed script locally (requires DATABASE_URL env var)
40 $(PYTHON) scripts/seed_musehub.py --force
41
42 migrate: ## Apply Alembic migrations in Docker
43 $(DOCKER) exec musehub alembic upgrade head
44
45 migrate-local: ## Apply Alembic migrations locally (requires DATABASE_URL env var)
46 alembic upgrade head
47
48 # ── Docker ────────────────────────────────────────────────────────────────────
49
50 docker-up: ## Start all Docker services
51 $(DOCKER) up -d
52
53 docker-down: ## Stop and remove containers (keeps volumes)
54 $(DOCKER) down
55
56 docker-rebuild: ## Rebuild images and restart
57 $(DOCKER) up -d --build
58
59 docker-nuke: ## Tear down containers AND volumes (wipes DB)
60 $(DOCKER) down -v
61
62 docker-logs: ## Tail app logs
63 $(DOCKER) logs -f musehub
64
65 # ── Cleanup ───────────────────────────────────────────────────────────────────
66
67 clean: ## Remove __pycache__, .pyc, coverage artefacts
68 find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null; true
69 find . -name '*.pyc' -delete 2>/dev/null; true
70 rm -rf .coverage coverage.xml htmlcov .pytest_cache