-
-
Notifications
You must be signed in to change notification settings - Fork 1
125 lines (108 loc) · 3.6 KB
/
tests.yaml
File metadata and controls
125 lines (108 loc) · 3.6 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
name: Testing
on:
push:
branches:
- main
pull_request:
types:
- "reopened"
- "opened"
- "synchronize"
workflow_call:
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Run lint with tox
run: uvx --with tox-uv tox -e lint
test:
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
python-config:
- version: "3.10"
tox-env: "py310"
- version: "3.11"
tox-env: "py311"
- version: "3.12"
tox-env: "py312"
- version: "3.13"
tox-env: "py313"
- version: "3.14"
tox-env: "py314"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # Fetch all history for hatch-vcs to work
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python ${{ matrix.python-config.version }}
run: uv python install ${{ matrix.python-config.version }}
- name: Configure git for tests
run: git config --global protocol.file.allow always
- name: Run tests with tox
run: uvx --with tox-uv tox -e ${{ matrix.python-config.tox-env }}
# Upload coverage data from this matrix job
- name: Upload coverage data
uses: actions/upload-artifact@v5
with:
name: coverage-data-${{ matrix.os }}-${{ matrix.python-config.tox-env }}
path: .coverage.*
include-hidden-files: true
if-no-files-found: ignore
# Combine coverage from all matrix jobs and report
coverage:
name: Combine & check coverage
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
run: uv python install 3.12
- name: Create virtual environment
run: uv venv
- name: Install coverage
run: uv pip install coverage[toml]
# Download all coverage artifacts from matrix jobs
- name: Download coverage data
uses: actions/download-artifact@v6
with:
pattern: coverage-data-*
merge-multiple: true
# Combine all .coverage.* files into one .coverage database
- name: Combine coverage data
run: |
uv run python -Im coverage combine
uv run python -Im coverage html
uv run python -Im coverage json
# Export total coverage percentage for badge
export TOTAL=$(uv run python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
# Generate markdown report and add to GitHub summary
- name: Generate coverage report
run: |
echo "## Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
uv run python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
# Upload HTML coverage report as artifact for debugging
- name: Upload HTML coverage report
uses: actions/upload-artifact@v5
with:
name: html-coverage-report
path: htmlcov/
# Fail if coverage is below threshold
- name: Fail if coverage is below threshold
run: |
uv run python -Im coverage report --fail-under=35