Skip to content

ci: normalize generator whitespace in Python conformance #2

ci: normalize generator whitespace in Python conformance

ci: normalize generator whitespace in Python conformance #2

name: Generated SDK Conformance
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
jobs:
regenerate-and-build:
runs-on: blacksmith-2vcpu-ubuntu-2404
timeout-minutes: 10
steps:
- uses: actions/checkout@v5
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '21'
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Fetch immutable contract
run: |
curl --fail --location \
https://raw.githubusercontent.com/CoreLinkPlatform/api-contracts/v1.0.0-draft/openapi/corelink-public-v1.yaml \
--output /tmp/corelink-public-v1.yaml
- name: Fetch pinned generator
run: |
curl --fail --location \
https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.12.0/openapi-generator-cli-7.12.0.jar \
--output /tmp/openapi-generator-cli.jar
- name: Regenerate in temporary directory
run: |
rm -rf /tmp/corelink-python-generated
mkdir -p /tmp/corelink-python-generated
java -jar /tmp/openapi-generator-cli.jar generate \
-i /tmp/corelink-public-v1.yaml \
-g python \
-o /tmp/corelink-python-generated \
--additional-properties=packageName=corelink_sdk,projectName=corelink-sdk,packageVersion=0.1.0.dev0 \
--global-property=apiDocs=false,modelDocs=false
- name: Verify generated source is reproducible
run: |
python - <<'PY'
from pathlib import Path
left = Path('corelink_sdk')
right = Path('/tmp/corelink-python-generated/corelink_sdk')
left_files = {p.relative_to(left) for p in left.rglob('*') if p.is_file() and '__pycache__' not in p.parts}
right_files = {p.relative_to(right) for p in right.rglob('*') if p.is_file() and '__pycache__' not in p.parts}
if left_files != right_files:
missing = sorted(str(p) for p in left_files - right_files)
extra = sorted(str(p) for p in right_files - left_files)
raise SystemExit(f'generated file-set drift: missing={missing} extra={extra}')
for rel in sorted(left_files, key=str):
a = '\n'.join(line.rstrip() for line in (left / rel).read_text().splitlines())
b = '\n'.join(line.rstrip() for line in (right / rel).read_text().splitlines())
if a != b:
raise SystemExit(f'generated semantic drift: {rel}')
print('Generated Python source matches pinned contract (ignoring trailing whitespace).')
PY
- name: Compile checked-in SDK
run: python -m compileall corelink_sdk