-
Notifications
You must be signed in to change notification settings - Fork 4
62 lines (48 loc) · 2 KB
/
python-tests.yml
File metadata and controls
62 lines (48 loc) · 2 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
name: Python SDK Tests
on:
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
test:
permissions:
pull-requests: write
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Install uv
uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098 # v7
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: ${{ matrix.python-version }}
- name: Install hatch
run: uv tool install hatch
- name: Install dependencies
working-directory: ./
run: |
uv pip install --system --editable .
uv pip install --system pytest pytest-cov anyio pytest-asyncio
- name: Run tests
working-directory: ./
run: |
hatch run test
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_OUTPUT
echo "COVERAGE_PCT=$(python -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage.xml'); root = tree.getroot(); print(f'{float(root.attrib[\"line-rate\"]) * 100:.2f}')")" >> $GITHUB_OUTPUT
echo "TEST_COUNT=$(python -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage.xml'); root = tree.getroot(); print(root.find('.//metrics').attrib['tests'])")" >> $GITHUB_OUTPUT
id: test_results
- name: Create result file
run: |
mkdir -p test-results
echo "${{ steps.test_results.outputs.COVERAGE_PCT }}" > test-results/coverage.txt
echo "${{ steps.test_results.outputs.TEST_COUNT }}" > test-results/test-count.txt
- name: Upload test results
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: test-results-${{ matrix.python-version }}
path: test-results/