Skip to content

chore: update cargo-wdk templates to use latest crate versions#573

Merged
gurry merged 10 commits intomainfrom
copilot/update-cargo-wdk-templates
Nov 12, 2025
Merged

chore: update cargo-wdk templates to use latest crate versions#573
gurry merged 10 commits intomainfrom
copilot/update-cargo-wdk-templates

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

This PR updates cargo wdk new templates to use the latest versions of windows-drivers-rs crates and adds CI checks to make sure these versions remain up-to-date in the future.

Changes

  • Updated crate versions:

    • wdk: 0.3.0 → 0.4.0
    • wdk-build: 0.3.0 → 0.5.0
    • wdk-sys: 0.3.0 → 0.5.0
    • wdk-alloc: 0.3.0 → 0.4.0
    • wdk-panic: 0.3.0 → 0.4.0
  • Added CI checks: Added CI checks to ensure we always use the latest WDR crates in templates. These check compare the deps in Cargo.toml.tmp files to those in the workspace's Cargo.toml file assuming the latter always contains the latest.

  • Fixes cargo wdk new templates are using outdated versions of windows-drivers-rs crates #572

Copilot AI and others added 2 commits November 11, 2025 07:58
- Updated all template Cargo.toml files to use latest crate versions
- Added template_versions_test.rs to verify templates match workspace
- Added toml dev-dependency for parsing in tests

Co-authored-by: gurry <1068853+gurry@users.noreply.github.com>
Co-authored-by: gurry <1068853+gurry@users.noreply.github.com>
Copilot AI changed the title [WIP] Update cargo wdk new templates with latest windows-drivers-rs crates Update cargo-wdk templates to use latest crate versions and add CI enforcement Nov 11, 2025
Copilot AI requested a review from gurry November 11, 2025 08:04
Copilot AI and others added 2 commits November 11, 2025 09:43
- Remove template_versions_test.rs (Rust test)
- Add .github/scripts/check-template-versions.ps1 (PowerShell script)
- Add .github/workflows/template-version-check.yaml (GitHub workflow)
- Script reads versions from [package] sections of crates, not workspace
- Workflow runs automatically on push, PR, and scheduled daily

Co-authored-by: gurry <1068853+gurry@users.noreply.github.com>
Since we replaced the Rust test with a PowerShell script, the toml dependency is no longer needed.

Co-authored-by: gurry <1068853+gurry@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 11, 2025

@copilot please fix all the check failures and also address the review comment I added on crates/cargo-wdk/tests/template_versions_test.rs

Addressed the review feedback:

  1. Replaced Rust test with PowerShell script in pipeline (commit 3fa7426)
  2. Script now reads versions from [package] sections instead of workspace dependencies
  3. Removed unnecessary toml dependency (commit 4eef7d5)

The workflow will now run as part of CI checks.

Copilot AI requested a review from gurry November 11, 2025 09:47
Changed check-template-versions.ps1 to read versions from the workspace
Cargo.toml [workspace.dependencies] section instead of individual crate
[package] sections. This matches the versions released on crates.io.

Co-authored-by: gurry <1068853+gurry@users.noreply.github.com>
Copilot AI requested a review from gurry November 11, 2025 11:10
@gurry gurry changed the title Update cargo-wdk templates to use latest crate versions and add CI enforcement chore: update cargo-wdk templates to use latest crate versions and add CI enforcement Nov 12, 2025
@gurry gurry changed the title chore: update cargo-wdk templates to use latest crate versions and add CI enforcement chore: update cargo-wdk templates to use latest crate versions Nov 12, 2025
@gurry
Copy link
Contributor

gurry commented Nov 12, 2025

@copilot Make this check a step in the version-checks.yaml workflow instead creating it as a workflow of its own. In that step use the compare-regex-versions action similar to existing steps there and remove the check-template-versions.ps1 PowerShell script.

- Removed standalone template-version-check.yaml workflow
- Removed check-template-versions.ps1 PowerShell script
- Added template version check steps to version-checks.yaml
- Uses compare-regex-versions action for consistency
- Runs on ubuntu-latest (faster than windows runners)
- Checks all wdk dependencies in kmdf, umdf, and wdm templates

Co-authored-by: gurry <1068853+gurry@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 12, 2025

@copilot Make this check a step in the version-checks.yaml workflow instead creating it as a workflow of its own. In that step use the compare-regex-versions action similar to existing steps there...

Migrated template version checks to version-checks.yaml workflow. Removed the standalone workflow and PowerShell script. All template dependencies now use the compare-regex-versions action and run on ubuntu-latest for faster execution. Changes in commit ab53273.

@gurry
Copy link
Contributor

gurry commented Nov 12, 2025

@copilot Instead of adding 13 separate checks, is it possible to reduce duplication by having just one step check for every combination of Cargo.toml.tmp and dependencies? Don't make any changes. Just show me how it can be done if it all

Copy link
Contributor Author

Copilot AI commented Nov 12, 2025

@copilot Instead of adding 13 separate checks, is it possible to reduce duplication by having just one step do it for every combination of Cargo.toml.tmp and dependency? Don't make any changes. Just s...

Yes, there are a few approaches to reduce duplication:

Option 1: Use a matrix strategy (but has limitations with composite actions)

