-
Notifications
You must be signed in to change notification settings - Fork 226
273 lines (236 loc) · 8.83 KB
/
ci_linux.yml
File metadata and controls
273 lines (236 loc) · 8.83 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
name: CI on Linux
on:
# Trigger builds on pull requests
pull_request:
paths-ignore:
- "**.md"
# Trigger builds AND tests on push to main
push:
branches:
- main
paths-ignore:
- "**.md"
# Add manual trigger via Actions UI for running BOTH build and test
workflow_dispatch:
env:
RUST_LOG: info
RUST_BACKTRACE: 1
jobs:
build:
name: Build / ${{ matrix.variance.name }}
runs-on: ${{ matrix.variance.runner }}
strategy:
fail-fast: false
matrix:
variance:
- name: Ubuntu-24.04 / CUDA-12.8.1 / x86_64
image: "ghcr.io/rust-gpu/rust-cuda-ubuntu24-cuda12:latest"
runner: ubuntu-latest
- name: Ubuntu-24.04 / CUDA-12.8.1 / ARM64
image: "ghcr.io/rust-gpu/rust-cuda-ubuntu24-cuda12:latest"
runner: ubuntu-24.04-arm
- name: RockyLinux-9 / CUDA-12.8.1 / x86_64
image: "ghcr.io/rust-gpu/rust-cuda-rockylinux9-cuda12:latest"
runner: ubuntu-latest
outputs:
# Output the result of the permission check
actor_has_write_permission: ${{ steps.check_access.outputs.require-result }}
# Output the build artifact details so the test job can use them
artifact_name: ${{ steps.artifact_details.outputs.name }}
artifact_path: ${{ steps.artifact_details.outputs.path }}
steps:
- name: Free up space
# Without this the job will likely run out of disk space.
run: |
df -h
# Remove Java
sudo rm -rf /usr/lib/jvm
# Remove .NET
sudo rm -rf /usr/share/dotnet
# Remove Swift
sudo rm -rf /usr/share/swift
# Remove Haskell
sudo rm -rf /usr/local/.ghcup
# Remove Julia
sudo rm -rf /usr/local/julia*
# Remove Android SDKs
sudo rm -rf /usr/local/lib/android
# Remove Chromium
sudo rm -rf /usr/local/share/chromium
# Remove Microsoft/Edge and Google Chrome builds
sudo rm -rf /opt/microsoft /opt/google
# Remove Azure CLI
sudo rm -rf /opt/az
# Remove PowerShell
sudo rm -rf /usr/local/share/powershell
# Remove CodeQL and other toolcaches
sudo rm -rf /opt/hostedtoolcache
docker system prune -af || true
docker builder prune -af || true
df -h
- name: Checkout repository
uses: actions/checkout@v4
- name: Check access permissions
id: check_access
uses: actions-cool/check-user-permission@v2
with:
require: write
username: ${{ github.triggering_actor }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Pull build image
run: docker pull ${{ matrix.variance.image }}
- name: Record host UID/GID
run: |
echo "HOST_UID=$(id -u)" >> $GITHUB_ENV
echo "HOST_GID=$(id -g)" >> $GITHUB_ENV
- name: Set container name
run: echo "CONTAINER_NAME=ci-build-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.variance.runner }}" >> $GITHUB_ENV
- name: Start build container
run: |
docker create --name "$CONTAINER_NAME" \
-v "$PWD":/workspace \
-w /workspace \
-e RUST_LOG \
-e RUST_BACKTRACE \
${{ matrix.variance.image }} \
sleep infinity
docker start "$CONTAINER_NAME"
- name: Verify CUDA, Rust installation
run: |
docker exec "$CONTAINER_NAME" bash -lc 'set -euo pipefail
nvcc --version
rustup show
'
- name: Rustfmt
run: |
docker exec "$CONTAINER_NAME" bash -lc 'set -euo pipefail
cargo fmt --all -- --check
'
- name: Build all bindings
run: |
docker exec "$CONTAINER_NAME" bash -lc 'set -euo pipefail
cargo build --all-features -p cust_raw
'
- name: Build workspace
run: |
docker exec "$CONTAINER_NAME" bash -lc 'set -euo pipefail
cargo build
'
- name: Clippy
run: |
docker exec "$CONTAINER_NAME" bash -lc 'set -euo pipefail
export RUSTFLAGS=-Dwarnings
cargo clippy
'
# Exclude crates with tests that require an NVIDIA GPU: blastoff, cudnn, cust.
- name: Test
run: |
docker exec "$CONTAINER_NAME" bash -lc 'set -euo pipefail
export RUSTFLAGS=-Dwarnings
cargo test --workspace \
--exclude blastoff \
--exclude cudnn \
--exclude cust
'
# Exclude cust_raw because it triggers hundreds of warnings.
- name: Check documentation
run: |
docker exec "$CONTAINER_NAME" bash -lc 'set -euo pipefail
export RUSTDOCFLAGS=-Dwarnings
cargo doc --workspace --all-features --document-private-items --no-deps \
--exclude cust_raw
'
- name: Normalize build artifacts ownership
run: |
docker exec "$CONTAINER_NAME" bash -lc "rm -rf /workspace/target/debug/incremental || true"
docker exec "$CONTAINER_NAME" bash -lc "chown -R ${HOST_UID}:${HOST_GID} /workspace/target || true"
- name: Stop build container
run: |
docker rm -f "$CONTAINER_NAME" || true
- name: Prepare artifact details
id: artifact_details
run: |
SANITIZED_NAME=$(echo '${{ matrix.variance.name }}' | sed 's/[^a-zA-Z0-9.-]/-/g')
ARTIFACT_NAME="target_debug-${SANITIZED_NAME}-${{ github.run_id }}"
ARTIFACT_PATH="target/debug"
echo "name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
echo "path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact_details.outputs.name }}
path: ${{ steps.artifact_details.outputs.path }}
retention-days: 1
test:
name: Test / ${{ matrix.variance.name }}
# Depends on the build job
needs: build
# Run ONLY IF:
# - The corresponding 'build' job succeeded AND
# - EITHER:
# - Event is 'push' to 'main'
# - OR Event is 'workflow_dispatch'
# - OR Event is 'pull_request' AND the 'actor_has_write_permission' output from build is 'true'
if: >
needs.build.result == 'success' &&
(
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && needs.build.outputs.actor_has_write_permission == 'true')
)
runs-on: ${{ matrix.variance.runner }}
# Use the exact same container image as the build job
container:
image: ${{ matrix.variance.image }}
strategy:
# Save some credits
fail-fast: true
matrix:
variance:
# Must match the build job's matrix definition
- name: Ubuntu-24.04 / CUDA-12.8.1 / x86_64
image: "ghcr.io/rust-gpu/rust-cuda-ubuntu24-cuda12:latest"
runner: ubuntu-latest
- name: Ubuntu-24.04 / CUDA-12.8.1 / ARM64
image: "ghcr.io/rust-gpu/rust-cuda-ubuntu24-cuda12:latest"
runner: ubuntu-24.04-arm
steps:
- name: Compute artifact name
id: test_artifact
run: |
SANITIZED_NAME=$(echo '${{ matrix.variance.name }}' | sed 's/[^a-zA-Z0-9.-]/-/g')
ARTIFACT_NAME="target_debug-${SANITIZED_NAME}-${{ github.run_id }}"
ARTIFACT_PATH="target/debug"
echo "name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
echo "path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: ${{ steps.test_artifact.outputs.name }}
path: ${{ steps.test_artifact.outputs.path }}
- name: List downloaded files
run: ls -lR ${{ steps.test_artifact.outputs.path }}
- name: Run remote tests
env:
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
run: |
echo "Stubbed out"
compiletest:
name: Compile tests
runs-on: ubuntu-latest
container:
image: "ghcr.io/rust-gpu/rust-cuda-ubuntu24-cuda12:latest"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run cargo version
run: cargo --version
- name: Rustfmt compiletests
shell: bash
# Uses rustfmt directly, rather than via `cargo fmt`, because the compiletests .rs files
# are not within a package.
run: shopt -s globstar && rustfmt --check tests/compiletests/ui/**/*.rs
- name: Compiletest
run: cargo run -p compiletests --release --no-default-features -- --target-arch compute_61,compute_75,compute_90