Skip to content

Commit fb23ffe

Browse files
committed
Centralize regen tool pins in pyproject.toml regen group
1 parent 4288696 commit fb23ffe

6 files changed

Lines changed: 521 additions & 29 deletions

File tree

.github/workflows/generated.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ jobs:
1919
with:
2020
persist-credentials: false
2121
- uses: ./.github/actions/setup-uv
22+
- run: uv sync --group regen
2223
- name: Prepare spec
2324
run: |
2425
set -euo pipefail
2526
if [[ -f openapi-overlay.yaml ]]; then
26-
uvx oas-patch==0.6.0 overlay openapi.json openapi-overlay.yaml -o /tmp/patched-spec.json
27+
uv run oas-patch overlay openapi.json openapi-overlay.yaml -o /tmp/patched-spec.json
2728
else
2829
cp openapi.json /tmp/patched-spec.json
2930
fi
3031
- name: Regenerate client
3132
run: |
32-
uvx openapi-python-client==0.28.3 generate \
33+
uv run openapi-python-client generate \
3334
--path /tmp/patched-spec.json \
3435
--meta none \
3536
--config openapi-python-client-config.yaml \

AGENTS.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,17 @@ When you hit a bug in generated code:
5454
Run exactly what's in [`CONTRIBUTING.md`](CONTRIBUTING.md) and mirrored in [`.github/workflows/generated.yml`](.github/workflows/generated.yml):
5555

5656
```sh
57+
uv sync --group regen
5758
curl -sf https://api.ionq.co/v0.4/api-docs -o openapi.json
58-
uvx oas-patch==0.6.0 overlay openapi.json openapi-overlay.yaml -o /tmp/patched-spec.json
59-
uvx openapi-python-client==0.28.3 generate \
59+
uv run oas-patch overlay openapi.json openapi-overlay.yaml -o /tmp/patched-spec.json
60+
uv run openapi-python-client generate \
6061
--path /tmp/patched-spec.json --meta none \
6162
--config openapi-python-client-config.yaml \
6263
--custom-template-path custom-templates \
6364
--output-path ionq_core --overwrite
6465
```
6566

66-
Both pinned versions appear in `CONTRIBUTING.md` *and* `.github/workflows/generated.yml`; `tests/test_docs_consistency.py` fails CI if you bump one without the other. Commit regenerated files in the same PR as the spec/template/overlay change that produced them.
67+
Commit regenerated files in the same PR as the spec/template/overlay change that produced them.
6768

6869
## Calling generated endpoints
6970

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,16 @@ CI runs them on a weekly schedule via the [`integration`](.github/workflows/inte
6262
To regenerate `ionq_core/api/`, `ionq_core/models/`, and the root-level generated files, run:
6363

6464
```sh
65+
uv sync --group regen
6566
curl -sf https://api.ionq.co/v0.4/api-docs -o openapi.json
6667

6768
if [ -f openapi-overlay.yaml ]; then
68-
uvx oas-patch==0.6.0 overlay openapi.json openapi-overlay.yaml -o /tmp/patched-spec.json
69+
uv run oas-patch overlay openapi.json openapi-overlay.yaml -o /tmp/patched-spec.json
6970
else
7071
cp openapi.json /tmp/patched-spec.json
7172
fi
7273

73-
uvx openapi-python-client==0.28.3 generate \
74+
uv run openapi-python-client generate \
7475
--path /tmp/patched-spec.json \
7576
--meta none \
7677
--config openapi-python-client-config.yaml \

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ dev = [
4545
"ty",
4646
"pdoc>=16",
4747
]
48+
regen = [
49+
"oas-patch==0.6.0",
50+
"openapi-python-client==0.28.3",
51+
]
4852

4953
[build-system]
5054
requires = ["hatchling"]

tests/test_docs_consistency.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
GITATTRIBUTES = (ROOT / ".gitattributes").read_text()
2020
CONTRIB = (ROOT / "CONTRIBUTING.md").read_text()
2121
AGENTS = (ROOT / "AGENTS.md").read_text()
22-
GENERATED_WF = (ROOT / ".github" / "workflows" / "generated.yml").read_text()
23-
SPEC_DRIFT_WF = (ROOT / ".github" / "workflows" / "spec-drift.yml").read_text()
2422

2523

2624
def _normalize(path: str) -> str:
@@ -44,12 +42,6 @@ def _ci_python_versions() -> list[str]:
4442
return re.findall(r'"(\d+\.\d+)"', m.group(1))
4543

4644

47-
def _pin(text: str, package: str) -> str:
48-
m = re.search(rf"{re.escape(package)}==(\S+)", text)
49-
assert m, f"{package} pin not found"
50-
return m.group(1)
51-
52-
5345
@pytest.mark.parametrize(
5446
"needle",
5547
[
@@ -119,14 +111,6 @@ def test_gitattributes_covers_ruff_paths_plus_init():
119111
assert gitattr == ruff | {"ionq_core/__init__.py"}
120112

121113

122-
def test_openapi_python_client_versions_match():
123-
assert _pin(CONTRIB, "openapi-python-client") == _pin(GENERATED_WF, "openapi-python-client")
124-
125-
126-
def test_oas_patch_versions_match():
127-
assert _pin(CONTRIB, "oas-patch") == _pin(GENERATED_WF, "oas-patch")
128-
129-
130114
def test_spec_path_matches_default_base_url():
131115
# Without this, a DEFAULT_BASE_URL bump leaves CONTRIBUTING.md pointing at a stale endpoint.
132116
spec_path = f"{urlparse(DEFAULT_BASE_URL).path}/api-docs"
@@ -150,12 +134,6 @@ def test_single_spdx_year_across_package():
150134
assert len(years) == 1, f"expected exactly one SPDX year, found: {years}"
151135

152136

153-
@pytest.mark.parametrize("package", ["openapi-python-client", "oas-patch"])
154-
def test_generator_pin_in_agents_md(package):
155-
"""Pinned versions in the AGENTS.md regen block match CONTRIBUTING.md."""
156-
assert _pin(AGENTS, package) == _pin(CONTRIB, package), f"{package} pin in AGENTS.md does not match CONTRIBUTING.md"
157-
158-
159137
def test_spec_path_in_agents_md():
160138
"""The api-docs path quoted in AGENTS.md tracks DEFAULT_BASE_URL."""
161139
spec_path = f"{urlparse(DEFAULT_BASE_URL).path}/api-docs"

0 commit comments

Comments
 (0)