-
Notifications
You must be signed in to change notification settings - Fork 50
293 lines (267 loc) · 9.97 KB
/
Copy pathtest-gpu.yml
File metadata and controls
293 lines (267 loc) · 9.97 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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
name: GPU Tests
on:
workflow_dispatch:
issue_comment:
types: [created]
push:
branches: [main]
pull_request:
types:
- opened
- synchronize
# Cancel the job if new commits are pushed
# https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.issue.number || github.ref }}
cancel-in-progress: true
jobs:
set-pending:
name: GPU Tests Pending
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
statuses: write
steps:
- name: Set pending status on PR
run: |
for context in "CI-Pass" "All Tests Green"; do
gh api repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }} \
-f state=pending \
-f context="$context" \
-f description="Waiting for /test-gpu command..."
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
check:
runs-on: ubuntu-latest
# Skip pull_request (handled by set-pending) and issue_comment unless /test-gpu
if: >-
github.event_name != 'pull_request' && (
github.event_name != 'issue_comment' ||
(github.event.issue.pull_request && startsWith(github.event.comment.body, '/test-gpu'))
)
outputs:
head-sha: ${{ steps.get-sha.outputs.sha }}
permissions:
pull-requests: write
statuses: write
steps:
- name: Check permissions
if: github.event_name == 'issue_comment' || github.event_name == 'workflow_dispatch'
run: |
PERMISSION=$(gh api repos/${{ github.repository }}/collaborators/${{ github.actor }}/permission --jq '.permission')
if [[ "$PERMISSION" != "admin" && "$PERMISSION" != "maintain" ]]; then
echo "::error::Only maintainers or admins can trigger this workflow. Your permission: $PERMISSION"
exit 1
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: React to comment
if: github.event_name == 'issue_comment'
run: |
gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions -f content=rocket
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get PR head SHA
id: get-sha
if: github.event_name == 'issue_comment'
run: |
SHA=$(gh pr view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json headRefOid -q .headRefOid)
echo "sha=$SHA" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set pending status on PR
if: github.event_name == 'issue_comment'
run: |
for context in "CI-Pass" "All Tests Green"; do
gh api repos/${{ github.repository }}/statuses/${{ steps.get-sha.outputs.sha }} \
-f state=pending \
-f context="$context" \
-f description="GPU tests running..." \
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
get-envs:
runs-on: ubuntu-latest
needs: check
outputs:
stable-dev: ${{ steps.get-envs.outputs.stable-dev }}
prerelease: ${{ steps.get-envs.outputs.prerelease }}
steps:
- uses: actions/checkout@v6
with:
filter: blob:none
fetch-depth: 0
ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || '' }}
- uses: astral-sh/setup-uv@v6
with:
enable-cache: false
- id: get-envs
run: |
# Stable and dev environments
STABLE_DEV_JSON=$(uvx hatch env show --json | jq -c '
to_entries
| map(
select(.key | startswith("hatch-test") and endswith("12") and (contains("prerelease") | not))
| {
name: .key,
python: .value.python | sub("3[.]13"; "3.13.3"),
}
)')
echo "stable-dev=${STABLE_DEV_JSON}" | tee -a $GITHUB_OUTPUT
# Prerelease environments
PRERELEASE_JSON=$(uvx hatch env show --json | jq -c '
to_entries
| map(
select(.key | startswith("hatch-test") and endswith("12") and contains("prerelease"))
| {
name: .key,
python: .value.python | sub("3[.]13"; "3.13.3"),
}
)')
echo "prerelease=${PRERELEASE_JSON}" | tee -a $GITHUB_OUTPUT
test-stable-dev:
name: Test (${{ matrix.env.name }})
needs: get-envs
runs-on: cirun-aws-gpu
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
env: ${{ fromJson(needs.get-envs.outputs.stable-dev) }}
env:
ENV_NAME: ${{ matrix.env.name }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
filter: blob:none
ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || '' }}
- uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.env.python }}
- name: Install dependencies
run: uvx hatch -v env create ${{ matrix.env.name }}
- name: Run tests
run: |
mkdir -p test-data
if [[ "${{ matrix.env.name }}" == *"stable"* ]]; then
uvx hatch run ${{ matrix.env.name }}:run-cov -v --color=yes
uvx hatch run ${{ matrix.env.name }}:coverage xml
uvx hatch run ${{ matrix.env.name }}:cov-report
else
uvx hatch run ${{ matrix.env.name }}:run -v --color=yes
fi
- name: Upload test results
if: ${{ !cancelled() && contains(matrix.env.name, 'stable') }}
uses: codecov/codecov-action@v5
with:
report_type: test_results
files: test-data/test-results.xml
use_oidc: false
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage data
if: contains(matrix.env.name, 'stable')
uses: codecov/codecov-action@v5
with:
files: test-data/coverage.xml
use_oidc: false
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
test-prerelease:
name: Test (${{ matrix.env.name }})
needs: get-envs
runs-on: cirun-aws-gpu
timeout-minutes: 30
continue-on-error: true # Prerelease failures don't fail the workflow
strategy:
fail-fast: false
matrix:
env: ${{ fromJson(needs.get-envs.outputs.prerelease) }}
env:
ENV_NAME: ${{ matrix.env.name }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
filter: blob:none
ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || '' }}
- uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.env.python }}
- name: Install dependencies
run: uvx hatch -v env create ${{ matrix.env.name }}
- name: Run tests
run: uvx hatch run ${{ matrix.env.name }}:run -v --color=yes
stable-dev-green:
name: CI-Pass
if: always() && github.event_name != 'pull_request'
needs:
- check
- get-envs
- test-stable-dev
runs-on: ubuntu-latest
permissions:
statuses: write
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
- name: Set success status on PR
if: success() && github.event_name == 'issue_comment'
run: |
gh api repos/${{ github.repository }}/statuses/${{ needs.check.outputs.head-sha }} \
-f state=success \
-f context="CI-Pass" \
-f description="GPU tests passed" \
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set failure status on PR
if: failure() && github.event_name == 'issue_comment'
run: |
gh api repos/${{ github.repository }}/statuses/${{ needs.check.outputs.head-sha }} \
-f state=failure \
-f context="CI-Pass" \
-f description="GPU tests failed" \
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
all-green:
name: All Tests Green
if: always() && github.event_name != 'pull_request'
needs:
- check
- get-envs
- test-stable-dev
- test-prerelease
runs-on: ubuntu-latest
permissions:
statuses: write
steps:
- uses: re-actors/alls-green@release/v1
with:
allowed-failures: test-prerelease
jobs: ${{ toJSON(needs) }}
- name: Set success status on PR
if: success() && github.event_name == 'issue_comment'
run: |
gh api repos/${{ github.repository }}/statuses/${{ needs.check.outputs.head-sha }} \
-f state=success \
-f context="All Tests Green" \
-f description="All GPU tests passed" \
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set failure status on PR
if: failure() && github.event_name == 'issue_comment'
run: |
gh api repos/${{ github.repository }}/statuses/${{ needs.check.outputs.head-sha }} \
-f state=failure \
-f context="All Tests Green" \
-f description="GPU tests failed" \
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}