Skip to content

Commit 81aa642

Browse files
authored
Scaffolding for running tests in CI (#199)
1 parent b0a4b7d commit 81aa642

File tree

2 files changed

+107
-7
lines changed

2 files changed

+107
-7
lines changed

.github/workflows/ci_linux.yml

+106-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
name: CI on Linux
22

33
on:
4+
# Trigger builds on pull requests
45
pull_request:
56
paths-ignore:
67
- "**.md"
8+
9+
# Trigger builds AND tests on push to main
710
push:
11+
branches:
12+
- main
813
paths-ignore:
914
- "**.md"
15+
16+
# Add manual trigger via Actions UI for running BOTH build and test
17+
workflow_dispatch:
18+
1019
env:
1120
RUST_LOG: info
1221
RUST_BACKTRACE: 1
22+
1323
jobs:
1424
build:
15-
name: ${{ matrix.variance.name }}
25+
name: Build / ${{ matrix.variance.name }}
1626
runs-on: ubuntu-latest
1727
container:
1828
image: ${{ matrix.variance.image }}
@@ -22,34 +32,124 @@ jobs:
2232
variance:
2333
# - name: Ubuntu-22.04/CUDA-11.8.0
2434
# image: "ghcr.io/rust-gpu/rust-cuda-ubuntu22-cuda11:latest"
25-
- name: Ubuntu-22.04/CUDA-12.8.1
35+
- name: Ubuntu-22.04 / CUDA-12.8.1
2636
image: "ghcr.io/rust-gpu/rust-cuda-ubuntu22-cuda12:latest"
27-
- name: Ubuntu-24.04/CUDA-12.8.1
37+
- name: Ubuntu-24.04 / CUDA-12.8.1
2838
image: "ghcr.io/rust-gpu/rust-cuda-ubuntu24-cuda12:latest"
29-
- name: RockyLinux-9/CUDA-12.8.1
39+
- name: RockyLinux-9 / CUDA-12.8.1
3040
image: "ghcr.io/rust-gpu/rust-cuda-rockylinux9-cuda12:latest"
41+
outputs:
42+
# Output the result of the permission check
43+
actor_has_write_permission: ${{ steps.check_access.outputs.require-result }}
44+
# Output the build artifact details so the test job can use them
45+
artifact_name: ${{ steps.artifact_details.outputs.name }}
46+
artifact_path: ${{ steps.artifact_details.outputs.path }}
47+
3148
steps:
3249
- name: Checkout repository
3350
uses: actions/checkout@v4
51+
52+
- name: Check access permissions
53+
id: check_access
54+
uses: actions-cool/check-user-permission@v2
55+
with:
56+
require: write
57+
username: ${{ github.triggering_actor }}
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
3461
- name: Verify CUDA, Rust installation
3562
run: |
3663
nvcc --version
3764
rustup show
3865
- name: Load Rust cache
3966
uses: Swatinem/rust-cache@v2
4067
with:
41-
key: ${{ matrix.variance.name }}
68+
key: ${{ matrix.variance.name }}-${{ github.sha }}
69+
4270
- name: Rustfmt
4371
run: cargo fmt --all -- --check
72+
4473
- name: Clippy
4574
env:
4675
RUSTFLAGS: -Dwarnings
4776
run: cargo clippy --workspace --exclude "optix*" --exclude "path_tracer" --exclude "denoiser" --exclude "ex*" --exclude "cudnn*"
77+
4878
- name: Build all bindings
4979
run: cargo build --all-features -p cust_raw
50-
- name: Build
80+
81+
- name: Build workspace
5182
run: cargo build --workspace --exclude "optix*" --exclude "path_tracer" --exclude "denoiser" --exclude "ex*" --exclude "cudnn*"
83+
5284
- name: Check documentation
5385
env:
5486
RUSTDOCFLAGS: -Dwarnings
5587
run: cargo doc --workspace --all-features --document-private-items --no-deps --exclude "optix*" --exclude "path_tracer" --exclude "denoiser" --exclude "ex*" --exclude "cudnn*" --exclude "cust_raw"
88+
89+
- name: Prepare artifact details
90+
id: artifact_details
91+
run: |
92+
SANITIZED_NAME=$(echo '${{ matrix.variance.name }}' | sed 's/[^a-zA-Z0-9.-]/-/g')
93+
ARTIFACT_NAME="target_debug-${SANITIZED_NAME}-${{ github.run_id }}"
94+
ARTIFACT_PATH="target/debug"
95+
echo "name=${ARTIFACT_NAME}" >> $GITHUB_OUTPUT
96+
echo "path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT
97+
98+
- name: Upload build artifacts
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: ${{ steps.artifact_details.outputs.name }}
102+
path: ${{ steps.artifact_details.outputs.path }}
103+
retention-days: 1
104+
105+
test:
106+
name: Test / ${{ matrix.variance.name }}
107+
# Depends on the build job
108+
needs: build
109+
# Run ONLY IF:
110+
# - The corresponding 'build' job succeeded AND
111+
# - EITHER:
112+
# - Event is 'push' to 'main'
113+
# - OR Event is 'workflow_dispatch'
114+
# - OR Event is 'pull_request' AND the 'actor_has_write_permission' output from build is 'true'
115+
if: >
116+
needs.build.result == 'success' &&
117+
(
118+
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
119+
github.event_name == 'workflow_dispatch' ||
120+
(github.event_name == 'pull_request' && needs.build.outputs.actor_has_write_permission == 'true')
121+
)
122+
runs-on: ubuntu-latest
123+
# Use the exact same container image as the build job
124+
container:
125+
image: ${{ matrix.variance.image }}
126+
strategy:
127+
# Save some credits
128+
fail-fast: true
129+
matrix:
130+
variance:
131+
# Must match the build job's matrix definition
132+
# - name: Ubuntu-22.04 / CUDA-11.8.0 image:
133+
# "ghcr.io/rust-gpu/rust-cuda-ubuntu22-cuda11:latest"
134+
- name: Ubuntu-22.04 / CUDA-12.8.1
135+
image: "ghcr.io/rust-gpu/rust-cuda-ubuntu22-cuda12:latest"
136+
- name: Ubuntu-24.04 / CUDA-12.8.1
137+
image: "ghcr.io/rust-gpu/rust-cuda-ubuntu24-cuda12:latest"
138+
- name: RockyLinux-9 / CUDA-12.8.1
139+
image: "ghcr.io/rust-gpu/rust-cuda-rockylinux9-cuda12:latest"
140+
steps:
141+
- name: Download build artifacts
142+
uses: actions/download-artifact@v4
143+
with:
144+
name: ${{ needs.build.outputs.artifact_name }}
145+
path: ${{ needs.build.outputs.artifact_path }}
146+
147+
- name: List downloaded files
148+
run: ls -lR ${{ needs.build.outputs.artifact_path }}
149+
150+
- name: Run remote tests
151+
env:
152+
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
153+
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
154+
run: |
155+
echo "Stubbed out"

.github/workflows/ci_windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414

1515
jobs:
1616
rust:
17-
name: ${{ matrix.os }}/CUDA-${{ matrix.cuda }}
17+
name: Build / ${{ matrix.os }} / CUDA-${{ matrix.cuda }}
1818
runs-on: ${{ matrix.os }}
1919
env:
2020
LLVM_LINK_STATIC: 1

0 commit comments

Comments
 (0)