-
Notifications
You must be signed in to change notification settings - Fork 48
216 lines (193 loc) · 7.11 KB
/
Copy pathtest-gpu.yml
File metadata and controls
216 lines (193 loc) · 7.11 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
name: GPU Tests
on:
push:
branches: [main]
pull_request:
types:
- labeled
- 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.ref }}
cancel-in-progress: true
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Require push to main or 'run-gpu-ci' label
if: ${{ !(github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'run-gpu-ci')) }}
run: |
echo "::error::GPU CI requires a push to main or the 'run-gpu-ci' label on the PR."
exit 1
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
- uses: astral-sh/setup-uv@v8.1.0
with:
enable-cache: false
- id: get-envs
run: |
# Stable + dev, all cu13 (stable -> T4, dev -> A10)
STABLE_DEV_JSON=$(uvx --from "hatch==1.16.5" hatch env show --json | jq -c '
to_entries
| map(
select(.key | startswith("hatch-test"))
| select(
((.key | contains("stable")) and (.key | endswith("13")))
or ((.key | contains("dev")) and (.key | endswith("13")))
)
| {
name: .key,
python: .value.python | sub("3[.]13"; "3.13.3"),
runner: (if (.key | contains("stable")) then "cirun-aws-gpu-t4" else "cirun-aws-gpu-a10" end),
}
)')
echo "stable-dev=${STABLE_DEV_JSON}" | tee -a $GITHUB_OUTPUT
# Prerelease environments (cu13 -> A10)
PRERELEASE_JSON=$(uvx --from "hatch==1.16.5" hatch env show --json | jq -c '
to_entries
| map(
select(.key | startswith("hatch-test") and endswith("13") and contains("prerelease"))
| {
name: .key,
python: .value.python | sub("3[.]13"; "3.13.3"),
runner: "cirun-aws-gpu-a10",
}
)')
echo "prerelease=${PRERELEASE_JSON}" | tee -a $GITHUB_OUTPUT
test-stable-dev:
name: Test (${{ matrix.env.name }})
needs: get-envs
runs-on: ${{ matrix.env.runner }}
timeout-minutes: 30
strategy:
fail-fast: false
max-parallel: 2
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
- uses: astral-sh/setup-uv@v8.1.0
with:
python-version: ${{ matrix.env.python }}
- name: Add CUDA to PATH
run: |
echo "/usr/local/cuda/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV
- name: Install dependencies
run: uvx --from "hatch==1.16.5" hatch -v env create ${{ matrix.env.name }}
- name: Run tests
run: |
mkdir -p test-data
if [[ "${{ matrix.env.name }}" == *"stable"* ]]; then
uvx --from "hatch==1.16.5" hatch run ${{ matrix.env.name }}:run-cov -v --color=yes
uvx --from "hatch==1.16.5" hatch run ${{ matrix.env.name }}:coverage xml
uvx --from "hatch==1.16.5" hatch run ${{ matrix.env.name }}:cov-report
else
uvx --from "hatch==1.16.5" 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@v6
with:
report_type: test_results
files: test-data/test-results.xml
use_oidc: false
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage data
if: contains(matrix.env.name, 'stable')
uses: codecov/codecov-action@v6
with:
files: test-data/coverage.xml
use_oidc: false
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
test-prerelease:
name: Test (${{ matrix.env.name }})
needs: get-envs
runs-on: ${{ matrix.env.runner }}
timeout-minutes: 30
continue-on-error: true # Prerelease failures don't fail the workflow
strategy:
fail-fast: false
max-parallel: 2
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
- uses: astral-sh/setup-uv@v8.1.0
with:
python-version: ${{ matrix.env.python }}
- name: Add CUDA to PATH
run: |
echo "/usr/local/cuda/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV
- name: Check CUDA version
run: nvcc --version
- name: Check NVIDIA SMI
run: nvidia-smi
- name: Install dependencies
run: uvx --from "hatch==1.16.5" hatch -v env create ${{ matrix.env.name }}
- name: Run tests
run: uvx --from "hatch==1.16.5" hatch run ${{ matrix.env.name }}:run -v --color=yes
remove-label:
name: Remove 'run-gpu-ci' Label
runs-on: ubuntu-latest
if: ${{ always() && github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-gpu-ci') }}
permissions:
pull-requests: write
steps:
- name: Remove 'run-gpu-ci' label
run: gh api -X DELETE "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/run-gpu-ci" || true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
stable-dev-green:
name: CI-Pass
if: always()
needs:
- get-envs
- test-stable-dev
runs-on: ubuntu-latest
steps:
- name: Check required jobs succeeded
run: |
if [[ "${{ needs.get-envs.result }}" != "success" || "${{ needs.test-stable-dev.result }}" != "success" ]]; then
echo "::error::Required jobs did not succeed (get-envs=${{ needs.get-envs.result }}, test-stable-dev=${{ needs.test-stable-dev.result }})."
exit 1
fi
all-green:
name: All Tests Green
if: always()
needs:
- get-envs
- test-stable-dev
- test-prerelease
runs-on: ubuntu-latest
steps:
- name: Check required jobs succeeded (test-prerelease allowed to fail)
run: |
if [[ "${{ needs.get-envs.result }}" != "success" || "${{ needs.test-stable-dev.result }}" != "success" ]]; then
echo "::error::Required jobs did not succeed (get-envs=${{ needs.get-envs.result }}, test-stable-dev=${{ needs.test-stable-dev.result }})."
exit 1
fi