-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
141 lines (98 loc) · 4.39 KB
/
Copy pathMakefile
File metadata and controls
141 lines (98 loc) · 4.39 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
.DEFAULT_GOAL := help
VENV := .venv
PYTHON := $(VENV)/bin/python
PIP := $(VENV)/bin/pip
RUFF := $(VENV)/bin/ruff
BLACK := $(VENV)/bin/black
PYTEST := $(VENV)/bin/pytest
ALEMBIC := $(VENV)/bin/alembic
UVICORN := $(VENV)/bin/uvicorn
API_HOST := 0.0.0.0
API_PORT := 8004
.PHONY: help \
install install-dev \
dev test test-unit test-integration coverage \
lint format check \
docker-up docker-down docker-logs docker-restart \
docker-build docker-rebuild docker-rebuild-nocache docker-ps \
url2md-build url2md-up url2md-rebuild url2md-logs \
url2md-build-raglab url2md-up-raglab url2md-rebuild-raglab \
migrate migrate-create migrate-down \
frontend-dev frontend-build frontend-lint frontend-test
help: ## Show this help message
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-24s\033[0m %s\n", $$1, $$2}'
# ---- Setup ----------------------------------------------------------------
install: ## Install runtime dependencies
$(PIP) install -r requirements.txt
install-dev: install ## Install runtime + dev tools (ruff, black, pytest-cov)
$(PIP) install ruff black pytest pytest-cov pytest-asyncio
# ---- Development ----------------------------------------------------------
dev: ## Run FastAPI dev server with --reload
$(UVICORN) app.main:app --reload --host $(API_HOST) --port $(API_PORT)
# ---- Testing --------------------------------------------------------------
test: ## Run all tests with coverage
$(PYTEST)
test-unit: ## Run unit tests only
$(PYTEST) tests/unit
test-integration: ## Run integration tests only
$(PYTEST) tests/integration
coverage: ## Generate HTML coverage report
$(PYTEST) --cov-report=html
@echo "Open htmlcov/index.html in your browser"
# ---- Code quality ---------------------------------------------------------
lint: ## Run ruff + black --check
$(RUFF) check app/ tests/
$(BLACK) --check app/ tests/
format: ## Auto-fix with ruff and reformat with black
$(RUFF) check --fix app/ tests/
$(BLACK) app/ tests/
check: lint test ## Run lint + tests (use as the local CI gate)
# ---- Docker ---------------------------------------------------------------
docker-up: ## Start all services in the background
docker compose up -d
docker-down: ## Stop all services
docker compose down
docker-restart: ## Restart the api container
docker compose restart api
docker-logs: ## Tail the api container logs
docker compose logs -f api
docker-build: ## Rebuild api + frontend images (uses cache)
docker compose build api frontend
docker-rebuild: docker-build docker-up ## Build and roll services to the new images
docker-rebuild-nocache: ## Full no-cache rebuild + roll (slow, use after deps changes)
docker compose build --no-cache api frontend
docker compose up -d
docker-ps: ## Show service status
docker compose ps
url2md-build: ## Build url2md image
docker compose --profile url2md build url2md
url2md-up: ## Start url2md service
docker compose --profile url2md up -d url2md
url2md-rebuild: url2md-build url2md-up ## Rebuild and restart url2md
url2md-logs: ## Tail url2md logs
docker compose --profile url2md logs -f url2md
url2md-build-raglab: ## Build url2md image for rag-lab
docker compose -p raglab -f docker-compose.rag-lab.yml --profile url2md build url2md
url2md-up-raglab: ## Start url2md for rag-lab
docker compose -p raglab -f docker-compose.rag-lab.yml --profile url2md up -d url2md
url2md-rebuild-raglab: url2md-build-raglab url2md-up-raglab ## Rebuild and restart url2md for rag-lab
# ---- Database -------------------------------------------------------------
migrate: ## Apply pending Alembic migrations
$(ALEMBIC) upgrade head
migrate-create: ## Create new migration; usage: make migrate-create M="message"
@if [ -z "$(M)" ]; then \
echo "Usage: make migrate-create M=\"description\""; exit 1; \
fi
$(ALEMBIC) revision --autogenerate -m "$(M)"
migrate-down: ## Roll back the last migration
$(ALEMBIC) downgrade -1
# ---- Frontend -------------------------------------------------------------
frontend-dev: ## Run Vite dev server (port 5174)
cd frontend && npm run dev
frontend-build: ## Build frontend for production
cd frontend && npm run build
frontend-lint: ## Run eslint on the frontend
cd frontend && npm run lint
frontend-test: ## Run Playwright UI tests (requires Docker)
cd frontend && npm run test:ui:line