Skip to content

Commit 94e0c8e

Browse files
committed
skip openapi spec download in ci
1 parent d8faecc commit 94e0c8e

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

.github/workflows/_integration_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ jobs:
4444
shell: bash
4545
run: poetry install --with quality,tests
4646

47-
- name: Make install
47+
- name: Generate OpenAPI client
4848
run: |
49-
make install
49+
make generate-client-from-existing-spec
5050
5151
- name: Install together
5252
run: |

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ format:
3737
generate-client:
3838
python scripts/generate_api_client.py
3939

40+
generate-client-from-existing-spec:
41+
python scripts/generate_api_client.py --skip-spec-download
42+
4043
# Documentation
4144

4245
html:

scripts/generate_api_client.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
from __future__ import annotations
33

4+
import argparse
45
import shutil
56
import subprocess
67
import sys
@@ -28,13 +29,32 @@ def download_file(url: str, target: Path) -> None:
2829
run_command(["wget", "-O", str(target), url])
2930

3031

32+
def parse_args() -> argparse.Namespace:
33+
"""Parse command line arguments."""
34+
parser = argparse.ArgumentParser(description="Generate Together API client")
35+
parser.add_argument(
36+
"--skip-spec-download",
37+
action="store_true",
38+
help="Skip downloading the OpenAPI spec file",
39+
)
40+
return parser.parse_args()
41+
42+
3143
def main() -> None:
32-
# Download OpenAPI spec
44+
args = parse_args()
3345
spec_file = Path(__file__).parent / "openapi.yaml"
34-
download_file(OPENAPI_SPEC_URL, spec_file)
3546

36-
# Run formatter on the spec for better merge conflict handling
37-
run_command(["npx", "-y", "prettier", "--write", str(spec_file)])
47+
# Download OpenAPI spec if not skipped
48+
if not args.skip_spec_download:
49+
download_file(OPENAPI_SPEC_URL, spec_file)
50+
# Run formatter on the spec for better merge conflict handling
51+
run_command(["npx", "-y", "prettier", "--write", str(spec_file)])
52+
elif not spec_file.exists():
53+
print(
54+
"Error: OpenAPI spec file not found and download was skipped",
55+
file=sys.stderr,
56+
)
57+
sys.exit(1)
3858

3959
# Download generator if needed
4060
download_file(GENERATOR_JAR_URL, GENERATOR_JAR)

0 commit comments

Comments
 (0)