-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
163 lines (128 loc) · 6.83 KB
/
Copy pathMakefile
File metadata and controls
163 lines (128 loc) · 6.83 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
.DEFAULT_GOAL := help
PYTHON := uv run python
PYTEST := uv run pytest
RUFF := uv run ruff
MYPY := uv run mypy
.PHONY: help bootstrap lint fmt test test-contract test-logs test-integration test-backends perf load-test schemas config-schema config-validate dev dev-full dev-down dev-wait dev-seed dev-reset docker clean audit infra-init infra-validate infra-plan helm-lint helm-template
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
bootstrap: ## Install all deps and pre-commit hooks (run once after clone)
@command -v uv >/dev/null 2>&1 || (echo "uv not found — see scripts/bootstrap.sh" && exit 1)
@command -v pnpm >/dev/null 2>&1 || (echo "pnpm not found — npm i -g pnpm" && exit 1)
uv sync --all-packages
pnpm install
uv run pre-commit install
uv run pre-commit install --hook-type commit-msg
@echo "\033[32m✓ Bootstrap complete. Run 'make dev' to start the local stack.\033[0m"
# ---------------------------------------------------------------------------
# Quality gates
# ---------------------------------------------------------------------------
lint: ## Run ruff + mypy on all Python packages
$(RUFF) check .
$(RUFF) format --check .
$(MYPY) packages/ apps/gateway/
config-schema: ## Generate rag.yaml JSON Schema → dist/
@mkdir -p dist
PYTHONPATH=packages/core/src:packages/config/src $(PYTHON) -m rag_config.gen_schema dist/
@echo "\033[32m✓ Schema written to dist/rag.schema.json + dist/rag.schema.yaml\033[0m"
config-validate: ## Validate the root rag.yaml
uv run ragctl config validate rag.yaml
fmt: ## Auto-fix ruff lint + format in-place
$(RUFF) check --fix .
$(RUFF) format .
# ---------------------------------------------------------------------------
# Testing
# ---------------------------------------------------------------------------
test: ## Run the full test suite (unit + contract; excludes the perf gate)
$(PYTEST) tests/ packages/ -x -q -m "not perf"
test-contract: ## Run SPI conformance suites only
$(PYTEST) tests/contract/ -v -m contract
test-logs: ## Run logging schema + PII + registry gates
$(PYTEST) tests/logs/ -v
test-integration: ## Run integration tests (requires: make dev + make dev-wait)
$(PYTEST) tests/integration/ -v -m integration
test-backends: ## Run backend unit tests (LocalFileStorage — no services required)
$(PYTEST) tests/integration/test_local_storage.py -v
perf: ## Run the gateway latency gate (server-side p99 overhead budget)
$(PYTEST) tests/perf/ -v -m perf
load-test: ## Run the in-process gateway load + profile harness
$(PYTHON) -m eval.gateway_load_v0.harness
# ---------------------------------------------------------------------------
# Schemas
# ---------------------------------------------------------------------------
schemas: ## Generate JSON Schema + Proto artifacts → dist/schemas/
@mkdir -p dist/schemas
PYTHONPATH=packages/core/src $(PYTHON) -m rag_core.gen_schemas dist/schemas/
@echo "\033[32m✓ Schemas written to dist/schemas/\033[0m"
# ---------------------------------------------------------------------------
# gRPC / proto (Step 3.2)
# ---------------------------------------------------------------------------
proto-gen: ## Regenerate Python gRPC stubs from proto/rag.proto
$(PYTHON) scripts/gen_proto_py.py
proto-lint: ## buf lint over proto/
buf lint
proto-check-drift: ## Fail if committed gRPC stubs are out of sync with rag.proto
$(PYTHON) scripts/check_proto_drift.py
# ---------------------------------------------------------------------------
# OpenAPI + SDKs (Step 3.7)
# ---------------------------------------------------------------------------
openapi-gen: ## Re-export dist/openapi.{json,yaml} from the live gateway routes
$(PYTHON) scripts/export_openapi.py
openapi-check-drift: ## Fail if dist/openapi.* is stale vs the gateway routes
$(PYTHON) scripts/check_openapi_drift.py
sdk-gen: ## Generate all SDK artifacts (proto stubs + OpenAPI clients) into sdks/*/
$(PYTHON) scripts/gen_sdks.py
# ---------------------------------------------------------------------------
# Local dev stack
# ---------------------------------------------------------------------------
dev: ## Start core local stack (postgres, redis, qdrant, minio)
docker compose --profile core up -d
@echo "\033[32m✓ Core stack running. Postgres=5432, Redis=6379, Qdrant=6333, MinIO=9000\033[0m"
dev-full: ## Start core + full observability stack
docker compose --profile core --profile observability up -d
@echo "\033[32m✓ Full stack running. Grafana=3001, Jaeger=16686, Prometheus=9090\033[0m"
dev-down: ## Stop all local stack services
docker compose --profile core --profile observability down
dev-wait: ## Block until all core services are healthy (timeout 90s)
bash scripts/dev-wait.sh
dev-seed: ## Run pgvector migration, init Qdrant collections, and load seed data
bash scripts/dev-seed.sh
dev-reset: ## Tear down volumes, restart, wait for health, and re-seed
docker compose --profile core down -v
docker compose --profile core up -d
bash scripts/dev-wait.sh
bash scripts/dev-seed.sh
docker: ## Build all Docker images
docker compose build
# ---------------------------------------------------------------------------
# Security
# ---------------------------------------------------------------------------
audit: ## Run pip-audit for dependency CVEs
uv run pip-audit
# ---------------------------------------------------------------------------
# IaC — Terraform + Helm
# ---------------------------------------------------------------------------
infra-init: ## terraform init for the dev environment
terraform -chdir=infra/terraform/environments/dev init
infra-validate: ## terraform validate for dev + prod environments
terraform -chdir=infra/terraform/environments/dev validate
terraform -chdir=infra/terraform/environments/prod validate
infra-plan: ## terraform plan for the dev environment
terraform -chdir=infra/terraform/environments/dev plan
helm-lint: ## Lint the rag-platform Helm chart
helm lint infra/helm/rag-platform/
helm-template: ## Render Helm templates (dry run)
helm template rag-platform infra/helm/rag-platform/
# ---------------------------------------------------------------------------
# Cleanup
# ---------------------------------------------------------------------------
clean: ## Remove build artefacts, caches, and __pycache__
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null; true
find . -type d -name .mypy_cache -exec rm -rf {} + 2>/dev/null; true
find . -type d -name .ruff_cache -exec rm -rf {} + 2>/dev/null; true
find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null; true
rm -rf dist/ .pytest_cache/ htmlcov/ .coverage