- name: Check template versions
  strategy:
    matrix:
      template: [kmdf, umdf, wdm]
      dependency: [wdk, wdk-build, wdk-sys]
      # Would need conditional logic to skip wdk-alloc/wdk-panic for umdf
  uses: ./.github/actions/compare-regex-versions
  with:
    file1: crates/cargo-wdk/templates/${{ matrix.template }}/Cargo.toml.tmp
    # ... rest of parameters

However, GitHub Actions doesn't support matrix strategy directly on individual steps, only on jobs.

Option 2: Create a single bash script step

- name: Check all template versions
  shell: bash
  run: |
    # Define templates and their dependencies
    declare -A templates=(
      ["kmdf"]="wdk wdk-build wdk-alloc wdk-panic wdk-sys"
      ["umdf"]="wdk wdk-build wdk-sys"
      ["wdm"]="wdk wdk-build wdk-alloc wdk-panic wdk-sys"
    )
    
    for template in "${!templates[@]}"; do
      for dep in ${templates[$template]}; do
        # Extract and compare versions using grep
        template_version=$(grep -oP "^${dep}\s*=\s*\"\K[^\"]+\" crates/cargo-wdk/templates/${template}/Cargo.toml.tmp)
        workspace_version=$(grep -oP "^${dep}\s*=\s*\{[^}]*version\s*=\s*\"\K[^\"]+\" Cargo.toml)
        
        if [ "$template_version" != "$workspace_version" ]; then
          echo "::error::Mismatch in ${template}: ${dep} template=${template_version} workspace=${workspace_version}"
          exit 1
        fi
      done
    done

Option 3: Create a new composite action that loops internally
Create .github/actions/check-template-versions/action.yaml that takes template configs as JSON input and loops internally.

The current 13-step approach is more explicit and provides clearer CI feedback (each check shows up separately), but Option 2 would be the most practical reduction in duplication.

@gurry
Copy link
Contributor

gurry commented Nov 12, 2025

@copilot Would it it be a good idea to convert the action into a bash script which can be called in a loop?

Copy link
Contributor Author

Copilot AI commented Nov 12, 2025

@copilot Would it it be a good idea to convert hte action into a bash script which can be called in a loop?

Converting the action into a bash script and calling it in a loop is feasible, but there are trade-offs to consider:

Pros of converting to a loopable bash script:

  • Reduces duplication from 13 steps to 1
  • Easier to maintain when adding new templates or dependencies
  • More compact workflow file

Cons of converting to a loopable bash script:

  • Loses granular CI feedback: Currently each check appears as a separate step in the GitHub Actions UI, making it immediately clear which specific template/dependency combination failed. With a loop, you'd only see one step that failed, requiring log inspection to identify the specific failure.
  • Existing action is reusable: The compare-regex-versions action is already used for other version checks (README, lockstep versioning). Converting template checks to a custom script creates inconsistency.
  • Less flexible error messages: The action supports custom error messages per check; a loop would need additional logic to maintain this.

Recommendation:
Keep the current approach for template checks since:

  1. The action is already established and used elsewhere in the workflow
  2. The explicit CI feedback is valuable for quickly identifying issues
  3. The duplication is manageable (13 checks for 3 templates)

However, if the number of templates or dependencies grows significantly, refactoring to a bash script with a loop would become more attractive.

- Removed blank line after comment (line 58)
- Removed file1-label, file2-label, and error-message from all 13 template checks
- Default labels and error messages are sufficient
- Reduces workflow file from 226 to 186 lines

Co-authored-by: gurry <1068853+gurry@users.noreply.github.com>
@gurry
Copy link
Contributor

gurry commented Nov 12, 2025

A separate workflow step for each file/dependency combination looks verbose and ugly. We should ideally run the checks in a loop using a table for the files. But let's not delay the patch release. Will tackle that later.

Copilot AI requested a review from gurry November 12, 2025 09:10
Signed-off-by: Gurinder Singh <frederick.the.fool@gmail.com>
@gurry gurry marked this pull request as ready for review November 12, 2025 09:39
Copilot AI review requested due to automatic review settings November 12, 2025 09:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the cargo wdk new templates to use the latest versions of windows-drivers-rs crates and adds comprehensive CI checks to ensure template versions remain synchronized with workspace dependencies.

  • Updated all template Cargo.toml files to use latest crate versions (wdk 0.4.0, wdk-build 0.5.0, wdk-sys 0.5.0, wdk-alloc 0.4.0, wdk-panic 0.4.0)
  • Added CI validation to compare template dependency versions against workspace Cargo.toml versions
  • Ensures future version updates are automatically validated through CI

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
crates/cargo-wdk/templates/wdm/Cargo.toml.tmp Updated WDM template dependencies to latest versions (wdk, wdk-build, wdk-alloc, wdk-panic, wdk-sys)
crates/cargo-wdk/templates/umdf/Cargo.toml.tmp Updated UMDF template dependencies to latest versions (wdk, wdk-build, wdk-sys)
crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp Updated KMDF template dependencies to latest versions (wdk, wdk-build, wdk-alloc, wdk-panic, wdk-sys)
.github/workflows/version-checks.yaml Added CI checks for all three templates (KMDF, UMDF, WDM) to validate dependency versions match workspace versions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gurry gurry enabled auto-merge November 12, 2025 09:50
@gurry gurry added this pull request to the merge queue Nov 12, 2025
Merged via the queue into main with commit 1716d4a Nov 12, 2025
463 checks passed
@gurry gurry deleted the copilot/update-cargo-wdk-templates branch November 12, 2025 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo wdk new templates are using outdated versions of windows-drivers-rs crates

5 participants