Skip to content

docs: format README Python example (#95) #111

docs: format README Python example (#95)

docs: format README Python example (#95) #111

Workflow file for this run

# Copyright 2026 UCP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
schema-preprocessing:
name: Schema preprocessing (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
with:
python-version: ${{ matrix.python-version }}
- name: Install package (generated-model tests import it)
run: pip install -e .
- name: Run preprocessing tests
run: python -m unittest discover -s tests -p "test_*.py"
model-drift:
name: Generated models match the pinned UCP spec
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: true
- name: Regenerate models from the pinned spec version
# SDK 0.5.x targets UCP 2026-08-25 (see the README compatibility
# table). Bump this pin together with the SDK version line.
run: ./generate_models.sh 2026-08-25
- name: Normalize file endings (as pre-commit's end-of-file-fixer does)
run: |
python3 - <<'PY'
from pathlib import Path
for path in Path("src/ucp_sdk/models/schemas").rglob("*.py"):
text = path.read_text(encoding="utf-8")
fixed = text.rstrip("\n") + "\n" if text.strip() else ""
if fixed != text:
path.write_text(fixed, encoding="utf-8")
PY
- name: Fail if regeneration does not reproduce the committed models
run: |
git add -A -- src/ucp_sdk/models/schemas
if ! git diff --cached --quiet -- src/ucp_sdk/models/schemas; then
echo "::error::Committed models differ from regeneration against the pinned UCP spec. Either the generation pipeline is broken, or the models were edited without regenerating. Run ./generate_models.sh 2026-08-25 and commit the result."
git --no-pager diff --cached --stat -- src/ucp_sdk/models/schemas
git --no-pager diff --cached -- src/ucp_sdk/models/schemas
exit 1
fi
echo "Committed models match regeneration."