chore: update cargo-wdk templates to use latest crate versions#573
chore: update cargo-wdk templates to use latest crate versions#573
Conversation
- 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>
cargo wdk new templates with latest windows-drivers-rs crates- 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>
Addressed the review feedback:
The workflow will now run as part of CI checks. |
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 Make this check a step in the |
- 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>
Migrated template version checks to |
|
@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 |
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 parametersHowever, 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
doneOption 3: Create a new composite action that 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. |
|
@copilot Would it it be a good idea to convert the 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:
Cons of converting to a loopable bash script:
Recommendation:
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>
|
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. |
Signed-off-by: Gurinder Singh <frederick.the.fool@gmail.com>
There was a problem hiding this comment.
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.
This PR updates
cargo wdk newtemplates 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.0wdk-build: 0.3.0 → 0.5.0wdk-sys: 0.3.0 → 0.5.0wdk-alloc: 0.3.0 → 0.4.0wdk-panic: 0.3.0 → 0.4.0Added CI checks: Added CI checks to ensure we always use the latest WDR crates in templates. These check compare the deps in
Cargo.toml.tmpfiles to those in the workspace'sCargo.tomlfile assuming the latter always contains the latest.Fixes
cargo wdk newtemplates are using outdated versions of windows-drivers-rs crates #572