|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: [pull_request, push] |
| 4 | + |
| 5 | +# Cancel a job if there's a new on on the same branch started. |
| 6 | +# Based on https://stackoverflow.com/questions/58895283/stop-already-running-workflow-job-in-github-actions/67223051#67223051 |
| 7 | +concurrency: |
| 8 | + group: ${{ github.ref }} |
| 9 | + cancel-in-progress: true |
| 10 | + |
| 11 | +env: |
| 12 | + CARGO_INCREMENTAL: 0 |
| 13 | + RUST_BACKTRACE: 1 |
| 14 | + # Faster crates.io index checkout. |
| 15 | + CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse |
| 16 | + |
| 17 | +jobs: |
| 18 | + set-msrv: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + msrv: ${{ steps.msrv.outputs.MSRV }} |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + - name: Get MSRV from rust-toolchain |
| 25 | + id: msrv |
| 26 | + run: | |
| 27 | + MSRV=$(cat ./rust-toolchain) |
| 28 | + echo "MSRV=$MSRV" | tee --append "$GITHUB_OUTPUT" |
| 29 | +
|
| 30 | + linux: |
| 31 | + needs: set-msrv |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + - uses: dtolnay/rust-toolchain@master |
| 36 | + with: |
| 37 | + toolchain: ${{needs.set-msrv.outputs.msrv}} |
| 38 | + - name: Install required packages |
| 39 | + run: sudo apt install --no-install-recommends --yes ocl-icd-opencl-dev nvidia-cuda-toolkit |
| 40 | + - name: Build with default features |
| 41 | + run: cargo build --workspace |
| 42 | + # Machine has no GPU installed, hence run without the `cuda` or `opencl` feature. |
| 43 | + - name: Run tests without default features |
| 44 | + run: cargo test --workspace --no-default-features -- --nocapture |
| 45 | + |
| 46 | + clippy_check: |
| 47 | + needs: set-msrv |
| 48 | + runs-on: ubuntu-latest |
| 49 | + name: Clippy |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + - uses: dtolnay/rust-toolchain@master |
| 53 | + with: |
| 54 | + toolchain: ${{ needs.set-msrv.outputs.msrv }} |
| 55 | + components: clippy |
| 56 | + - name: Install required packages |
| 57 | + run: sudo apt install --no-install-recommends --yes ocl-icd-opencl-dev nvidia-cuda-dev |
| 58 | + - name: Run cargo clippy default features |
| 59 | + run: cargo clippy --workspace --all-targets -- -D warnings |
| 60 | + - name: Run cargo clippy with cuda and opencl features |
| 61 | + run: cargo clippy --workspace --all-targets --features cuda,opencl -- -D warnings |
| 62 | + - name: Run cargo clippy with cuda feature |
| 63 | + run: cargo clippy --workspace --all-targets --no-default-features --features cuda -- -D warnings |
| 64 | + - name: Run cargo clippy with opencl feature |
| 65 | + run: cargo clippy --workspace --all-targets --no-default-features --features opencl -- -D warnings |
| 66 | + |
| 67 | + check_fmt_and_docs: |
| 68 | + needs: set-msrv |
| 69 | + runs-on: ubuntu-latest |
| 70 | + name: Checking fmt and docs |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@v4 |
| 73 | + - uses: dtolnay/rust-toolchain@master |
| 74 | + with: |
| 75 | + toolchain: ${{ needs.set-msrv.outputs.msrv }} |
| 76 | + components: rustfmt |
| 77 | + - name: fmt |
| 78 | + run: cargo fmt --all -- --check |
| 79 | + - name: Docs |
| 80 | + env: |
| 81 | + # Making sure that the documentation can be built without having the NVIDIA toolkit |
| 82 | + # installed. |
| 83 | + DOCS_RS: true |
| 84 | + run: | |
| 85 | + cargo rustdoc --package ec-gpu --all-features -- -D warnings |
| 86 | + cargo rustdoc --package ec-gpu-gen --all-features -- -D warnings |
0 commit comments