Repository navigation
167 lines (145 loc) · 5.78 KB
/
Copy pathunit-tests.yml
File metadata and controls
167 lines (145 loc) · 5.78 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
---
name: Run Unit Tests
on:
push:
branches: [main]
pull_request:
paths:
- 'src/**'
- 'tests/**'
- 'pyproject.toml'
- 'uv.lock'
- 'scripts/run_db_tests.sh'
- 'scripts/docker-compose.test.yml'
# Self-callout: re-run when this workflow changes so YAML edits are validated in PRs.
- '.github/workflows/unit-tests.yml'
permissions:
contents: read
jobs:
test:
name: Test with Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
if: github.repository == 'a2aproject/a2a-python'
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: a2a
POSTGRES_PASSWORD: a2a_password
POSTGRES_DB: a2a_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: a2a_test
MYSQL_USER: a2a
MYSQL_PASSWORD: a2a_password
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h localhost -u root -proot" --health-interval=10s --health-timeout=5s --health-retries=5
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Set up test environment variables
run: |
echo "POSTGRES_TEST_DSN=postgresql+asyncpg://a2a:a2a_password@localhost:5432/a2a_test" >> $GITHUB_ENV
echo "MYSQL_TEST_DSN=mysql+aiomysql://a2a:a2a_password@localhost:3306/a2a_test" >> $GITHUB_ENV
- name: Install uv for Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
with:
python-version: ${{ matrix.python-version }}
- name: Add uv to PATH
run: |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
# Coverage comparison for PRs (only on Python 3.14 to avoid duplicate work)
- name: Checkout Base Branch
if: github.event_name == 'pull_request' && matrix.python-version == '3.14'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
ref: ${{ github.event.pull_request.base.ref || 'main' }}
clean: true
- name: Install dependencies
run: uv sync --locked
- name: Run coverage (Base)
if: github.event_name == 'pull_request' && matrix.python-version == '3.14'
run: |
uv run pytest --cov=a2a --cov-report=json --cov-report=html:coverage
mv coverage.json /tmp/coverage-base.json
- name: Checkout PR Branch (Restore)
if: github.event_name == 'pull_request' && matrix.python-version == '3.14'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
clean: true
- name: Run coverage (PR)
if: github.event_name == 'pull_request' && matrix.python-version == '3.14'
run: |
uv run pytest --cov=a2a --cov-report=json --cov-report=html:coverage --cov-report=term --cov-fail-under=88
mv coverage.json coverage-pr.json
cp /tmp/coverage-base.json coverage-base.json
- name: Save Metadata
if: github.event_name == 'pull_request' && matrix.python-version == '3.14'
run: |
echo ${{ github.event.number }} > ./PR_NUMBER
echo ${{ github.event.pull_request.base.ref || 'main' }} > ./BASE_BRANCH
- name: Upload Coverage Artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: github.event_name == 'pull_request' && matrix.python-version == '3.14'
with:
name: coverage-data
path: |
coverage-base.json
coverage-pr.json
coverage/
PR_NUMBER
BASE_BRANCH
retention-days: 1
# Run standard tests (for matrix items that didn't run coverage PR)
- name: Run tests (Standard)
if: matrix.python-version != '3.14' || github.event_name != 'pull_request'
run: uv run pytest --cov=a2a --cov-report term --cov-fail-under=88
- name: Upload Artifact (base)
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: github.event_name != 'pull_request' && matrix.python-version == '3.14'
with:
name: coverage-report
path: coverage
retention-days: 14
- name: Show coverage summary in log
run: uv run coverage report
# httpx2 testing - Running test on httpx2 for marked tests
httpx2:
name: Test with httpx2 (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
if: github.repository == 'a2aproject/a2a-python'
strategy:
matrix:
python-version: ['3.11', '3.12', '3.13', '3.14']
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- name: Install uv for Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
with:
python-version: ${{ matrix.python-version }}
- name: Add uv to PATH
run: |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install dependencies
run: uv sync --locked --group httpx2
# httpx_lib silently falls back to httpx when httpx2 is missing, thus installing httpx2 is required
- name: Verify httpx2 is the installed flavor
run: |
uv run python -c "
from a2a.utils._httpx_compat import httpx_lib
assert httpx_lib.__name__ == 'httpx2', httpx_lib.__name__
"
- name: Run tests
run: uv run pytest -m httpx2