name: CI on: pull_request: # Runs on `trunk` to save the build caches that pull requests read # and to upload the coverage baseline. schedule: - cron: "0 6 * * *" workflow_dispatch: env: # # Keep in sync with cts.yml # # # Dependency versioning # # This is the MSRV used by all repository infrastructure. REPO_MSRV: "1.96.1" # This is the MSRV used by `wgpu` itself. WGPU_MSRV: "1.87" # This is the MSRV used by the `wgpu-core`, `wgpu-hal`, `wgpu-sync`, and `wgpu-types` crates, # to ensure that they can be used with firefox. CORE_MSRV: "1.87" # # Build and test configuration # CARGO_INCREMENTAL: false CARGO_TERM_COLOR: always RUST_LOG: debug,wasm_bindgen_wasm_interpreter=warn,wasm_bindgen_cli_support=warn,walrus=warn,naga=info RUST_BACKTRACE: full PKG_CONFIG_ALLOW_CROSS: 1 # allow android to work RUSTFLAGS: -D warnings --cfg wgpu_validate_locks_debug RUSTDOCFLAGS: -D warnings WASM_BINDGEN_TEST_TIMEOUT: 300 # 5 minutes CACHE_SUFFIX: e # cache busting WGPU_CI: true # # Runtime configuration # LVP_POISON_MEMORY: true # to test memory init; see docs/testing.md WGPU_DX12_COMPILER: dxc # Every time a PR is pushed to, cancel any previous jobs. This # makes us behave nicer to github and get faster turnaround times # on PRs that are pushed to multiple times in rapid succession. concurrency: group: ${{github.workflow}}-${{github.ref}} cancel-in-progress: ${{github.event_name == 'pull_request'}} # We distinguish the following kinds of builds: # - native: build for the same target as we compile on # - web: build for the Web # - em: build for the Emscripten # For build time and size optimization we disable debug symbols # entirely on clippy jobs and reduce it to line-numbers # only for ones where we run tests. # # Additionally, we disable incremental builds entirely # as our caching system doesn't actually cache our crates. # It adds overhead to the build and another point of failure. jobs: check: # runtime is normally 2-8 minutes # # currently high due to documentation time problems on mac. # https://github.com/rust-lang/rust/issues/114891 timeout-minutes: 30 strategy: fail-fast: false matrix: include: # Windows - name: Windows x86_64 os: windows-2025 target: x86_64-pc-windows-msvc tier: 1 kind: native # Windows - name: Windows aarch64 os: windows-2025 target: aarch64-pc-windows-msvc tier: 2 kind: native # MacOS - name: MacOS x86_64 os: macos-26 target: x86_64-apple-darwin tier: 1 kind: native - name: MacOS aarch64 os: macos-26 target: aarch64-apple-darwin tier: 1 kind: native # IOS - name: IOS aarch64 os: macos-26 target: aarch64-apple-ios tier: 2 kind: native # VisionOS - name: VisionOS aarch64 os: macos-26 target: aarch64-apple-visionos kind: wgpu-only tier: 3 extra-flags: -Zbuild-std # Linux - name: Linux x86_64 os: ubuntu-24.04 target: x86_64-unknown-linux-gnu tier: 1 kind: native - name: Linux aarch64 os: ubuntu-24.04 target: aarch64-unknown-linux-gnu tier: 1 kind: native # FreeBSD - name: FreeBSD x86_64 os: ubuntu-24.04 target: x86_64-unknown-freebsd tier: 2 kind: wgpu-only # NetBSD - name: NetBSD x86_64 os: ubuntu-24.04 target: x86_64-unknown-netbsd tier: 2 kind: wgpu-only # Android - name: Android aarch64 os: ubuntu-24.04 target: aarch64-linux-android tier: 2 kind: native # Android - name: Android ARMv7 os: ubuntu-24.04 target: armv7-linux-androideabi tier: 2 kind: wgpu-only # Android - name: Android x86_64 os: ubuntu-24.04 target: x86_64-linux-android tier: 2 kind: wgpu-only # OpenHarmony - name: OpenHarmony aarch64 os: ubuntu-24.04 target: aarch64-unknown-linux-ohos tier: 2 kind: native # WebGPU/WebGL - name: WebAssembly os: ubuntu-24.04 target: wasm32-unknown-unknown tier: 2 kind: web - name: WebAssembly 64-bit os: ubuntu-24.04 target: wasm64-unknown-unknown kind: wgpu-only tier: 3 extra-flags: -Zbuild-std=std,panic_abort - name: Emscripten os: ubuntu-24.04 target: wasm32-unknown-emscripten tier: 2 kind: wgpu-only - name: WebAssembly Core 1.0 os: ubuntu-24.04 target: wasm32v1-none tier: 2 kind: no_std # 32-bit PowerPC Linux # Included to test support for `portable-atomic` - name: Linux ppc32 os: ubuntu-24.04 target: powerpc-unknown-linux-gnu tier: 2 kind: wgpu-only name: Clippy ${{ matrix.name }} runs-on: ${{ matrix.os }} permissions: {} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Checkout repo uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Install toolchain (repo MSRV - tier 1 or 2) if: matrix.tier == 1 || matrix.tier == 2 run: | rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component clippy rustup target add ${{ matrix.target }} --toolchain ${{ env.REPO_MSRV }} rustup override set ${{ env.REPO_MSRV }} cargo -V # In order to build on platforms that require a nightly toolchain, we install stable as expected, # add the rust-src component, then tell stable to consider itself nightly by setting RUSTC_BOOTSTRAP=1. # # This is not formally "correct" thing to do, but it saves significant maintainer burden. If we were to # use a proper nightly toolchain we would have to manually find a date that works. Even with a date that is # carefully coordinated with the version of stable we are using, there are often mismatches of clippy lints # between nightly and stable. This is a real mess. By using RUSTC_BOOTSTRAP=1, we get access to all the nice # nightly features without needing to go through the hassle of maintaining a nightly toolchain. # # RUSTC_BOOTSTRAP=1 is how the rust project builds itself when bootstrapping the compiler, so while not "stable" # it has been around for many years and don't anticipate it going away any time soon. - name: Install toolchain (repo MSRV - tier 3) if: matrix.tier == 3 run: | rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component clippy,rust-src echo "RUSTC_BOOTSTRAP=1" >> "$GITHUB_ENV" - name: Disable debug symbols shell: bash run: | mkdir -p .cargo cat <> .cargo/config.toml [profile.dev] debug = false EOF - name: Caching uses: step-security/rust-cache@v2.9.2 with: key: clippy-${{ matrix.target }}-${{ matrix.kind }}-${{ env.CACHE_SUFFIX }} env-vars: ImageVersion save-if: ${{ github.ref == 'refs/heads/trunk' }} - name: (Linux `aarch64`) Install `aarch64-linux-gnu` `g++` if: matrix.target == 'aarch64-unknown-linux-gnu' run: | set -e sudo apt-get update -y -qq sudo apt-get install g++-aarch64-linux-gnu - name: (Android) Add Android APK to `PATH` if: matrix.target == 'aarch64-linux-android' run: | # clang++ will be detected correctly by CC from path echo "$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH # the android sdk doesn't use the conventional name for ar, so explicitly set it. echo "AR_aarch64_linux_android=llvm-ar" >> "$GITHUB_ENV" # Building for wasm32 requires a series of specific tests for the WebGPU backend. - name: Check web if: matrix.kind == 'web' shell: bash run: | set -e # build for WebGPU cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --tests --features glsl,spirv,fragile-send-sync-non-atomic-wasm cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --tests --features glsl,spirv cargo --locked doc --target ${{ matrix.target }} ${{ matrix.extra-flags }} --no-deps --features glsl,spirv # check with only the web feature cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --no-default-features --features=web # all features cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --tests --all-features cargo --locked doc --target ${{ matrix.target }} ${{ matrix.extra-flags }} --no-deps --all-features # Building for platforms where the tests do not compile. - name: Check `wgpu` only if: matrix.kind == 'wgpu-only' shell: bash run: | set -e # check with no features cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu -p wgpu-hal --no-default-features # Don't check samples since we use winit in our samples which has dropped support for Emscripten. # Check with all features. cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-hal --all-features cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu --all-features # Building for no_std platforms. - name: Check `no_std` if: matrix.kind == 'no_std' shell: bash run: | set -e # check with no features cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-types --no-default-features cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p naga-types --no-default-features cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-sync --no-default-features cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p naga --no-default-features cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-hal --no-default-features cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-core --no-default-features cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu --no-default-features # Check with all compatible features cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-types --no-default-features --features strict_asserts,fragile-send-sync-non-atomic-wasm,serde,counters cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p naga-types --no-default-features --features serialize,deserialize cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-sync --no-default-features cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p naga --no-default-features --features dot-out,spv-in,spv-out,glsl-out,msl-out,serialize,deserialize,wgsl-in,wgsl-out,hlsl-out cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-hal --no-default-features --features fragile-send-sync-non-atomic-wasm cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-core --no-default-features --features api_log_info,resource_log_info,strict_asserts,serde,wgsl,spirv,counters,noop cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu --no-default-features --features webgpu,drm,wgsl,strict_asserts,serde,counters # Building for native platforms with standard tests. - name: Check native if: matrix.kind == 'native' shell: bash run: | set -e # check with no features cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --no-default-features # Check with all features. cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --tests --benches --all-features # Check with all features and profiling macro code. # If we don't check this then errors inside `profiling::scope!()` will not be caught. cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --tests --benches --all-features --features test-build-with-profiling # Check wgpu-hal with main backends in isolation to catch missing feature/dependencies activations which may be overlooked when they are dragged in via other features. # (best effort: in theory we'd need to test all combinations) cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-hal --no-default-features --features vulkan cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-hal --no-default-features --features gles cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-hal --no-default-features --features metal cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-hal --no-default-features --features dx12 # Check important naga features in isolation for feature in arbitrary glsl-in glsl-out hlsl-out msl-out spv-in spv-out wgsl-in wgsl-out; do cargo --locked clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p naga --no-default-features --features $feature done # build docs cargo --locked doc --target ${{ matrix.target }} ${{ matrix.extra-flags }} --all-features --no-deps - name: Check private item docs if: matrix.kind == 'native' shell: bash run: | set -e cargo --locked doc --target ${{ matrix.target }} ${{ matrix.extra-flags }} \ --package wgpu-core \ --package wgpu-core-remote \ --package wgpu-core-remote-types \ --package wgpu-hal \ --package naga \ --package wgpu \ --all-features --no-deps --document-private-items # We run minimal checks on the MSRV of the `wgpu` crate, ensuring that # its dependency tree does not cause issues for servo or other users. # # We don't test all platforms, just ones with different dependency stacks. check-wgpu-msrv: # runtime is normally 1-3 minutes timeout-minutes: 10 strategy: fail-fast: false matrix: include: # Windows - name: Windows x86_64 os: windows-2025 target: x86_64-pc-windows-msvc # MacOS - name: MacOS x86_64 os: macos-26 target: x86_64-apple-darwin # Linux - name: Linux x86_64 os: ubuntu-24.04 target: x86_64-unknown-linux-gnu # WebGPU - name: WebAssembly os: ubuntu-24.04 target: wasm32-unknown-unknown name: wgpu MSRV Check ${{ matrix.name }} runs-on: ${{ matrix.os }} permissions: {} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Checkout repo uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Install core MSRV toolchain run: | rustup toolchain install ${{ env.WGPU_MSRV }} --no-self-update --profile=minimal --component clippy --target ${{ matrix.target }} rustup override set ${{ env.WGPU_MSRV }} cargo -V - name: Disable debug symbols shell: bash run: | mkdir -p .cargo cat <> .cargo/config.toml [profile.dev] debug = false EOF - name: Caching uses: step-security/rust-cache@v2.9.2 with: key: wgpu-msrv-check-${{ matrix.target }}-${{ env.CACHE_SUFFIX }} env-vars: ImageVersion save-if: ${{ github.ref == 'refs/heads/trunk' }} - name: Reduce MSRV on dependencies shell: bash run: | set -e # No needed operations currently. # If we find a dependency that needs to be downgraded to achieve # the MSRV, we can do it here with `cargo update -p --precise ` - name: Check native shell: bash run: | set -e # check `wgpu` with all features. cargo check --target ${{ matrix.target }} --all-features -p wgpu # We run minimal checks on the MSRV of the core crates, ensuring that # its dependency tree does not cause issues for firefox. # # We don't test all platforms, just ones with different dependency stacks. check-core-msrv: # runtime is normally 1-3 minutes timeout-minutes: 10 strategy: fail-fast: false matrix: include: # Windows - name: Windows x86_64 os: windows-2025 target: x86_64-pc-windows-msvc # MacOS - name: MacOS x86_64 os: macos-26 target: x86_64-apple-darwin # Linux - name: Linux x86_64 os: ubuntu-24.04 target: x86_64-unknown-linux-gnu name: Core MSRV Check ${{ matrix.name }} runs-on: ${{ matrix.os }} permissions: {} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Checkout repo uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Install core MSRV toolchain run: | rustup toolchain install ${{ env.CORE_MSRV }} --no-self-update --profile=minimal --component clippy --target ${{ matrix.target }} rustup override set ${{ env.CORE_MSRV }} cargo -V - name: Disable debug symbols shell: bash run: | mkdir -p .cargo cat <> .cargo/config.toml [profile.dev] debug = false EOF - name: Caching uses: step-security/rust-cache@v2.9.2 with: key: core-msrv-check-${{ matrix.target }}-${{ env.CACHE_SUFFIX }} env-vars: ImageVersion save-if: ${{ github.ref == 'refs/heads/trunk' }} - name: Reduce MSRV on dependencies shell: bash run: | set -e # No needed operations currently. # If we find a dependency that needs to be downgraded to achieve # the MSRV, we can do it here with `cargo update -p --precise ` - name: Check native shell: bash run: | set -e # check `wgpu-core-remote` and `wgpu-core` all features. This will also get `wgpu-core-remote-types` and `wgpu-hal` and `wgpu-types`. cargo check --target ${{ matrix.target }} --all-features -p wgpu-core -p wgpu-core-remote # Check that the libraries build — but not that there are no warnings or that tests pass - # with `-Zdirect-minimal-versions` which lowers all dependencies from the workspace packages # to non-workspace packages to their minimum allowed version. check-minimal-versions: # runtime is normally 2 minutes timeout-minutes: 10 name: MSRV Minimal Versions runs-on: ubuntu-24.04 env: # Override flags to NOT include `-D warnings`, because warnings may be due to harmless problems in deps. # Also, allow unexpected_cfgs because it is very common and spammy when using old deps. RUSTFLAGS: -A unexpected_cfgs permissions: {} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Checkout repo uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Install toolchain run: | rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal rustup override set ${{ env.REPO_MSRV }} cargo -V - name: Disable debug symbols shell: bash run: | mkdir -p .cargo echo """ [profile.dev] debug = false" >> .cargo/config.toml - name: Set minimal versions shell: bash run: | set -e cargo +${{ env.REPO_MSRV }} update -Zdirect-minimal-versions env: RUSTC_BOOTSTRAP: 1 - name: Run cargo check shell: bash run: | set -e cargo check --all-targets --all-features wasm-test: # runtime is normally 6-8 minutes timeout-minutes: 20 name: Test WebAssembly runs-on: ubuntu-24.04 permissions: {} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Checkout repo uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Install repo MSRV toolchain run: | rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component clippy --target wasm32-unknown-unknown rustup override set ${{ env.REPO_MSRV }} cargo -V - name: Get `wasm-bindgen` version run: | WASM_BINDGEN_VERSION=$(cargo metadata --format-version 1 --all-features | jq '.packages[] | select(.name == "wasm-bindgen") | .version' | tr -d '"') echo $WASM_BINDGEN_VERSION echo "WASM_BINDGEN_VERSION=$WASM_BINDGEN_VERSION" >> "$GITHUB_ENV" - name: Install `wasm-bindgen` run: cargo +stable install wasm-bindgen-cli --version=$WASM_BINDGEN_VERSION - name: Install `cargo-nextest` uses: step-security/taiki-e-install-action@v2.87.32 with: tool: cargo-nextest - name: Execute tests run: | cargo xtask test-wasm gpu-test: # runtime is normally 5-15 minutes timeout-minutes: 30 strategy: fail-fast: false matrix: # Windows runs in the `gpu-test-windows-attempt-*` jobs below. include: # Mac - name: Mac aarch64 os: macos-26 # Linux - name: Linux x86_64 os: ubuntu-24.04 name: Test ${{ matrix.name }} runs-on: ${{ matrix.os }} permissions: {} steps: &gpu-test-steps - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Checkout repo uses: actions/checkout@v7.0.1 with: persist-credentials: false # Windows CI intermittently lands on hosts that stall for a minute or # more at a time, which kills whichever tests happen to be running. # Record the host details and counters from the start of the job. # https://github.com/gfx-rs/wgpu/issues/9248 - name: (Windows) Start host metrics sampler if: matrix.os == 'windows-2025' uses: $/.github/actions/sample-host-metrics with: output-dir: host-metrics abort-on-bad-host: ${{ matrix.attempt == 1 }} - name: Install repo MSRV toolchain run: | rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal -c llvm-tools cargo -V - name: Install `cargo-nextest` and `cargo-llvm-cov` uses: step-security/taiki-e-install-action@v2.87.32 with: tool: cargo-nextest,cargo-llvm-cov - name: Debug symbols to line-tables-only shell: bash run: | mkdir -p .cargo cat <> .cargo/config.toml [profile.dev] debug = "line-tables-only" EOF # Cache step must go before warp and mesa install on windows as they write into the # target directory, and rust-cache will overwrite the entirety of the target directory. - name: Caching uses: step-security/rust-cache@v2.9.2 with: key: test-${{ matrix.os }}-${{ env.CACHE_SUFFIX }} env-vars: ImageVersion save-if: ${{ github.ref == 'refs/heads/trunk' }} workspaces: | . -> target - name: (Windows) Install DXC if: matrix.os == 'windows-2025' uses: $/.github/actions/install-dxc - name: (Windows) Install WARP if: matrix.os == 'windows-2025' uses: $/.github/actions/install-warp with: target-dir: "target/llvm-cov-target/debug" - name: (Windows) Install Agility SDK if: matrix.os == 'windows-2025' uses: $/.github/actions/install-agility-sdk - name: (Windows) Install Mesa if: matrix.os == 'windows-2025' uses: $/.github/actions/install-mesa - name: (Windows) Install Vulkan SDK if: matrix.os == 'windows-2025' uses: $/.github/actions/install-vulkan-sdk - name: (Mac) Install Vulkan SDK if: matrix.os == 'macos-26' uses: $/.github/actions/install-vulkan-sdk - name: (Linux) Install Vulkan SDK if: matrix.os == 'ubuntu-24.04' uses: $/.github/actions/install-vulkan-sdk - name: (Linux) Install Mesa if: matrix.os == 'ubuntu-24.04' uses: $/.github/actions/install-mesa - name: Delete Naga snapshots shell: bash run: | set -e # Delete snapshots so we can ensure there aren't any excess output files. rm -r naga/tests/out # While armed, the sampler judges whether the host is one of the stalling # ones, and on the first attempt kills the build or tests if it is. - name: (Windows) Arm host watchdog if: matrix.os == 'windows-2025' shell: pwsh run: New-Item -ItemType File -Force -Path host-metrics/watchdog-armed | Out-Null - name: Run tests id: tests shell: bash run: | set -e cargo --locked xtask test --llvm-cov - name: (Windows) Disarm host watchdog if: always() && matrix.os == 'windows-2025' shell: pwsh run: Remove-Item -Force -ErrorAction SilentlyContinue -Path host-metrics/watchdog-armed - name: (Windows) Check host id: check-host if: always() && matrix.os == 'windows-2025' shell: pwsh env: TESTS_OUTCOME: ${{ steps.tests.outcome }} RETRY_ALLOWED: ${{ matrix.attempt == 1 }} run: | .github/actions/sample-host-metrics/check-host.ps1 -OutputDir host-metrics ` -TestsOutcome $env:TESTS_OUTCOME -RetryAllowed:($env:RETRY_ALLOWED -eq "true") - name: Check Naga snapshots # git diff doesn't check untracked files, we need to stage those then compare with HEAD. run: git add --intent-to-add -- naga/tests/out && git diff --exit-code HEAD -- naga/tests/out - uses: actions/upload-artifact@v7.0.2 name: Upload comparison images if: always() # We want artifacts even if the tests fail. with: name: comparison-images-${{ matrix.os }}${{ matrix.attempt && format('-attempt-{0}', matrix.attempt) || '' }} path: | **/*-actual.png **/*-difference.png # Per-test timings and the host counter samples outlive the run logs, # which is what we need to chase intermittent timeouts (#9248). - uses: actions/upload-artifact@v7.0.2 name: Upload test timings if: always() # We want timings even if the tests fail. with: name: test-timings-${{ matrix.os }}${{ matrix.attempt && format('-attempt-{0}', matrix.attempt) || '' }} path: | **/nextest/*/junit.xml host-metrics/ if-no-files-found: warn # Print GPU configuration so we can see what features were available during the test. - name: Print GPU configurations if: always() # We want this information even if the tests fail. shell: bash run: | set -e cat .gpuconfig - name: Generate coverage report id: coverage shell: bash continue-on-error: true run: | set -e cargo --locked llvm-cov report --lcov --output-path lcov.info - name: Upload coverage report to Codecov uses: step-security/codecov-action@v7.1.1 # Mergify draft pull requests re-run the tests of already-reported # pull requests, so their coverage is not uploaded. if: steps.coverage.outcome == 'success' && !startsWith(github.head_ref, 'mergify/merge-queue/') with: files: lcov.info token: ${{ secrets.CODECOV_TOKEN }} # Windows runs the same steps as `gpu-test`, but gets a second attempt on a # new host when the first attempt finds that its host is one of the stalling # ones, or when its tests fail only by timing out. # https://github.com/gfx-rs/wgpu/issues/9248 gpu-test-windows-attempt-1: timeout-minutes: 30 strategy: matrix: include: - name: Windows x86_64 os: windows-2025 attempt: 1 # Not substituting the platform to be consistent with the retry jobs. name: Test Windows x86_64 (attempt ${{ matrix.attempt }}) runs-on: ${{ matrix.os }} permissions: {} outputs: retry: ${{ steps.check-host.outputs.retry }} steps: *gpu-test-steps gpu-test-windows-attempt-2: needs: gpu-test-windows-attempt-1 if: ${{ !cancelled() && needs.gpu-test-windows-attempt-1.outputs.retry == 'true' }} timeout-minutes: 30 strategy: matrix: include: - name: Windows x86_64 os: windows-2025 attempt: 2 # Avoid substituting the platform because skipped jobs don't apply substitutions. name: Test Windows x86_64 (retry; attempt ${{ matrix.attempt }}) runs-on: ${{ matrix.os }} permissions: {} steps: *gpu-test-steps # Reports the outcome of the attempts under the name the Windows test job # has always had. gpu-test-windows: needs: [gpu-test-windows-attempt-1, gpu-test-windows-attempt-2] if: always() timeout-minutes: 2 name: Test Windows x86_64 runs-on: ubuntu-24.04 permissions: {} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Check attempts env: FIRST: ${{ needs.gpu-test-windows-attempt-1.result }} RETRY: ${{ needs.gpu-test-windows-attempt-1.outputs.retry }} SECOND: ${{ needs.gpu-test-windows-attempt-2.result }} run: | echo "attempt 1: $FIRST, retry requested: ${RETRY:-false}, attempt 2: $SECOND" if [ "$FIRST" = success ]; then exit 0 fi if [ "$RETRY" = true ] && [ "$SECOND" = success ]; then echo "::notice title=Windows tests passed on retry::Attempt 1 ran on an unsuitable host." exit 0 fi exit 1 doctest: # runtime is normally 2 minutes timeout-minutes: 10 name: Doctest runs-on: ubuntu-24.04 permissions: {} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Checkout repo uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Install repo MSRV toolchain run: | rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component rustfmt rustup override set ${{ env.REPO_MSRV }} cargo -V - name: Caching uses: step-security/rust-cache@v2.9.2 with: key: doctests-${{ env.CACHE_SUFFIX }} env-vars: ImageVersion save-if: ${{ github.ref == 'refs/heads/trunk' }} - name: Run doctests shell: bash run: | set -e cargo --locked test --doc miri: # runtime is normally 2 minutes timeout-minutes: 10 name: Miri (limited scope) runs-on: ubuntu-24.04 permissions: {} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Checkout repo uses: actions/checkout@v7.0.1 with: persist-credentials: false # Miri is *only* available on nightly. - name: Install nightly toolchain run: | rustup toolchain install nightly --no-self-update --profile=minimal --component miri rustup override set nightly cargo -V - name: Caching uses: step-security/rust-cache@v2.9.2 with: key: miri-${{ env.CACHE_SUFFIX }} env-vars: ImageVersion save-if: ${{ github.ref == 'refs/heads/trunk' }} - name: Run Miri on selected tests shell: bash run: | set -e # Note: this is a *smaller* set of tests than `cargo xtask miri` runs; # it is ones that are both important and cheap. # Consider expanding it to include some API tests with the noop backend. cargo miri test --package=wgpu --no-default-features -- write_only fmt: # runtime is normally 15 seconds timeout-minutes: 2 name: Format & Typos runs-on: ubuntu-24.04 permissions: {} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Checkout repo uses: actions/checkout@v7.0.1 with: persist-credentials: false # Only pull requests give a well-defined commit range. The merge queue # runs the commits that this check already saw on the pull request. - name: Check for AI-authored commits if: github.event_name == 'pull_request' uses: $/.github/actions/ai-commit-check - name: Install repo MSRV toolchain run: | rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component rustfmt rustup override set ${{ env.REPO_MSRV }} cargo -V - name: Check repository files run: cargo --locked xtask sync-repo-files --check # NOTE: Keep this above the others, because this will fail if there are _any_ changes to # files, even ones this step doesn't modify. - name: "Format `**/*.{md,js,html,yml}` files" run: "npx --yes prettier@3.9.6 --check --write . && git diff --exit-code" - name: Run `cargo fmt` run: | cargo --locked fmt -- --check - name: Install Tombi uses: tombi-toml/setup-tombi@v1.9.9 with: version: "1.1.3" - name: Format TOML files run: tombi format --check --diff - name: Check for typos uses: crate-ci/typos@v1.51.1 check-cts-runner: # runtime is normally 2 minutes timeout-minutes: 10 name: Clippy cts_runner runs-on: ubuntu-24.04 permissions: {} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Checkout repo uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Install MSRV toolchain run: | rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component clippy rustup override set ${{ env.REPO_MSRV }} cargo -V - name: Disable debug symbols shell: bash run: | mkdir -p .cargo cat <> .cargo/config.toml [profile.dev] debug = false EOF - name: Caching uses: step-security/rust-cache@v2.9.2 with: key: cts-runner-${{ env.CACHE_SUFFIX }} env-vars: ImageVersion save-if: ${{ github.ref == 'refs/heads/trunk' }} - name: Build Deno run: | cargo --locked clippy --manifest-path cts_runner/Cargo.toml # Separate job so that new advisories don't block CI. # # This job is not required to pass for PRs to be merged. cargo-deny-check-advisories: # runtime is normally 1 minute timeout-minutes: 5 name: "cargo-deny advisories" runs-on: ubuntu-24.04 permissions: {} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Checkout repo uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Run `cargo deny check` uses: EmbarkStudios/cargo-deny-action@v2.1.1 with: command: check advisories arguments: --all-features --workspace command-arguments: -Dwarnings -Aunmatched-organization rust-version: ${{ env.REPO_MSRV }} cargo-deny-check-rest: # runtime is normally 1 minute timeout-minutes: 5 name: "cargo-deny" runs-on: ubuntu-24.04 permissions: {} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Checkout repo uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Run `cargo deny check` uses: EmbarkStudios/cargo-deny-action@v2.1.1 with: command: check bans licenses sources arguments: --all-features --workspace command-arguments: -Dwarnings -Aunmatched-organization rust-version: ${{ env.REPO_MSRV }} zizmor: name: "Zizmor" runs-on: ubuntu-24.04 permissions: # `zizmor-action` uploads its findings to GitHub code scanning as SARIF. security-events: write steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 with: egress-policy: audit - name: Checkout repo uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Run `zizmor` uses: step-security/zizmor-action@v0.7.1