-
-
Notifications
You must be signed in to change notification settings - Fork 435
206 lines (197 loc) · 6.79 KB
/
test.yaml
File metadata and controls
206 lines (197 loc) · 6.79 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
schedule:
- cron: "0 9 * * *"
concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
name: >-
${{ matrix.py || matrix.name }} on
${{ matrix.os == 'windows-latest' && 'Windows' || (matrix.os == 'macos-latest' && 'macOS' || 'Ubuntu') }}
strategy:
fail-fast: false
matrix:
py: ["3.14", "3.13", "3.12", "3.11", "3.10"]
os: [ubuntu-24.04, windows-latest, macos-latest]
tox_env: ['']
include:
- tox_env: py312-black24-parallel
name: py312-black24
- tox_env: py312-black23-parallel
name: py312-black23
- tox_env: py312-black22-parallel
name: py312-black22
- tox_env: py312-isort8-parallel
name: py312-isort8
- tox_env: py312-isort7-parallel
name: py312-isort7
- tox_env: py312-isort6-parallel
name: py312-isort6
- tox_env: py312-isort5-parallel
name: py312-isort5
runs-on: ${{ matrix.os == '' && 'ubuntu-24.04' || matrix.os }}
env:
OS: ${{ matrix.os == '' && 'ubuntu-24.04' || matrix.os}}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
persist-credentials: false
- name: Install the latest version of uv
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5
with:
enable-cache: true
cache-suffix: "${{ matrix.py || matrix.tox_env }}"
- name: Install tox
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv
- name: Setup Python test environment
run: |
if [ -n "${{ matrix.py }}" ]; then
TOX_ENV="py${{ matrix.py }}-parallel"
TOX_ENV="${TOX_ENV//.}"
else
TOX_ENV="${{ matrix.tox_env }}"
fi
tox run -vv --notest --skip-missing-interpreters false -e $TOX_ENV
shell: bash
env:
UV_PYTHON_PREFERENCE: "only-managed"
- name: Run test suite
run: |
if [ -n "${{ matrix.py }}" ]; then
TOX_ENV="py${{ matrix.py }}-parallel"
TOX_ENV="${TOX_ENV//.}"
else
TOX_ENV="${{ matrix.tox_env }}"
fi
tox run --skip-uv-sync --skip-pkg-install -e $TOX_ENV
shell: bash
env:
UV_PYTHON_PREFERENCE: "only-managed"
- name: Rename coverage report file
run: |
import os; import sys
py = "${{ matrix.py }}"
if py:
env_name = f"py{py.replace('.', '')}-parallel"
base_name = py
else:
env_name = "${{ matrix.tox_env }}"
base_name = "${{ matrix.tox_env }}"
os.rename(f".tox/.coverage.{env_name}", f".tox/.coverage.{base_name}-${{ matrix.os }}")
shell: python
- name: Upload coverage data
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
include-hidden-files: true
name: .coverage.${{ matrix.py || matrix.tox_env }}-${{ matrix.os == '' && 'ubuntu-24.04' || matrix.os }}
path: ".tox/.coverage.*"
retention-days: 3
coverage:
name: combine coverage
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
persist-credentials: false
- name: Install the latest version of uv
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5
- name: Install tox
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv
- name: Setup coverage tool
run: tox run -e coverage --notest
env:
UV_PYTHON_PREFERENCE: only-managed
- name: Download coverage data
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
path: .tox
pattern: .coverage.*
merge-multiple: true
- name: Combine and report coverage
id: coverage
run: tox run -e coverage --skip-uv-sync --skip-pkg-install
continue-on-error: true
env:
UV_PYTHON_PREFERENCE: only-managed
- name: Show uncovered lines on failure
if: steps.coverage.outcome == 'failure'
run: |
echo "::error::Coverage check failed. Lines not covered:"
COVERAGE_FILE=.tox/.coverage .tox/coverage/bin/coverage report --show-missing --fail-under=0 | grep -v "100%"
- name: Upload HTML report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: html-report
path: .tox/htmlcov
- name: Upload coverage to Codecov
if: always()
uses: codecov/codecov-action@75cd11691c0faa626561e295848008c8a7dddffe # v5
with:
flags: unittests
files: .tox/coverage.xml
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Fail if coverage check failed
if: steps.coverage.outcome == 'failure'
run: exit 1
check:
name: ${{ matrix.tox_env }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tox_env:
- type
- docs
- pkg_meta
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
persist-credentials: false
- name: Install the latest version of uv
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5
- name: Install tox
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv
- name: Setup check suite
run: tox r -vv --notest --skip-missing-interpreters false -e ${{ matrix.tox_env }}
env:
UV_PYTHON_PREFERENCE: "only-managed"
- name: Run check for ${{ matrix.tox_env }}
run: tox run --skip-uv-sync --skip-pkg-install -e ${{ matrix.tox_env }}
env:
UV_PYTHON_PREFERENCE: "only-managed"
test-gate:
name: test-gate
if: always()
runs-on: ubuntu-latest
needs:
- test
- coverage
- check
steps:
- name: Fail if any test workflow job failed
run: |
test_result='${{ needs.test.result }}'
coverage_result='${{ needs.coverage.result }}'
check_result='${{ needs.check.result }}'
echo "test: ${test_result}"
echo "coverage: ${coverage_result}"
echo "check: ${check_result}"
[ "${test_result}" = "success" ] || exit 1
[ "${coverage_result}" = "success" ] || exit 1
[ "${check_result}" = "success" ] || exit 1