Files
mandy/.github/workflows/d3d12.yml

87 lines
3.9 KiB
YAML

# Builds and tests the D3D12 runtime (d3d12/, Rust: leonida.exe and its crates) when it changes. Until now no workflow
# ran its tests, so a change that broke one of them reached main unseen. It needs no GPU and no game files: the tests
# that need a device or the title skip themselves.
#
# Measured on main 060c47160 (Windows 11, toolchain from d3d12/rust-toolchain.toml): the workspace builds in about
# 4 minutes and its tests take about 11; 1441 pass, 58 are ignored, and one fails, the xtask asset-policy test, because
# two sources are over its 640 KiB limit (crates/leonida-gpu/src/host.rs, crates/leonida-shader/src/emit/lower.rs).
# `cargo clippy -D warnings` also fails on main (about 25 findings in five crates) and `cargo fmt --check` would
# reformat most of the tree. So the tests are the gate; the policy test and clippy run as reports until those are fixed,
# and formatting is left out so it does not collide with the open d3d12 pull requests.
name: D3D12 runtime
on:
push:
branches: [main]
paths:
- "d3d12/**"
# leonida-lua's tests read mods/example_lua.
- "mods/**"
- ".github/workflows/d3d12.yml"
pull_request:
paths:
- "d3d12/**"
# leonida-lua's tests read mods/example_lua.
- "mods/**"
- ".github/workflows/d3d12.yml"
workflow_dispatch:
permissions:
contents: read
concurrency:
# Each non-PR run has its own group so a queued push or dispatch cannot replace it.
group: d3d12-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
d3d12:
name: d3d12 (windows-latest)
# The crates are Windows-only today (leonida-gpu does not build on macOS); Linux follows #2577 if it lands.
runs-on: windows-latest
timeout-minutes: 70
defaults:
run:
working-directory: d3d12
shell: bash
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# The runner's own rustup installs the toolchain pinned in d3d12/rust-toolchain.toml, no third-party action.
- name: Rust toolchain
run: |
rustup show active-toolchain || rustup toolchain install
rustc --version
echo "RUSTC_HASH=$(rustc -vV | tr -d '\r' | awk '/^commit-hash: /{print $2}')" >> "$GITHUB_ENV"
- name: Cache Cargo downloads
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry
~/.cargo/git
key: d3d12-windows-cargo-${{ env.RUSTC_HASH }}-${{ hashFiles('d3d12/Cargo.lock') }}
restore-keys: |
d3d12-windows-cargo-${{ env.RUSTC_HASH }}-
d3d12-windows-cargo-
- name: Build
run: cargo build --workspace --all-targets --locked
# The features of the executable people run (d3d12/scripts/build-nvidia.ps1, without dlss); no other step builds them.
- name: Build as shipped (diagnostics, mimalloc)
run: cargo build -p leonida --features diagnostics,mimalloc --locked
- name: Tests (no GPU, no game data)
timeout-minutes: 30
run: cargo test --workspace --exclude xtask --locked
# tests/replay.rs is compiled only with the diagnostics feature.
- name: Replay test (diagnostics)
timeout-minutes: 15
run: cargo test -p leonida-gpu --features diagnostics --test replay --locked
# Report only until host.rs and lower.rs are split under the limit; make it blocking then.
- name: Asset policy (report)
continue-on-error: true
run: cargo test -p xtask --locked
# Report only until the existing findings are fixed; make it blocking (-D warnings) then.
- name: Clippy (report)
continue-on-error: true
run: cargo clippy --workspace --all-targets --locked -- -D warnings