11name : CI on Linux
22
33on :
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+
1019env :
1120 RUST_LOG : info
1221 RUST_BACKTRACE : 1
22+
1323jobs :
1424 build :
1525 name : ${{ matrix.variance.name }}
@@ -28,28 +38,103 @@ jobs:
2838 image : " ghcr.io/rust-gpu/rust-cuda-ubuntu24-cuda12:latest"
2939 - name : RockyLinux-9/CUDA-12.8.1
3040 image : " ghcr.io/rust-gpu/rust-cuda-rockylinux9-cuda12:latest"
41+
3142 steps :
3243 - name : Checkout repository
3344 uses : actions/checkout@v4
45+
3446 - name : Verify CUDA, Rust installation
3547 run : |
3648 nvcc --version
3749 rustup show
3850 - name : Load Rust cache
3951 uses : Swatinem/rust-cache@v2
4052 with :
41- key : ${{ matrix.variance.name }}
53+ # Use the specific commit SHA for the most accurate build cache key
54+ key : ${{ matrix.variance.name }}-${{ github.sha }}
55+
4256 - name : Rustfmt
4357 run : cargo fmt --all -- --check
58+
4459 - name : Clippy
4560 env :
4661 RUSTFLAGS : -Dwarnings
4762 run : cargo clippy --workspace --exclude "optix*" --exclude "path_tracer" --exclude "denoiser" --exclude "ex*" --exclude "cudnn*"
63+
4864 - name : Build all bindings
4965 run : cargo build --all-features -p cust_raw
50- - name : Build
66+
67+ - name : Build workspace
5168 run : cargo build --workspace --exclude "optix*" --exclude "path_tracer" --exclude "denoiser" --exclude "ex*" --exclude "cudnn*"
69+
5270 - name : Check documentation
5371 env :
5472 RUSTDOCFLAGS : -Dwarnings
5573 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"
74+
75+ - name : Upload build artifacts
76+ uses : actions/upload-artifact@v4
77+ with :
78+ # Use github.run_id for a unique name per workflow run
79+ name : target_debug-${{ matrix.variance.name }}-${{ github.run_id }}
80+ path : |
81+ target/debug
82+ retention-days : 1
83+
84+ test-remote :
85+ name : Test ${{ matrix.variance.name }}
86+ # This job depends on the build job completing successfully for the same matrix entry
87+ needs : build
88+ # Run this job ONLY IF:
89+ # - The build job succeeded ('needs.build.result == 'success'')
90+ # - AND EITHER:
91+ # - The event was a push to the 'main' branch
92+ # - OR The event was a manual trigger
93+ # - OR The event was a pull_request AND the author is an OWNER or MEMBER of the repo
94+ if : >
95+ always() && needs.build.result == 'success' &&
96+ (
97+ (github.event_name == 'push' && github.ref == 'refs/heads/main') ||
98+ github.event_name == 'workflow_dispatch' ||
99+ (
100+ github.event_name == 'pull_request' &&
101+ contains(fromJson('["OWNER","MEMBER"]'), github.event.pull_request.author_association)
102+ )
103+ )
104+ runs-on : ubuntu-latest
105+ # Use the exact same container image as the build job
106+ container :
107+ image : ${{ matrix.variance.image }}
108+ # Define the same strategy matrix to run tests for each build environment
109+ strategy :
110+ fail-fast : false # Usually good to see all test results
111+ matrix :
112+ variance :
113+ # Must match the build job's matrix definition
114+ # - name: Ubuntu-22.04/CUDA-11.8.0
115+ # image: "ghcr.io/rust-gpu/rust-cuda-ubuntu22-cuda11:latest"
116+ - name : Ubuntu-22.04/CUDA-12.8.1
117+ image : " ghcr.io/rust-gpu/rust-cuda-ubuntu22-cuda12:latest"
118+ - name : Ubuntu-24.04/CUDA-12.8.1
119+ image : " ghcr.io/rust-gpu/rust-cuda-ubuntu24-cuda12:latest"
120+ - name : RockyLinux-9/CUDA-12.8.1
121+ image : " ghcr.io/rust-gpu/rust-cuda-rockylinux9-cuda12:latest"
122+ steps :
123+ - name : Download build artifacts
124+ uses : actions/download-artifact@v4
125+ with :
126+ # Match the unique artifact name from the build job using the workflow run_id
127+ name : target_debug-${{ matrix.variance.name }}-${{ github.run_id }}
128+ path : target/debug
129+
130+ - name : List downloaded files
131+ run : ls -lR target/debug
132+
133+ - name : Run remote tests
134+ env :
135+ # Inject the id and secret ONLY in this job, which is conditionally run
136+ MODAL_TOKEN_ID : ${{ secrets.MODAL_TOKEN_ID }}
137+ MODAL_TOKEN_SECRET : ${{ secrets.MODAL_TOKEN_SECRET }}
138+ # Add any other env vars needed for testing
139+ run : |
140+ echo "Stubbed out"
0 commit comments