Skip to content

Pin GitHub Actions to full-length commit SHAs #1

Pin GitHub Actions to full-length commit SHAs

Pin GitHub Actions to full-length commit SHAs #1

Workflow file for this run

on:
push:
branches-ignore:
- 'gh-readonly-queue/**'
pull_request:
merge_group:
schedule: # Trigger a job on default branch at 4AM PST everyday
- cron: 0 11 * * *
name: Test
concurrency:
group: ${{ github.workflow }}-${{ github.event.compare || github.head_ref || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
# TODO: Remove when cargo-wdk supports Cargo build-dir layout v2 (see https://github.com/microsoft/windows-drivers-rs/issues/709).
# The whitelist in function `sanitize_env_vars` in crates/cargo-wdk/tests/test_utils/mod.rs should also be removed once this env var is removed.
CARGO_UNSTABLE_BUILD_DIR_NEW_LAYOUT: 'false'
jobs:
test:
name: Test
strategy:
fail-fast: false # Allow all matrix variants to complete even if some fail
matrix:
runner:
- name: windows-2025
arch: amd64
- name: windows-11-arm
arch: arm64
wdk:
- version: 10.0.22621 # NI WDK
source: winget
- version: 10.0.26100 # GE WDK
source: nuget
llvm:
- 17.0.6
rust_toolchain:
- stable
- beta
- nightly
cargo_profile:
- dev
- release
runs-on: ${{ matrix.runner.name }}
steps:
- name: Checkout Repository
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Install Winget
uses: ./.github/actions/install-winget
with:
# windows-11-arm runner image does not include winget-cli (see https://github.com/actions/partner-runner-images/issues/95).
force-cli-install: ${{ matrix.runner.name == 'windows-11-arm' && 'true' || 'false' }}
- name: Install LLVM ${{ matrix.llvm }}
uses: ./.github/actions/install-llvm
with:
version: ${{ matrix.llvm }}
- name: Install WDK (${{ matrix.wdk.version }})
uses: ./.github/actions/install-wdk
with:
version: ${{ matrix.wdk.version }}
source: ${{ matrix.wdk.source }}
host: ${{ matrix.wdk.source == 'nuget' && matrix.runner.arch || '' }}
target: ${{ matrix.wdk.source == 'nuget' && matrix.runner.arch || '' }}
- name: Install Rust Toolchain (${{ matrix.rust_toolchain }}) and LLVM tools
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_toolchain }}
targets: |
x86_64-pc-windows-msvc
aarch64-pc-windows-msvc
components: llvm-tools-preview
- name: Install cargo-llvm-cov
if: matrix.runner.arch != 'arm64'
uses: ./.github/actions/install-cargo-tool
with:
tool: cargo-llvm-cov
- name: Install Cargo Expand
uses: ./.github/actions/install-cargo-tool
with:
tool: cargo-expand@1.0.85
- name: Install Cargo Make
uses: ./.github/actions/install-cargo-tool
with:
tool: cargo-make
# Code coverage is generated only for amd64 because cargo-llvm-cov
# does not currently support Windows on arm64.
# See issue: https://github.com/taiki-e/cargo-llvm-cov/issues/436
- name: Run Cargo Test with Coverage (workspace)
if: matrix.runner.arch != 'arm64'
env:
# cargo-wdk new tests try to build newly generated
# driver projects which can fail in release-plz PRs
# because the dependencies are not yet published.
# This env var skips such builds for release-plz PRs
SKIP_BUILD_IN_CARGO_WDK_NEW_TESTS: ${{ startsWith(github.head_ref, 'release-plz-') && '1' || '' }}
run: cargo +${{ matrix.rust_toolchain }} llvm-cov --workspace --codecov --output-path target/codecov.info --locked --profile ${{ matrix.cargo_profile }} --all-features
- name: Upload Coverage to Codecov
if: matrix.runner.arch != 'arm64' && github.repository == 'microsoft/windows-drivers-rs' # Skip for forks because they may not have CODECOV_TOKEN
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
files: target/codecov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
- name: Run Cargo Test (workspace)
if: matrix.runner.arch == 'arm64'
env:
# Skips build in cargo-wdk new tests for release-plz PRs
SKIP_BUILD_IN_CARGO_WDK_NEW_TESTS: ${{ startsWith(github.head_ref, 'release-plz-') && '1' || '' }}
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --all-features
- name: Run Cargo Test (Top-Level tests Folder via Cargo Make)
run: cargo +${{ matrix.rust_toolchain }} make --cwd ./tests test --locked --profile ${{ matrix.cargo_profile }}