forked from Universal-Commerce-Protocol/samples
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (90 loc) · 3.55 KB
/
Copy pathpython-server-tests.yml
File metadata and controls
103 lines (90 loc) · 3.55 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
91
92
93
94
95
96
97
98
99
100
101
102
103
# 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: Python Server Tests
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
env:
MERCHANT_SERVER_PORT: 8182
DATABASE_PATH: /tmp/ucp_test
jobs:
test:
name: Integration tests + happy-path client (rest/python)
runs-on: ubuntu-latest
steps:
- name: Check out samples repo
uses: actions/checkout@v5
with:
path: samples
- name: Check out SDK repo
uses: actions/checkout@v5
with:
repository: Universal-Commerce-Protocol/python-sdk
path: python-sdk
# rest/python/server consumes ucp-sdk as an editable path dependency
# (../../../../python-sdk), so an unpinned sibling checkout breaks
# whenever python-sdk@main moves incompatibly — as it did on
# 2026-06-30 with python-sdk#48 (see samples#118). Pin to the last
# compatible commit and bump deliberately, together with the code
# changes that adopt the newer SDK.
ref: f54858e0cf1e8933cc0e9d89b380e2cd4a0b3f00
- name: Install uv
uses: astral-sh/setup-uv@v8.2.0
- name: Set up Python
run: uv python install 3.12
- name: Sync server dependencies
run: uv sync --directory samples/rest/python/server/
- name: Run server integration tests
run: uv run --directory samples/rest/python/server pytest -v
- name: Initialize test database
run: |
rm -rf ${DATABASE_PATH}
mkdir -p ${DATABASE_PATH}
uv run --directory samples/rest/python/server import_csv.py \
--products_db_path=${DATABASE_PATH}/products.db \
--transactions_db_path=${DATABASE_PATH}/transactions.db \
--data_dir=../test_data/flower_shop
- name: Start Flower Shop server
run: |
uv run --directory samples/rest/python/server server.py \
--products_db_path=${DATABASE_PATH}/products.db \
--transactions_db_path=${DATABASE_PATH}/transactions.db \
--port=${MERCHANT_SERVER_PORT} &
# Wait for the server to be ready
for i in $(seq 1 30); do
if curl -sf http://localhost:${MERCHANT_SERVER_PORT}/.well-known/ucp > /dev/null 2>&1; then
echo "Server is ready"
break
fi
if [ "$i" -eq 30 ]; then
echo "Server failed to start within 30 seconds"
exit 1
fi
sleep 1
done
- name: Run happy-path client
run: |
uv sync --directory samples/rest/python/client/flower_shop
uv run --directory samples/rest/python/client/flower_shop \
simple_happy_path_client.py \
--server_url=http://localhost:${MERCHANT_SERVER_PORT} 2>&1 \
| tee client.log
# The client logs failures without a non-zero exit status, so
# assert on the explicit success marker.
grep -q "Happy Path completed successfully." client.log