Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (80 loc) · 3.17 KB
/
Copy pathMakefile
File metadata and controls
102 lines (80 loc) · 3.17 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
.DEFAULT_GOAL := help
SHELL := /bin/sh
# Windows developers get .venv/Scripts; POSIX gets .venv/bin.
VENV := .venv
PY := $(if $(wildcard $(VENV)/Scripts/python.exe),$(VENV)/Scripts/python.exe,$(VENV)/bin/python)
BACKEND := backend
FRONTEND := frontend
.PHONY: help
help: ## Show this help
@grep -hE '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) | sort | awk 'BEGIN{FS=":.*?## "};{printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'
.PHONY: install
install: ## Create the virtualenv and install backend + frontend dependencies
python -m venv $(VENV)
$(PY) -m pip install --upgrade pip
$(PY) -m pip install -e "$(BACKEND)[dev]"
cd $(FRONTEND) && npm ci
.PHONY: dev
dev: ## Run the API and the Vite dev server together
cd $(BACKEND) && ../$(PY) -m uvicorn app.main:app --reload --port 8000 & \
cd $(FRONTEND) && npm run dev; \
wait
.PHONY: dev-api
dev-api: ## Run only the API with autoreload
cd $(BACKEND) && ../$(PY) -m uvicorn app.main:app --reload --port 8000
.PHONY: dev-worker
dev-worker: ## Run a Celery ingestion worker
cd $(BACKEND) && ../$(PY) -m celery -A app.workers.tasks:celery worker --loglevel=INFO --concurrency=2
.PHONY: migrate
migrate: ## Apply metadata migrations to head
cd $(BACKEND) && ../$(PY) -m alembic upgrade head
.PHONY: migration
migration: ## Autogenerate a migration: make migration m="add x"
cd $(BACKEND) && ../$(PY) -m alembic revision --autogenerate -m "$(m)"
.PHONY: migrate-check
migrate-check: ## Fail if the models have drifted from the migrations
cd $(BACKEND) && ../$(PY) -m alembic check
.PHONY: fixtures
fixtures: ## Regenerate the synthetic SMF fixture used by tests and demos
cd $(BACKEND) && ../$(PY) -m app.smf.fixtures ../fixtures/demo-synthetic.smf
.PHONY: test
test: test-backend test-frontend ## Run backend and frontend unit tests
.PHONY: test-backend
test-backend: ## Run backend tests
cd $(BACKEND) && ../$(PY) -m pytest -q
.PHONY: test-frontend
test-frontend: ## Run frontend unit tests
cd $(FRONTEND) && npm run test
.PHONY: test-e2e
test-e2e: ## Run Playwright end-to-end tests
cd $(FRONTEND) && npm run test:e2e
.PHONY: lint
lint: ## Lint backend and frontend
cd $(BACKEND) && ../$(PY) -m ruff check .
cd $(FRONTEND) && npm run lint
.PHONY: typecheck
typecheck: ## Type-check backend and frontend
cd $(BACKEND) && ../$(PY) -m mypy app
cd $(FRONTEND) && npm run typecheck
.PHONY: format
format: ## Apply formatters
cd $(BACKEND) && ../$(PY) -m ruff check --fix . && ../$(PY) -m ruff format .
cd $(FRONTEND) && npm run format
.PHONY: audit
audit: ## Check dependencies for known vulnerabilities
cd $(BACKEND) && ../$(PY) -m pip_audit -r <(../$(PY) -m pip freeze) || true
cd $(FRONTEND) && npm audit --audit-level=high
.PHONY: build
build: ## Build the production frontend bundle
cd $(FRONTEND) && npm run build
.PHONY: up
up: ## Start the full Docker stack
docker compose up -d --build
.PHONY: down
down: ## Stop the Docker stack, keeping volumes
docker compose down
.PHONY: clean
clean: ## Remove build and cache artefacts
rm -rf $(FRONTEND)/dist $(FRONTEND)/playwright-report $(FRONTEND)/test-results
rm -rf $(BACKEND)/.pytest_cache $(BACKEND)/.mypy_cache $(BACKEND)/.ruff_cache
find $(BACKEND) -name __pycache__ -type d -prune -exec rm -rf {} +