Repository navigation
90 lines (82 loc) · 3.64 KB
/
Copy pathtests.yml
File metadata and controls
90 lines (82 loc) · 3.64 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
81
82
83
84
85
86
87
88
89
90
# 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, "release/**"]
pull_request:
branches: [main, "release/**"]
permissions:
contents: read
jobs:
schema-preprocessing:
name: Unit tests (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.0.1
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: pip install -e .
- name: Run unit 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.0.1
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: false
- name: Regenerate models from ucp-lock.json and verify zero drift
run: |
set -euo pipefail
LOCK_FIELDS="$(jq -er '
(.ucp_sha | select(type == "string" and test("^[0-9a-f]{40}$"))) as $sha |
(.ucp_schema_version | select(type == "string" and test("^[0-9]+\\.[0-9]+\\.[0-9]+$"))) as $ver |
"\($sha) \($ver)"
' ucp-lock.json)"
read -r UCP_SHA UCP_SCHEMA_VERSION <<< "$LOCK_FIELDS"
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT
base_url="https://github.com/Universal-Commerce-Protocol/ucp-schema/releases/download/v${UCP_SCHEMA_VERSION}"
curl -fsSL --retry 3 -o "$tmp_dir/ucp-schema-linux-x86_64" "${base_url}/ucp-schema-linux-x86_64"
curl -fsSL --retry 3 -o "$tmp_dir/SHA256SUMS" "${base_url}/SHA256SUMS"
(cd "$tmp_dir" && sha256sum -c --ignore-missing SHA256SUMS)
mkdir -p "$HOME/.local/bin"
install -m 0755 "$tmp_dir/ucp-schema-linux-x86_64" "$HOME/.local/bin/ucp-schema"
export PATH="$HOME/.local/bin:$PATH"
rm -rf "$RUNNER_TEMP/ucp-spec"
git clone --filter=blob:none --no-checkout https://github.com/Universal-Commerce-Protocol/ucp.git "$RUNNER_TEMP/ucp-spec"
git -C "$RUNNER_TEMP/ucp-spec" checkout --detach "$UCP_SHA"
./generate_models.sh --from-lock --spec-dir "$RUNNER_TEMP/ucp-spec"
if [ -n "$(git status --porcelain -- src/ucp_sdk pyproject.toml ucp-lock.json)" ]; then
echo "::error::Committed models differ from regeneration against ucp-lock.json. Run ./generate_models.sh --from-lock and commit the result."
git status --short -- src/ucp_sdk pyproject.toml ucp-lock.json
git --no-pager diff -- src/ucp_sdk pyproject.toml ucp-lock.json
exit 1
fi