|
| 1 | +name: sdk-types-ci |
| 2 | + |
| 3 | +# Drift gate for the generated TYPES EXPORT (Pydantic + Zod). Regenerates from the |
| 4 | +# proto via scripts/gen-sdk-types.sh and fails if the committed output differs — the |
| 5 | +# same regenerate-and-diff contract as the gen/ drift gate, for the SDK types. Runs |
| 6 | +# only when the proto, the descriptor, the generators, or the committed output change. |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: [main] |
| 10 | + paths: &paths |
| 11 | + - 'proto/**' |
| 12 | + - 'gen/descriptor.binpb' |
| 13 | + - 'scripts/gen-sdk-types.sh' |
| 14 | + - 'scripts/check-canonical.sh' |
| 15 | + - 'scripts/sdk-types/**' |
| 16 | + - 'conformance/**' |
| 17 | + - 'gen/python/**' |
| 18 | + - 'gen/ts/**' |
| 19 | + - '.github/workflows/sdk-types-ci.yml' |
| 20 | + pull_request: |
| 21 | + paths: *paths |
| 22 | + |
| 23 | +jobs: |
| 24 | + sdk-types: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + - uses: actions/setup-go@v5 |
| 29 | + with: |
| 30 | + go-version-file: go.mod |
| 31 | + - uses: bufbuild/buf-setup-action@v1 |
| 32 | + with: |
| 33 | + version: 1.66.1 |
| 34 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + - uses: actions/setup-python@v5 |
| 36 | + with: |
| 37 | + python-version: '3.12' |
| 38 | + - uses: actions/setup-node@v4 |
| 39 | + with: |
| 40 | + node-version: 22 |
| 41 | + |
| 42 | + - name: regenerate types export |
| 43 | + run: ./scripts/gen-sdk-types.sh |
| 44 | + |
| 45 | + # Only the two generated files; wire/base.py is hand-written (the seam) and the |
| 46 | + # vocab constants are generated by buf, gated separately. |
| 47 | + - name: assert no drift |
| 48 | + run: | |
| 49 | + if ! git diff --exit-code -- gen/python/wire/models.py gen/ts/wire/schemas.ts; then |
| 50 | + echo "::error::Generated types export is out of sync with the proto. Run scripts/gen-sdk-types.sh and commit gen/python/wire/models.py + gen/ts/wire/schemas.ts." |
| 51 | + exit 1 |
| 52 | + fi |
| 53 | +
|
| 54 | + # Cross-language validation parity: the generated Pydantic models and Zod schemas |
| 55 | + # must reach the SAME verdict as Go protovalidate on every case in the generated |
| 56 | + # corpus (conformance/corpus/cases.json) — proving the proto -> JSON Schema -> |
| 57 | + # client pipeline carries every field-level rule. The corpus is pinned to |
| 58 | + # protovalidate by the Go conformance suite (proto-ci) and gated for drift there. |
| 59 | + - name: Python (Pydantic) parity |
| 60 | + run: | |
| 61 | + python -m pip install -q "pydantic>=2.0" pytest |
| 62 | + PYTHONPATH=gen/python pytest gen/python/tests -q |
| 63 | +
|
| 64 | + - name: TypeScript (Zod) parity |
| 65 | + working-directory: gen/ts |
| 66 | + run: | |
| 67 | + npm install |
| 68 | + npm test |
| 69 | +
|
| 70 | + # Canonical proto-JSON interop: each client re-serializes every valid corpus |
| 71 | + # instance and the emission, read back through Go protojson, must decode to the |
| 72 | + # same proto message as the original (incl. Timestamp/Duration). Reuses the |
| 73 | + # .sdk-types-work venv + zod provisioned by gen-sdk-types.sh above. |
| 74 | + - name: Canonical proto-JSON round-trip |
| 75 | + run: ./scripts/check-canonical.sh |
0 commit comments