Skip to content

Commit

Permalink
ci: add support for different target architectures
Browse files Browse the repository at this point in the history
  • Loading branch information
wmmc88 committed Jan 13, 2024
1 parent 2f3728a commit d821497
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 15 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
- dev
- release

target_triple:
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc

steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -43,15 +47,15 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_toolchain }}
targets: ${{ matrix.target_triple }}

- name: Run Cargo Build
run: cargo build --locked --profile ${{ matrix.cargo_profile }} --workspace
run: cargo +${{ matrix.rust_toolchain }} build --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace

- name: Install Cargo Make
uses: taiki-e/install-action@v2
with:
tool: cargo-make

- name: Build and Package Sample KMDF Driver
run: cargo make --cwd .\crates\sample-kmdf-driver --profile ${{ matrix.cargo_profile }}
continue-on-error: true # FIXME: Packaging tools in non-ewdk environments are not found
run: cargo make --cwd .\crates\sample-kmdf-driver default +${{ matrix.rust_toolchain }} --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }}
2 changes: 1 addition & 1 deletion .github/workflows/code-formatting-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
components: rustfmt

- name: Run Cargo Format
run: cargo fmt --all -- --check
run: cargo +nightly fmt --all -- --check

taplo-fmt:
name: .toml Formatting Check
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
- dev
- release

target_triple:
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc

steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -43,10 +47,23 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_toolchain }}
targets: ${{ matrix.target_triple }}

- name: Run Cargo Doc
run: cargo doc --locked --profile ${{ matrix.cargo_profile }}
# proc-macro crates must be excluded to avoid cargo doc bug: https://github.com/rust-lang/cargo/issues/10368
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --exclude wdk-macros

- name: Run Cargo Doc (--features nightly)
if: matrix.rust_toolchain == 'nightly'
run: cargo doc --locked --profile ${{ matrix.cargo_profile }} --features nightly
# proc-macro crates must be excluded to avoid cargo doc bug: https://github.com/rust-lang/cargo/issues/10368
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --exclude wdk-macros --features nightly

- name: Run Cargo Doc w/ proc-macro crates
if: matrix.target_triple == 'x86_64-pc-windows-msvc'
# cargo doc can only generate documentation for proc-macro crates when --target is not specified due to a cargo doc bug: https://github.com/rust-lang/cargo/issues/7677
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }}

- name: Run Cargo Doc w/ proc-macro crates (--features nightly)
if: matrix.target_triple == 'x86_64-pc-windows-msvc'
# cargo doc can only generate documentation for proc-macro crates when --target is not specified due to a cargo doc bug: https://github.com/rust-lang/cargo/issues/7677
run: cargo +${{ matrix.rust_toolchain }} doc --locked --profile ${{ matrix.cargo_profile }} --features nightly
15 changes: 10 additions & 5 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
- dev
- release

target_triple:
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc

steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -46,13 +50,14 @@ jobs:
with:
toolchain: ${{ matrix.rust_toolchain }}
components: clippy
targets: ${{ matrix.target_triple }}

- name: Run Cargo Clippy
run: cargo clippy --locked --profile ${{ matrix.cargo_profile }} --all-targets -- -D warnings
run: cargo +${{ matrix.rust_toolchain }} clippy --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --all-targets -- -D warnings

- name: Run Cargo Clippy (--features nightly)
if: matrix.rust_toolchain == 'nightly'
run: cargo clippy --locked --profile ${{ matrix.cargo_profile }} --all-targets --features nightly -- -D warnings
run: cargo +${{ matrix.rust_toolchain }} clippy --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --all-targets --features nightly -- -D warnings

udeps:
name: Detect Unused Cargo Dependencies
Expand All @@ -78,16 +83,16 @@ jobs:
}
- name: Install Rust Toolchain (Nightly)
uses: dtolnay/rust-toolchain@nightly
# Cargo udeps only supports running on nightly due to reliance on unstable dep-info feature: https://github.com/est31/cargo-udeps/issues/113, https://github.com/est31/cargo-udeps/issues/136
uses: dtolnay/rust-toolchain@nightly

- name: Install Cargo Udeps
uses: taiki-e/install-action@v2
with:
tool: cargo-udeps

- name: Run Cargo Udeps
run: cargo udeps --locked --all-targets
run: cargo +nightly udeps --locked --all-targets

- name: Run Cargo Udeps (--features nightly)
run: cargo udeps --locked --all-targets --features nightly
run: cargo +nightly udeps --locked --all-targets --features nightly
11 changes: 7 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
- dev
- release

target_triple:
- x86_64-pc-windows-msvc
# - aarch64-pc-windows-msvc FIXME: Add support for executing ARM64 tests. Maybe use target specific test runner in emulator: https://doc.rust-lang.org/cargo/reference/config.html#target

steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -43,6 +47,7 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_toolchain }}
targets: ${{ matrix.target_triple }}

- name: Install Cargo Expand
uses: taiki-e/install-action@v2
Expand All @@ -51,10 +56,8 @@ jobs:

# FIXME: wdk-sys layout tests fail, but only on github hosted runner
- name: Run Cargo Test
# Final driver crates must be excluded since theres no way to prevent linker args from being passed to their unit tests: https://github.com/rust-lang/cargo/issues/12663
run: cargo test --locked --profile ${{ matrix.cargo_profile }} --workspace --exclude sample-* --exclude wdk-sys
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --exclude wdk-sys

- name: Run Cargo Test (--features nightly)
if: matrix.rust_toolchain == 'nightly'
# Final driver crates must be excluded since theres no way to prevent linker args from being passed to their unit tests: https://github.com/rust-lang/cargo/issues/12663
run: cargo test --locked --profile ${{ matrix.cargo_profile }} --features nightly --workspace --exclude sample-* --exclude wdk-sys
run: cargo +${{ matrix.rust_toolchain }} test --locked --profile ${{ matrix.cargo_profile }} --target ${{ matrix.target_triple }} --workspace --exclude wdk-sys --features nightly
2 changes: 2 additions & 0 deletions crates/sample-kmdf-driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ publish = false

[lib]
crate-type = ["cdylib"]
# Tests from root driver crates must be excluded since there's no way to prevent linker args from being passed to their unit tests: https://github.com/rust-lang/cargo/issues/12663
test = false

[dependencies]
wdk.workspace = true
Expand Down

0 comments on commit d821497

Please sign in to comment.