forked from Universal-Commerce-Protocol/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (74 loc) · 3.11 KB
/
Copy pathtests.yml
File metadata and controls
80 lines (74 loc) · 3.11 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
# 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
- 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
- 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.4.x targets UCP 2026-04-08 (see the README compatibility
# table). Bump this pin together with the SDK version line.
run: ./generate_models.sh 2026-04-08
- 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-04-08 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."