-
Notifications
You must be signed in to change notification settings - Fork 3
258 lines (214 loc) · 7.22 KB
/
Copy pathtest.yml
File metadata and controls
258 lines (214 loc) · 7.22 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
name: Test src_method
# specify which events will trigger this workflow
on:
# run on all pushed to main
push:
branches:
- main
# PRs trigger for the "opened", "reopened", "synchronize" events (default) and
# "ready_for_review"
pull_request:
types:
- opened
- reopened
- synchronize # when new commits are pushed to the PR
- ready_for_review # when the PR is un-drafted
release:
types:
- published
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
COLUMNS: 120
FORCE_COLOR: 3
jobs:
test:
# in combination with the PR types selection, this top-level if statement
# skips running the workflow for Draft PRs
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'test-in-draft') }}
defaults:
run:
shell: bash
strategy:
matrix:
runner:
- ubuntu-latest
- gpu-runner
python-version:
- "3.11"
- "3.14"
test-group:
- "not slow and not perf"
runs-on: ${{ matrix.runner }}
steps:
- name: Runner hardware info Linux
if: ${{ runner.os == 'linux' }}
run: |
lscpu | egrep 'Model name|Socket|Thread|NUMA|CPU\(s\)'
NTHREADS=$(lscpu | egrep 'CPU\(s\):' | head -n 1 | awk '{ print $2 }')
echo "NTHREADS: $NTHREADS"
echo "OMP_NUM_THREADS=$NTHREADS" >> $GITHUB_ENV
- name: Check out repository
uses: actions/checkout@v7
with:
# grab the history of the PR, so setuptools-scm can compute the correct version number
fetch-depth: 0
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
if [[ "${{ matrix.runner }}" == "gpu-runner" ]]; then
extras="--extra gpu-nvidia"
else
extras=""
fi
uv sync --no-progress --no-dev --group test $extras
- name: Python environment information
run: |
uv tree
- name: Get src_method version
run: |
uv run python -c "import src_method; print(src_method.__version__)"
- name: CuPy configuration
if: ${{ matrix.runner == 'gpu-runner' }}
run: |
uv run python -c 'import cupy; cupy.show_config()'
- name: GPU diagnostics
if: ${{ matrix.runner == 'gpu-runner' }}
run: |
nvidia-smi
- name: Get test group label
id: test-group-label
run: |
runner="${{ matrix.runner }}"
pyver="${{ matrix.python-version }}"
echo "label=$runner-$pyver" >> $GITHUB_OUTPUT
- name: Run tests
run: >-
uv run python -m pytest
-r aR
--durations=50
--durations-min=5.0
--junit-xml=pytest-"${{ steps.test-group-label.outputs.label }}".xml
--cov=src
--cov-branch
--cov-report=lcov:lcov.info
--cov-report=xml:coverage-"${{ steps.test-group-label.outputs.label }}".xml
- name: Upload Test Results as artifacts
uses: actions/upload-artifact@v7
with:
name: test_results_${{ steps.test-group-label.outputs.label }}
path: |
pytest-*.xml
coverage-*.xml
retention-days: 1
test-matrix:
# The ruleset requires a check named after this workflow, but the matrix
# only ever reports per-combination names. This job publishes that name and
# keeps it independent of the matrix dimensions.
name: Test src_method
if: always()
needs: test
runs-on: ubuntu-latest
steps:
- name: Report the matrix result
run: |
echo "test: ${{ needs.test.result }}"
case "${{ needs.test.result }}" in
success|skipped) ;;
*) exit 1 ;;
esac
benchmark:
# Fails on a median slowdown of more than 25%. The threshold is wide
# because this runs on a shared runner, where no-op PRs have drifted by
# up to 20%; anything tighter reports noise as a regression.
name: 'Run Benchmark Comparison'
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: 'Checkout Base Branch (main)'
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.base.sha }}
- name: 'Install the latest version of uv'
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
# This job builds both the base and the PR checkout, so the version
# must satisfy `requires-python` on both sides of the comparison.
python-version: "3.13"
- name: 'Install dependencies'
run: |
uv sync --group test
- name: 'Run Benchmark on Base'
run: |
uv run python -m pytest -m "perf" \
--log-cli-level=WARNING \
--benchmark-save=baseline \
--benchmark-storage=file://benchmarks_data
- name: 'Upload Baseline Artifact'
uses: actions/upload-artifact@v7
with:
name: benchmark-baseline
path: benchmarks_data/**/*.json
- name: 'Checkout PR Branch'
uses: actions/checkout@v7
with:
clean: false
- name: 'Download Baseline Artifact'
uses: actions/download-artifact@v8
with:
name: benchmark-baseline
path: baseline-benchmarks/
- name: 'Run and Compare Benchmarks'
id: comparison
run: |
uv run python -m pytest -m "perf" \
-W ignore::pytest_benchmark.logger.PytestBenchmarkWarning \
--log-cli-level=WARNING \
--benchmark-storage=file://baseline-benchmarks \
--benchmark-compare-fail=median:25% \
--benchmark-compare=0001
publish-test-results:
name: "Publish Tests Results"
needs: test
runs-on: ubuntu-latest
# exposed at job level so the scan step can test for its presence in `if`
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
permissions:
checks: write
# only needed unless run with comment_mode: off
pull-requests: write
# only needed for private repository
contents: read
# only needed for private repository
issues: read
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
# grab the history of the PR, so setuptools-scm can compute the correct version number
fetch-depth: 0
- name: Download Artifacts
uses: actions/download-artifact@v8
with:
merge-multiple: true
- name: SonarQube Scan
# forks and unconfigured checkouts have no token; skip rather than fail
if: ${{ env.SONAR_TOKEN != '' }}
uses: SonarSource/sonarqube-scan-action@v8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files:
pytest-*.xml