diff --git a/.github/workflows/d3d12-rust.yml b/.github/workflows/d3d12-rust.yml new file mode 100644 index 0000000000..0d31137281 --- /dev/null +++ b/.github/workflows/d3d12-rust.yml @@ -0,0 +1,75 @@ +# Builds and tests the d3d12 workspace (Rust) when it changes, so a change that does not pass its +# tests shows up in CI. It needs no GPU, no display and no game files. +# +# Two checks that are deliberately not here, and why: +# +# cargo fmt --all -- --check d3d12/ has a rustfmt.toml and does not follow it: running +# `cargo fmt --all` rewrites 190 files. That is its own change, +# and not one to smuggle into a CI pull request. +# cargo clippy ... -D warnings 115 warnings and no errors across the workspace; holding them at +# -D warnings is also its own change. +# +# When either lands, its step belongs next to the tests below. +name: D3D12 Rust + +on: + push: + branches: [main] + paths: + - "d3d12/**" + - ".github/workflows/d3d12-rust.yml" + pull_request: + paths: + - "d3d12/**" + - ".github/workflows/d3d12-rust.yml" + workflow_dispatch: + +concurrency: + group: d3d12-rust-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + test: + name: d3d12-rust + # Windows: the workspace's GPU crate talks to D3D12 and Vulkan through Windows APIs, and the + # gate scripts its tests drive are PowerShell. + runs-on: windows-latest + timeout-minutes: 40 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Install Rust + # The channel `d3d12/rust-toolchain.toml` pins. `@stable` installs whatever the runner calls + # latest, and then `cargo` run from `d3d12/` has rustup fetch the pinned one on the fly: the + # same result with a download nobody asked for. If that file bumps, this line follows it. + uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 # v1 + with: + toolchain: 1.98.1 + - name: Cache Cargo dependencies and build + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + d3d12/target + key: d3d12-cargo-${{ runner.os }}-${{ hashFiles('d3d12/Cargo.lock') }} + restore-keys: | + d3d12-cargo-${{ runner.os }}- + - name: Tests + working-directory: d3d12 + # The asset-policy test reads the whole tree and is the reason this job exists: it is green + # once policy no longer measures a Rust source file as data (#2815). + run: cargo test --workspace --locked --exclude leonida-gpu + - name: Tests (leonida-gpu, one thread) + working-directory: d3d12 + # Runs even if the step above failed: one red should not hide the other. This crate's tests + # interfere with each other when they share a process: sixteen runs with the default threads + # failed twice and eight with --test-threads=1 failed none (#2570). It costs 37 seconds + # instead of 13, and it is the difference between a red that means something and a red one + # run in eight that nobody can attribute. + if: always() + run: cargo test -p leonida-gpu --lib --locked -- --test-threads=1