-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
131 lines (106 loc) · 4.51 KB
/
Copy pathMakefile
File metadata and controls
131 lines (106 loc) · 4.51 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
.PHONY: all proto zod python json sql clean generate-incremental proto-changed \
registry-register registry-check registry-list \
proto-all gateway gateway-docker ci codegen-verify
# Default: run all generators (requires buf on PATH for the proto target)
all: proto zod python json sql
# Run buf generate (requires buf CLI: https://buf.build/docs/installation)
proto:
buf generate
# TypeScript Zod schemas
zod:
python scripts/generate_zod.py
# Pydantic Python models
python:
python scripts/generate_pydantic.py
# JSON Schema (draft-07)
json:
python scripts/generate_json_schema.py
# SQL DDL
sql:
python scripts/generate_sql.py
# Detect changed proto files against main branch
proto-changed:
git diff --name-only origin/main | grep ".proto" > changed.txt || true
# Incremental mode: only regenerate changed protogate artifacts
generate-incremental: proto-changed
python scripts/generate_incremental.py changed.txt
# Remove all generated artefacts (keeps the directory skeletons)
clean:
find generated/ -type f ! -name '.gitkeep' -delete
# ---------------------------------------------------------------------------
# Schema Registry targets
# ---------------------------------------------------------------------------
# Register the default proto file (contracts/user/v1/user.proto) in the registry
registry-register:
python scripts/schema_registry.py register contracts/user/v1/user.proto
# Check compatibility of the default proto without registering
registry-check:
python scripts/schema_registry.py check contracts/user/v1/user.proto
# List all schemas in the registry
registry-list:
python scripts/schema_registry.py list
# ---------------------------------------------------------------------------
# Platform targets (gateway + full pipeline)
# ---------------------------------------------------------------------------
# Full generation: buf (gRPC stubs) + all custom generators
proto-all: proto zod python json sql
# Run the FastAPI gateway in development mode (hot-reload)
gateway:
@pip install -q -r gateway/requirements.txt
PYTHONPATH=. uvicorn gateway.main:app --reload --port 8080
# Build + run gateway via Docker
gateway-docker:
docker build -f gateway/Dockerfile -t semcod-gateway .
docker run --rm -p 8080:8080 semcod-gateway
# Full CI pipeline: lint → generate → test → registry check
ci:
@echo "==> buf lint"
buf lint || true
@echo "==> proto-all (generate)"
$(MAKE) proto-all
@echo "==> pytest"
pytest tests/ -v
@echo "==> schema registry check (v1)"
python scripts/schema_registry.py check contracts/user/v1/user.proto || true
@echo "==> schema registry check (v2)"
python scripts/schema_registry.py check contracts/user/v2/user.proto || true
@echo "==> CI done ✓"
# Verify codegen guardrails and (optionally) check TS outputs for drift.
# Usage with real targets:
# make codegen-verify TS_CODEGEN_SCRIPT=/abs/path/to/generate-typescript-types.py \
# TS_CODEGEN_OUTPUTS="/abs/path/a.ts /abs/path/b.ts"
codegen-verify:
@echo "==> pytest: TypeScript codegen guardrails"
pytest tests/test_typescript_codegen.py tests/test_protogate_cli.py -q
@if [ -n "$(TS_CODEGEN_SCRIPT)" ] && [ -n "$(TS_CODEGEN_OUTPUTS)" ]; then \
echo "==> protogate ts-from-python --check"; \
cmd="python -m protogate.cli codegen ts-from-python --script $(TS_CODEGEN_SCRIPT) --check"; \
for out in $(TS_CODEGEN_OUTPUTS); do cmd="$$cmd --output $$out"; done; \
eval "$$cmd"; \
else \
echo "==> skip ts-from-python drift check (set TS_CODEGEN_SCRIPT and TS_CODEGEN_OUTPUTS to enable)"; \
fi
# ---------------------------------------------------------------------------
# Legacy Bridge targets
# ---------------------------------------------------------------------------
# Register legacy JSON schema
legacy-register:
python scripts/legacy_registry.py register-json user.legacy contracts/legacy_bridge/user_legacy.schema.json
python scripts/legacy_registry.py register-proto user.v1 contracts/legacy_bridge/user_legacy.v1.proto
# Diff legacy vs proto
diff-legacy:
python scripts/legacy_registry.py diff user.legacy user.v1
# Generate detailed migration report
legacy-report:
python scripts/legacy_registry.py report user.legacy user.v1
# List all schemas
legacy-list:
python scripts/legacy_registry.py list
# Full sync check (fails if readiness < 1.0)
sync-check:
@echo "==> Checking legacy vs proto sync"
@PYTHONPATH=. python scripts/legacy_bridge/sync_check.py
# Bootstrap EventStore from Legacy DB
bootstrap-legacy:
@echo "==> Bootstrapping EventStore from legacy.db"
@PYTHONPATH=. python scripts/legacy_bridge/migrator.py