Repository navigation
206 lines (199 loc) · 8.95 KB
/
Copy pathci.yaml
File metadata and controls
206 lines (199 loc) · 8.95 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
rust:
name: Rust format, lint, and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# NOTE: When updating the biome version, also update reflectapi/src/codegen/typescript.rs
- uses: biomejs/setup-biome@v2
with:
version: "1.8.3"
- uses: astral-sh/ruff-action@v3
with:
version: "0.15.8"
args: "--version"
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- run: cargo fmt -- --check
- run: cargo clippy --all-targets --all-features -- -D warnings
- run: cargo test --workspace
- name: Test generated Rust enum compatibility
run: cargo test --manifest-path reflectapi-demo/tests/rust/enum_compatibility/Cargo.toml
- name: Test generated Rust field presence
run: cargo test --manifest-path reflectapi-demo/tests/rust/field_presence/Cargo.toml
- uses: actions/upload-artifact@v7
with:
name: enum-compatibility-typescript
path: |
reflectapi-demo/target/enum-compatibility/typescript/*.ts
reflectapi-demo/target/enum-compatibility/fallback_samples.json
- uses: actions/upload-artifact@v7
with:
name: field-presence-typescript
path: reflectapi-demo/target/field-presence/typescript/*.ts
typescript-runtime:
name: TypeScript runtime tests
needs: rust
runs-on: ubuntu-latest
defaults:
run:
working-directory: reflectapi-demo/clients/typescript
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
- run: npx --yes pnpm@10 install --frozen-lockfile
- run: npx --yes pnpm@10 test
- uses: actions/download-artifact@v8
with:
name: enum-compatibility-typescript
path: reflectapi-demo/target/enum-compatibility
- name: Test generated TypeScript enum compatibility
run: REFLECTAPI_ENUM_SKIP_GENERATION=1 sh ../../tests/typescript/run.sh
- uses: actions/download-artifact@v8
with:
name: field-presence-typescript
path: reflectapi-demo/target/field-presence/typescript
- name: Check generated TypeScript field presence
run: REFLECTAPI_PRESENCE_SKIP_GENERATION=1 sh ../../tests/typescript/run-field-presence.sh
python-runtime:
name: Python runtime tests (${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.14"]
env:
UV_PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v3
- name: Run tests
working-directory: reflectapi-python-runtime
run: uv run --extra dev pytest -q --no-cov
# Regenerates the demo Python client from the in-repo schema and
# imports it. The generated package's strict `_rebuild_models()`
# runs at import time and raises on any dangling type reference, so
# this job catches the class of bug where the codegen emits a
# Python annotation pointing at a symbol it never defined.
python-codegen-smoke:
name: Python codegen smoke test (${{ matrix.python-version }}${{ matrix.dependencies == 'minimum' && ', minimum' || '' }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- python-version: "3.12"
dependencies: latest
uv-run-args: ""
- python-version: "3.14"
dependencies: latest
uv-run-args: ""
# Exercise the supported floors against the generated SDK, including
# recursive PEP 695 models, wire samples, and enum compatibility.
- python-version: "3.12"
dependencies: minimum
uv-run-args: >-
--isolated --with pydantic==2.10.0 --with httpx==0.25.2
--with httpcore==1.0.9 --with anyio==4.14.2 --with idna==3.15
- python-version: "3.14"
dependencies: minimum
uv-run-args: >-
--isolated --with pydantic==2.12.0 --with httpx==0.25.2
--with httpcore==1.0.9 --with anyio==4.14.2 --with idna==3.15
env:
UV_PYTHON: ${{ matrix.python-version }}
# --with uses an ephemeral overlay; --locked preserves the tracked lock.
# These flags must accompany every uv invocation in this job.
UV_RUN_ARGS: ${{ matrix.uv-run-args }}
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: astral-sh/setup-uv@v3
# The Python codegen shells out to `ruff format`; different ruff
# versions wrap long lines differently, so the snapshot-drift
# check below is meaningless unless CI and local devs use the
# same ruff version. Pin it explicitly.
- uses: astral-sh/ruff-action@v3
with:
version: "0.15.8"
# `args` short-circuits the action's default `ruff check` —
# we only want ruff on PATH so the codegen can shell out to
# `ruff format`, not for the action itself to lint the repo.
args: "--version"
- name: Report dependency versions
working-directory: reflectapi-demo/clients/python
run: |
uv run --locked $UV_RUN_ARGS python - <<'PY'
from importlib.metadata import version
for package in ("pydantic", "httpx", "httpcore", "anyio", "idna"):
print(f"{package}=={version(package)}")
PY
- name: Regenerate demo Python client from schema
run: |
cargo run -p reflectapi-cli --quiet -- codegen \
-s reflectapi-demo/reflectapi.json \
-o reflectapi-demo/clients/python/api_client \
-l python --python-package-name api_client --python-sync -f
- name: Import demo client (triggers strict model_rebuild)
working-directory: reflectapi-demo/clients/python
run: uv run --locked $UV_RUN_ARGS python -c "import api_client; print('demo client import OK')"
- name: Demo snapshot is committed (no drift)
run: git diff --exit-code reflectapi-demo/clients/python/api_client/
# Codegen coverage fixtures (recursive types, Python keyword
# field names, Pydantic-reserved names, ...) live in the
# integration test at `reflectapi-demo/tests/codegen_coverage.rs`.
# The test writes a Python client to
# `target/codegen-coverage-client/`; the next step imports it
# so `_rebuild_models()` raises on any dangling reference.
- name: Generate codegen coverage client
run: cargo test -p reflectapi-demo --test codegen_coverage
- name: Import codegen coverage client
working-directory: reflectapi-demo/clients/python
run: |
uv run --locked $UV_RUN_ARGS python -c "
import sys, pathlib
sys.path.insert(0, str(pathlib.Path('../../target/codegen-coverage-client').resolve()))
import codegen_coverage_client
print('coverage client import OK')
"
- name: Replay serde wire samples through the coverage client
working-directory: reflectapi-demo/clients/python
run: uv run --locked $UV_RUN_ARGS pytest ../../tests/python/test_wire.py -q -p no:cacheprovider
- name: Type-check generated clients
working-directory: reflectapi-demo/clients/python
run: uv run --locked $UV_RUN_ARGS pyright
- name: Run demo client tests
working-directory: reflectapi-demo/clients/python
run: uv run --locked $UV_RUN_ARGS pytest -q
- name: Generate enum compatibility clients
run: cargo test -p reflectapi-demo --test enum_compatibility
- name: Type-check enum compatibility consumer
working-directory: reflectapi-demo/clients/python
run: uv run --locked $UV_RUN_ARGS pyright --project ../../tests/python/pyrightconfig.json
- name: Test generated Python enum compatibility
working-directory: reflectapi-demo/clients/python
run: uv run --locked $UV_RUN_ARGS pytest ../../tests/python/test_enum_compatibility.py -q -p no:cacheprovider
# Pydantic builds JSON schemas without running the generated models'
# custom validators and serializers; replay serde's known variants
# against both the validation and serialization schemas.
- name: Check generated Python JSON schemas against serde samples
working-directory: reflectapi-demo/clients/python
run: uv run --locked $UV_RUN_ARGS pytest ../../tests/python/test_json_schema.py -q -p no:cacheprovider
- name: Generate field-presence clients
run: cargo test -p reflectapi-demo --test field_presence
- name: Test generated Python field presence
working-directory: reflectapi-demo/clients/python
run: uv run --locked $UV_RUN_ARGS pytest ../../tests/python/test_field_presence.py -q -p no:cacheprovider