From 6f2c016bfc2e99bb22431b1b4f425fe146060fbd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 07:50:07 +0000 Subject: [PATCH 1/9] Initial plan From cb786ad84cc11b3dc7f0a3e0cedc977b68492612 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 07:58:54 +0000 Subject: [PATCH 2/9] Update template versions and add version validation test - 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> --- Cargo.lock | 82 ++++++++++ crates/cargo-wdk/Cargo.toml | 1 + .../cargo-wdk/templates/kmdf/Cargo.toml.tmp | 10 +- .../cargo-wdk/templates/umdf/Cargo.toml.tmp | 6 +- crates/cargo-wdk/templates/wdm/Cargo.toml.tmp | 10 +- .../cargo-wdk/tests/template_versions_test.rs | 147 ++++++++++++++++++ 6 files changed, 243 insertions(+), 13 deletions(-) create mode 100644 crates/cargo-wdk/tests/template_versions_test.rs diff --git a/Cargo.lock b/Cargo.lock index c88a92723..f3b22e1dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,6 +188,7 @@ dependencies = [ "serde_json", "sha2", "thiserror", + "toml", "tracing", "tracing-subscriber", "wdk-build", @@ -393,6 +394,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + [[package]] name = "errno" version = "0.3.12" @@ -492,6 +499,12 @@ dependencies = [ "walkdir", ] +[[package]] +name = "hashbrown" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" + [[package]] name = "heck" version = "0.5.0" @@ -533,6 +546,16 @@ dependencies = [ "quote", ] +[[package]] +name = "indexmap" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.0" @@ -889,6 +912,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + [[package]] name = "sha2" version = "0.10.9" @@ -987,6 +1019,47 @@ dependencies = [ "once_cell", ] +[[package]] +name = "toml" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "toml_write", + "winnow", +] + +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + [[package]] name = "tracing" version = "0.1.41" @@ -1334,6 +1407,15 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winnow" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +dependencies = [ + "memchr", +] + [[package]] name = "wit-bindgen-rt" version = "0.33.0" diff --git a/crates/cargo-wdk/Cargo.toml b/crates/cargo-wdk/Cargo.toml index 059bbe34c..842ec0e3f 100644 --- a/crates/cargo-wdk/Cargo.toml +++ b/crates/cargo-wdk/Cargo.toml @@ -32,6 +32,7 @@ assert_fs.workspace = true predicates.workspace = true regex.workspace = true sha2.workspace = true +toml = "0.8" [lints.rust] missing_docs = "warn" diff --git a/crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp b/crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp index 889ab805a..4afb3e9a1 100644 --- a/crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp +++ b/crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp @@ -7,13 +7,13 @@ target-kmdf-version-minor = 33 crate-type = ["cdylib"] [build-dependencies] -wdk-build = "0.3.0" +wdk-build = "0.5.0" [dependencies] -wdk = "0.3.0" -wdk-alloc = "0.3.0" -wdk-panic = "0.3.0" -wdk-sys = "0.3.0" +wdk = "0.4.0" +wdk-alloc = "0.4.0" +wdk-panic = "0.4.0" +wdk-sys = "0.5.0" [features] default = [] diff --git a/crates/cargo-wdk/templates/umdf/Cargo.toml.tmp b/crates/cargo-wdk/templates/umdf/Cargo.toml.tmp index 1bd43a48e..24b92c453 100644 --- a/crates/cargo-wdk/templates/umdf/Cargo.toml.tmp +++ b/crates/cargo-wdk/templates/umdf/Cargo.toml.tmp @@ -7,11 +7,11 @@ target-umdf-version-minor = 33 crate-type = ["cdylib"] [build-dependencies] -wdk-build = "0.3.0" +wdk-build = "0.5.0" [dependencies] -wdk = "0.3.0" -wdk-sys = "0.3.0" +wdk = "0.4.0" +wdk-sys = "0.5.0" [features] default = [] diff --git a/crates/cargo-wdk/templates/wdm/Cargo.toml.tmp b/crates/cargo-wdk/templates/wdm/Cargo.toml.tmp index 725ea8202..0380e56b1 100644 --- a/crates/cargo-wdk/templates/wdm/Cargo.toml.tmp +++ b/crates/cargo-wdk/templates/wdm/Cargo.toml.tmp @@ -5,13 +5,13 @@ driver-type = "WDM" crate-type = ["cdylib"] [build-dependencies] -wdk-build = "0.3.0" +wdk-build = "0.5.0" [dependencies] -wdk = "0.3.0" -wdk-alloc = "0.3.0" -wdk-panic = "0.3.0" -wdk-sys = "0.3.0" +wdk = "0.4.0" +wdk-alloc = "0.4.0" +wdk-panic = "0.4.0" +wdk-sys = "0.5.0" [features] default = [] diff --git a/crates/cargo-wdk/tests/template_versions_test.rs b/crates/cargo-wdk/tests/template_versions_test.rs new file mode 100644 index 000000000..a98e6cf7c --- /dev/null +++ b/crates/cargo-wdk/tests/template_versions_test.rs @@ -0,0 +1,147 @@ +//! Test to verify that template Cargo.toml files use the correct versions +//! from the workspace configuration. + +use std::{collections::HashMap, path::PathBuf}; + +use cargo_metadata::MetadataCommand; +use toml::Value; + +/// Get the workspace versions from the root Cargo.toml +fn get_workspace_versions() -> HashMap { + let metadata = MetadataCommand::new() + .manifest_path("../../Cargo.toml") + .exec() + .expect("Failed to get cargo metadata"); + + let mut versions = HashMap::new(); + + // Get workspace dependencies + let workspace_root = metadata.workspace_root.as_std_path(); + let cargo_toml_path = workspace_root.join("Cargo.toml"); + let cargo_toml_content = + std::fs::read_to_string(&cargo_toml_path).expect("Failed to read workspace Cargo.toml"); + let cargo_toml: Value = + toml::from_str(&cargo_toml_content).expect("Failed to parse workspace Cargo.toml"); + + if let Some(workspace) = cargo_toml.get("workspace") { + if let Some(deps) = workspace.get("dependencies") { + if let Some(deps_table) = deps.as_table() { + for (name, value) in deps_table { + if name.starts_with("wdk") { + if let Some(version) = value.get("version") { + if let Some(version_str) = version.as_str() { + versions.insert(name.clone(), version_str.to_string()); + } + } + } + } + } + } + } + + versions +} + +/// Parse a template Cargo.toml and extract dependency versions +fn get_template_versions(template_path: PathBuf) -> HashMap { + let template_content = + std::fs::read_to_string(&template_path).expect("Failed to read template file"); + let template_toml: Value = + toml::from_str(&template_content).expect("Failed to parse template TOML"); + + let mut versions = HashMap::new(); + + // Check build-dependencies + if let Some(build_deps) = template_toml.get("build-dependencies") { + if let Some(build_deps_table) = build_deps.as_table() { + for (name, value) in build_deps_table { + if name.starts_with("wdk") { + if let Some(version_str) = value.as_str() { + versions.insert(name.clone(), version_str.to_string()); + } + } + } + } + } + + // Check dependencies + if let Some(deps) = template_toml.get("dependencies") { + if let Some(deps_table) = deps.as_table() { + for (name, value) in deps_table { + if name.starts_with("wdk") { + if let Some(version_str) = value.as_str() { + versions.insert(name.clone(), version_str.to_string()); + } + } + } + } + } + + versions +} + +#[test] +fn kmdf_template_versions_match_workspace() { + let workspace_versions = get_workspace_versions(); + let template_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("templates") + .join("kmdf") + .join("Cargo.toml.tmp"); + let template_versions = get_template_versions(template_path); + + // KMDF template should have: wdk-build, wdk, wdk-alloc, wdk-panic, wdk-sys + for (dep_name, template_version) in &template_versions { + let workspace_version = workspace_versions + .get(dep_name) + .unwrap_or_else(|| panic!("Dependency {dep_name} not found in workspace")); + assert_eq!( + template_version, workspace_version, + "KMDF template: {dep_name} version mismatch. Template has {template_version}, \ + workspace has {workspace_version}" + ); + } +} + +#[test] +fn umdf_template_versions_match_workspace() { + let workspace_versions = get_workspace_versions(); + let template_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("templates") + .join("umdf") + .join("Cargo.toml.tmp"); + let template_versions = get_template_versions(template_path); + + // UMDF template should have: wdk-build, wdk, wdk-sys + for (dep_name, template_version) in &template_versions { + let workspace_version = workspace_versions + .get(dep_name) + .unwrap_or_else(|| panic!("Dependency {dep_name} not found in workspace")); + assert_eq!( + template_version, workspace_version, + "UMDF template: {dep_name} version mismatch. Template has {template_version}, \ + workspace has {workspace_version}" + ); + } +} + +#[test] +fn wdm_template_versions_match_workspace() { + let workspace_versions = get_workspace_versions(); + let template_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("templates") + .join("wdm") + .join("Cargo.toml.tmp"); + let template_versions = get_template_versions(template_path); + + // WDM template should have: wdk-build, wdk, wdk-alloc, wdk-panic, wdk-sys + for (dep_name, template_version) in &template_versions { + let workspace_version = workspace_versions + .get(dep_name) + .unwrap_or_else(|| panic!("Dependency {dep_name} not found in workspace")); + assert_eq!( + template_version, workspace_version, + "WDM template: {dep_name} version mismatch. Template has {template_version}, workspace \ + has {workspace_version}" + ); + } +} From 56ce8bb4f53d2603c01f6db498daea6321533972 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 08:01:00 +0000 Subject: [PATCH 3/9] Add copyright header to template_versions_test.rs Co-authored-by: gurry <1068853+gurry@users.noreply.github.com> --- crates/cargo-wdk/tests/template_versions_test.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/cargo-wdk/tests/template_versions_test.rs b/crates/cargo-wdk/tests/template_versions_test.rs index a98e6cf7c..11ffe2e88 100644 --- a/crates/cargo-wdk/tests/template_versions_test.rs +++ b/crates/cargo-wdk/tests/template_versions_test.rs @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation +// License: MIT OR Apache-2.0 //! Test to verify that template Cargo.toml files use the correct versions //! from the workspace configuration. From 3fa7426688747587c0a736826947440e86d5f5dc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 09:43:54 +0000 Subject: [PATCH 4/9] Replace Rust test with PowerShell script and workflow - 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> --- .github/scripts/check-template-versions.ps1 | 139 ++++++++++++++++ .github/workflows/template-version-check.yaml | 27 ++++ .../cargo-wdk/tests/template_versions_test.rs | 149 ------------------ 3 files changed, 166 insertions(+), 149 deletions(-) create mode 100644 .github/scripts/check-template-versions.ps1 create mode 100644 .github/workflows/template-version-check.yaml delete mode 100644 crates/cargo-wdk/tests/template_versions_test.rs diff --git a/.github/scripts/check-template-versions.ps1 b/.github/scripts/check-template-versions.ps1 new file mode 100644 index 000000000..f83f221cd --- /dev/null +++ b/.github/scripts/check-template-versions.ps1 @@ -0,0 +1,139 @@ +#!/usr/bin/env pwsh +# Copyright (c) Microsoft Corporation +# License: MIT OR Apache-2.0 + +# This script verifies that the cargo-wdk template Cargo.toml files use the correct +# versions of WDK crates by reading from each crate's [package] section. + +$ErrorActionPreference = "Stop" + +# Function to extract version from a Cargo.toml [package] section +function Get-PackageVersion { + param ( + [string]$CargoTomlPath + ) + + if (-not (Test-Path $CargoTomlPath)) { + Write-Error "Cargo.toml not found at: $CargoTomlPath" + exit 1 + } + + $content = Get-Content $CargoTomlPath -Raw + + # Match version in [package] section + if ($content -match '(?ms)\[package\].*?version\s*=\s*"([^"]+)"') { + return $Matches[1] + } + + Write-Error "Could not find version in [package] section of $CargoTomlPath" + exit 1 +} + +# Function to extract dependency versions from a template file +function Get-TemplateDependencies { + param ( + [string]$TemplatePath + ) + + if (-not (Test-Path $TemplatePath)) { + Write-Error "Template not found at: $TemplatePath" + exit 1 + } + + $content = Get-Content $TemplatePath -Raw + $dependencies = @{} + + # Extract wdk-* dependencies and their versions + $pattern = '(wdk[a-z-]*)\s*=\s*"([^"]+)"' + $matches = [regex]::Matches($content, $pattern) + + foreach ($match in $matches) { + $depName = $match.Groups[1].Value + $depVersion = $match.Groups[2].Value + $dependencies[$depName] = $depVersion + } + + return $dependencies +} + +Write-Host "Checking template versions against crate package versions..." -ForegroundColor Cyan + +# Get actual crate versions from [package] sections +$wdkVersion = Get-PackageVersion "crates/wdk/Cargo.toml" +$wdkAllocVersion = Get-PackageVersion "crates/wdk-alloc/Cargo.toml" +$wdkBuildVersion = Get-PackageVersion "crates/wdk-build/Cargo.toml" +$wdkPanicVersion = Get-PackageVersion "crates/wdk-panic/Cargo.toml" +$wdkSysVersion = Get-PackageVersion "crates/wdk-sys/Cargo.toml" + +Write-Host "" +Write-Host "Current crate versions:" -ForegroundColor Green +Write-Host " wdk: $wdkVersion" +Write-Host " wdk-alloc: $wdkAllocVersion" +Write-Host " wdk-build: $wdkBuildVersion" +Write-Host " wdk-panic: $wdkPanicVersion" +Write-Host " wdk-sys: $wdkSysVersion" +Write-Host "" + +$expectedVersions = @{ + "wdk" = $wdkVersion + "wdk-alloc" = $wdkAllocVersion + "wdk-build" = $wdkBuildVersion + "wdk-panic" = $wdkPanicVersion + "wdk-sys" = $wdkSysVersion +} + +$templates = @( + @{ + Name = "KMDF" + Path = "crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp" + ExpectedDeps = @("wdk", "wdk-alloc", "wdk-build", "wdk-panic", "wdk-sys") + }, + @{ + Name = "UMDF" + Path = "crates/cargo-wdk/templates/umdf/Cargo.toml.tmp" + ExpectedDeps = @("wdk", "wdk-build", "wdk-sys") + }, + @{ + Name = "WDM" + Path = "crates/cargo-wdk/templates/wdm/Cargo.toml.tmp" + ExpectedDeps = @("wdk", "wdk-alloc", "wdk-build", "wdk-panic", "wdk-sys") + } +) + +$hasErrors = $false + +foreach ($template in $templates) { + Write-Host "Checking $($template.Name) template..." -ForegroundColor Cyan + + $templateDeps = Get-TemplateDependencies $template.Path + + foreach ($depName in $template.ExpectedDeps) { + if (-not $templateDeps.ContainsKey($depName)) { + Write-Host " ERROR: $depName is missing from template" -ForegroundColor Red + $hasErrors = $true + continue + } + + $templateVersion = $templateDeps[$depName] + $expectedVersion = $expectedVersions[$depName] + + if ($templateVersion -ne $expectedVersion) { + Write-Host " ERROR: $depName version mismatch" -ForegroundColor Red + Write-Host " Template has: $templateVersion" -ForegroundColor Red + Write-Host " Expected: $expectedVersion" -ForegroundColor Red + $hasErrors = $true + } else { + Write-Host " OK: $depName = $templateVersion" -ForegroundColor Green + } + } + + Write-Host "" +} + +if ($hasErrors) { + Write-Host "Template version check FAILED!" -ForegroundColor Red + exit 1 +} else { + Write-Host "All template versions are correct!" -ForegroundColor Green + exit 0 +} diff --git a/.github/workflows/template-version-check.yaml b/.github/workflows/template-version-check.yaml new file mode 100644 index 000000000..44bb96917 --- /dev/null +++ b/.github/workflows/template-version-check.yaml @@ -0,0 +1,27 @@ +name: Template Version Check + +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 * * * + +concurrency: + group: ${{ github.workflow }}-${{ github.event.compare || github.head_ref || github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + check-template-versions: + name: Check Template Versions + runs-on: windows-2025 + + steps: + - name: Checkout Repository + uses: actions/checkout@v5 + + - name: Run Template Version Check + shell: pwsh + run: .github/scripts/check-template-versions.ps1 diff --git a/crates/cargo-wdk/tests/template_versions_test.rs b/crates/cargo-wdk/tests/template_versions_test.rs deleted file mode 100644 index 11ffe2e88..000000000 --- a/crates/cargo-wdk/tests/template_versions_test.rs +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (c) Microsoft Corporation -// License: MIT OR Apache-2.0 -//! Test to verify that template Cargo.toml files use the correct versions -//! from the workspace configuration. - -use std::{collections::HashMap, path::PathBuf}; - -use cargo_metadata::MetadataCommand; -use toml::Value; - -/// Get the workspace versions from the root Cargo.toml -fn get_workspace_versions() -> HashMap { - let metadata = MetadataCommand::new() - .manifest_path("../../Cargo.toml") - .exec() - .expect("Failed to get cargo metadata"); - - let mut versions = HashMap::new(); - - // Get workspace dependencies - let workspace_root = metadata.workspace_root.as_std_path(); - let cargo_toml_path = workspace_root.join("Cargo.toml"); - let cargo_toml_content = - std::fs::read_to_string(&cargo_toml_path).expect("Failed to read workspace Cargo.toml"); - let cargo_toml: Value = - toml::from_str(&cargo_toml_content).expect("Failed to parse workspace Cargo.toml"); - - if let Some(workspace) = cargo_toml.get("workspace") { - if let Some(deps) = workspace.get("dependencies") { - if let Some(deps_table) = deps.as_table() { - for (name, value) in deps_table { - if name.starts_with("wdk") { - if let Some(version) = value.get("version") { - if let Some(version_str) = version.as_str() { - versions.insert(name.clone(), version_str.to_string()); - } - } - } - } - } - } - } - - versions -} - -/// Parse a template Cargo.toml and extract dependency versions -fn get_template_versions(template_path: PathBuf) -> HashMap { - let template_content = - std::fs::read_to_string(&template_path).expect("Failed to read template file"); - let template_toml: Value = - toml::from_str(&template_content).expect("Failed to parse template TOML"); - - let mut versions = HashMap::new(); - - // Check build-dependencies - if let Some(build_deps) = template_toml.get("build-dependencies") { - if let Some(build_deps_table) = build_deps.as_table() { - for (name, value) in build_deps_table { - if name.starts_with("wdk") { - if let Some(version_str) = value.as_str() { - versions.insert(name.clone(), version_str.to_string()); - } - } - } - } - } - - // Check dependencies - if let Some(deps) = template_toml.get("dependencies") { - if let Some(deps_table) = deps.as_table() { - for (name, value) in deps_table { - if name.starts_with("wdk") { - if let Some(version_str) = value.as_str() { - versions.insert(name.clone(), version_str.to_string()); - } - } - } - } - } - - versions -} - -#[test] -fn kmdf_template_versions_match_workspace() { - let workspace_versions = get_workspace_versions(); - let template_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("templates") - .join("kmdf") - .join("Cargo.toml.tmp"); - let template_versions = get_template_versions(template_path); - - // KMDF template should have: wdk-build, wdk, wdk-alloc, wdk-panic, wdk-sys - for (dep_name, template_version) in &template_versions { - let workspace_version = workspace_versions - .get(dep_name) - .unwrap_or_else(|| panic!("Dependency {dep_name} not found in workspace")); - assert_eq!( - template_version, workspace_version, - "KMDF template: {dep_name} version mismatch. Template has {template_version}, \ - workspace has {workspace_version}" - ); - } -} - -#[test] -fn umdf_template_versions_match_workspace() { - let workspace_versions = get_workspace_versions(); - let template_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("templates") - .join("umdf") - .join("Cargo.toml.tmp"); - let template_versions = get_template_versions(template_path); - - // UMDF template should have: wdk-build, wdk, wdk-sys - for (dep_name, template_version) in &template_versions { - let workspace_version = workspace_versions - .get(dep_name) - .unwrap_or_else(|| panic!("Dependency {dep_name} not found in workspace")); - assert_eq!( - template_version, workspace_version, - "UMDF template: {dep_name} version mismatch. Template has {template_version}, \ - workspace has {workspace_version}" - ); - } -} - -#[test] -fn wdm_template_versions_match_workspace() { - let workspace_versions = get_workspace_versions(); - let template_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("templates") - .join("wdm") - .join("Cargo.toml.tmp"); - let template_versions = get_template_versions(template_path); - - // WDM template should have: wdk-build, wdk, wdk-alloc, wdk-panic, wdk-sys - for (dep_name, template_version) in &template_versions { - let workspace_version = workspace_versions - .get(dep_name) - .unwrap_or_else(|| panic!("Dependency {dep_name} not found in workspace")); - assert_eq!( - template_version, workspace_version, - "WDM template: {dep_name} version mismatch. Template has {template_version}, workspace \ - has {workspace_version}" - ); - } -} From 4eef7d581dd5ed5c8742367d9c6c0ba0583ffae4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 09:45:43 +0000 Subject: [PATCH 5/9] Remove toml dependency that's no longer needed 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> --- Cargo.lock | 82 ------------------------------------- crates/cargo-wdk/Cargo.toml | 1 - 2 files changed, 83 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3b22e1dc..c88a92723 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,7 +188,6 @@ dependencies = [ "serde_json", "sha2", "thiserror", - "toml", "tracing", "tracing-subscriber", "wdk-build", @@ -394,12 +393,6 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" -[[package]] -name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - [[package]] name = "errno" version = "0.3.12" @@ -499,12 +492,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "hashbrown" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" - [[package]] name = "heck" version = "0.5.0" @@ -546,16 +533,6 @@ dependencies = [ "quote", ] -[[package]] -name = "indexmap" -version = "2.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" -dependencies = [ - "equivalent", - "hashbrown", -] - [[package]] name = "is_terminal_polyfill" version = "1.70.0" @@ -912,15 +889,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_spanned" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" -dependencies = [ - "serde", -] - [[package]] name = "sha2" version = "0.10.9" @@ -1019,47 +987,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "toml" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.22.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime", - "toml_write", - "winnow", -] - -[[package]] -name = "toml_write" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" - [[package]] name = "tracing" version = "0.1.41" @@ -1407,15 +1334,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "0.7.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" -dependencies = [ - "memchr", -] - [[package]] name = "wit-bindgen-rt" version = "0.33.0" diff --git a/crates/cargo-wdk/Cargo.toml b/crates/cargo-wdk/Cargo.toml index 842ec0e3f..059bbe34c 100644 --- a/crates/cargo-wdk/Cargo.toml +++ b/crates/cargo-wdk/Cargo.toml @@ -32,7 +32,6 @@ assert_fs.workspace = true predicates.workspace = true regex.workspace = true sha2.workspace = true -toml = "0.8" [lints.rust] missing_docs = "warn" From 5d31951bb9dd894773010829089652b8540833de Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 11:07:27 +0000 Subject: [PATCH 6/9] Read versions from workspace dependencies instead of package sections 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> --- .github/scripts/check-template-versions.ps1 | 64 ++++++++++----------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/.github/scripts/check-template-versions.ps1 b/.github/scripts/check-template-versions.ps1 index f83f221cd..4358576b8 100644 --- a/.github/scripts/check-template-versions.ps1 +++ b/.github/scripts/check-template-versions.ps1 @@ -3,30 +3,42 @@ # License: MIT OR Apache-2.0 # This script verifies that the cargo-wdk template Cargo.toml files use the correct -# versions of WDK crates by reading from each crate's [package] section. +# versions of WDK crates by reading from the workspace Cargo.toml [workspace.dependencies] section. $ErrorActionPreference = "Stop" -# Function to extract version from a Cargo.toml [package] section -function Get-PackageVersion { +# Function to extract versions from workspace Cargo.toml [workspace.dependencies] section +function Get-WorkspaceDependencyVersions { param ( - [string]$CargoTomlPath + [string]$WorkspaceCargoToml = "Cargo.toml" ) - if (-not (Test-Path $CargoTomlPath)) { - Write-Error "Cargo.toml not found at: $CargoTomlPath" + if (-not (Test-Path $WorkspaceCargoToml)) { + Write-Error "Workspace Cargo.toml not found at: $WorkspaceCargoToml" exit 1 } - $content = Get-Content $CargoTomlPath -Raw + $content = Get-Content $WorkspaceCargoToml -Raw + $versions = @{} - # Match version in [package] section - if ($content -match '(?ms)\[package\].*?version\s*=\s*"([^"]+)"') { - return $Matches[1] + # Match versions in [workspace.dependencies] section + # Pattern matches: wdk = { path = "...", version = "0.4.0" } + # or: wdk-alloc = { path = "...", version = "0.4.0" } + $pattern = '(wdk[a-z-]*)\s*=\s*\{[^}]*version\s*=\s*"([^"]+)"' + $matches = [regex]::Matches($content, $pattern) + + foreach ($match in $matches) { + $depName = $match.Groups[1].Value + $depVersion = $match.Groups[2].Value + $versions[$depName] = $depVersion } - Write-Error "Could not find version in [package] section of $CargoTomlPath" - exit 1 + if ($versions.Count -eq 0) { + Write-Error "Could not find any wdk dependency versions in [workspace.dependencies] section" + exit 1 + } + + return $versions } # Function to extract dependency versions from a template file @@ -56,31 +68,17 @@ function Get-TemplateDependencies { return $dependencies } -Write-Host "Checking template versions against crate package versions..." -ForegroundColor Cyan +Write-Host "Checking template versions against workspace dependency versions..." -ForegroundColor Cyan -# Get actual crate versions from [package] sections -$wdkVersion = Get-PackageVersion "crates/wdk/Cargo.toml" -$wdkAllocVersion = Get-PackageVersion "crates/wdk-alloc/Cargo.toml" -$wdkBuildVersion = Get-PackageVersion "crates/wdk-build/Cargo.toml" -$wdkPanicVersion = Get-PackageVersion "crates/wdk-panic/Cargo.toml" -$wdkSysVersion = Get-PackageVersion "crates/wdk-sys/Cargo.toml" +# Get versions from workspace [workspace.dependencies] section +$expectedVersions = Get-WorkspaceDependencyVersions Write-Host "" -Write-Host "Current crate versions:" -ForegroundColor Green -Write-Host " wdk: $wdkVersion" -Write-Host " wdk-alloc: $wdkAllocVersion" -Write-Host " wdk-build: $wdkBuildVersion" -Write-Host " wdk-panic: $wdkPanicVersion" -Write-Host " wdk-sys: $wdkSysVersion" -Write-Host "" - -$expectedVersions = @{ - "wdk" = $wdkVersion - "wdk-alloc" = $wdkAllocVersion - "wdk-build" = $wdkBuildVersion - "wdk-panic" = $wdkPanicVersion - "wdk-sys" = $wdkSysVersion +Write-Host "Workspace dependency versions:" -ForegroundColor Green +foreach ($dep in $expectedVersions.Keys | Sort-Object) { + Write-Host " $dep : $($expectedVersions[$dep])" } +Write-Host "" $templates = @( @{ From ab53273e5e2a76c56c91d8113eaed4fbdf989a76 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 06:16:35 +0000 Subject: [PATCH 7/9] Migrate template version checks to version-checks.yaml workflow - 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> --- .github/scripts/check-template-versions.ps1 | 137 -------------- .github/workflows/template-version-check.yaml | 27 --- .github/workflows/version-checks.yaml | 171 ++++++++++++++++++ 3 files changed, 171 insertions(+), 164 deletions(-) delete mode 100644 .github/scripts/check-template-versions.ps1 delete mode 100644 .github/workflows/template-version-check.yaml diff --git a/.github/scripts/check-template-versions.ps1 b/.github/scripts/check-template-versions.ps1 deleted file mode 100644 index 4358576b8..000000000 --- a/.github/scripts/check-template-versions.ps1 +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/env pwsh -# Copyright (c) Microsoft Corporation -# License: MIT OR Apache-2.0 - -# This script verifies that the cargo-wdk template Cargo.toml files use the correct -# versions of WDK crates by reading from the workspace Cargo.toml [workspace.dependencies] section. - -$ErrorActionPreference = "Stop" - -# Function to extract versions from workspace Cargo.toml [workspace.dependencies] section -function Get-WorkspaceDependencyVersions { - param ( - [string]$WorkspaceCargoToml = "Cargo.toml" - ) - - if (-not (Test-Path $WorkspaceCargoToml)) { - Write-Error "Workspace Cargo.toml not found at: $WorkspaceCargoToml" - exit 1 - } - - $content = Get-Content $WorkspaceCargoToml -Raw - $versions = @{} - - # Match versions in [workspace.dependencies] section - # Pattern matches: wdk = { path = "...", version = "0.4.0" } - # or: wdk-alloc = { path = "...", version = "0.4.0" } - $pattern = '(wdk[a-z-]*)\s*=\s*\{[^}]*version\s*=\s*"([^"]+)"' - $matches = [regex]::Matches($content, $pattern) - - foreach ($match in $matches) { - $depName = $match.Groups[1].Value - $depVersion = $match.Groups[2].Value - $versions[$depName] = $depVersion - } - - if ($versions.Count -eq 0) { - Write-Error "Could not find any wdk dependency versions in [workspace.dependencies] section" - exit 1 - } - - return $versions -} - -# Function to extract dependency versions from a template file -function Get-TemplateDependencies { - param ( - [string]$TemplatePath - ) - - if (-not (Test-Path $TemplatePath)) { - Write-Error "Template not found at: $TemplatePath" - exit 1 - } - - $content = Get-Content $TemplatePath -Raw - $dependencies = @{} - - # Extract wdk-* dependencies and their versions - $pattern = '(wdk[a-z-]*)\s*=\s*"([^"]+)"' - $matches = [regex]::Matches($content, $pattern) - - foreach ($match in $matches) { - $depName = $match.Groups[1].Value - $depVersion = $match.Groups[2].Value - $dependencies[$depName] = $depVersion - } - - return $dependencies -} - -Write-Host "Checking template versions against workspace dependency versions..." -ForegroundColor Cyan - -# Get versions from workspace [workspace.dependencies] section -$expectedVersions = Get-WorkspaceDependencyVersions - -Write-Host "" -Write-Host "Workspace dependency versions:" -ForegroundColor Green -foreach ($dep in $expectedVersions.Keys | Sort-Object) { - Write-Host " $dep : $($expectedVersions[$dep])" -} -Write-Host "" - -$templates = @( - @{ - Name = "KMDF" - Path = "crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp" - ExpectedDeps = @("wdk", "wdk-alloc", "wdk-build", "wdk-panic", "wdk-sys") - }, - @{ - Name = "UMDF" - Path = "crates/cargo-wdk/templates/umdf/Cargo.toml.tmp" - ExpectedDeps = @("wdk", "wdk-build", "wdk-sys") - }, - @{ - Name = "WDM" - Path = "crates/cargo-wdk/templates/wdm/Cargo.toml.tmp" - ExpectedDeps = @("wdk", "wdk-alloc", "wdk-build", "wdk-panic", "wdk-sys") - } -) - -$hasErrors = $false - -foreach ($template in $templates) { - Write-Host "Checking $($template.Name) template..." -ForegroundColor Cyan - - $templateDeps = Get-TemplateDependencies $template.Path - - foreach ($depName in $template.ExpectedDeps) { - if (-not $templateDeps.ContainsKey($depName)) { - Write-Host " ERROR: $depName is missing from template" -ForegroundColor Red - $hasErrors = $true - continue - } - - $templateVersion = $templateDeps[$depName] - $expectedVersion = $expectedVersions[$depName] - - if ($templateVersion -ne $expectedVersion) { - Write-Host " ERROR: $depName version mismatch" -ForegroundColor Red - Write-Host " Template has: $templateVersion" -ForegroundColor Red - Write-Host " Expected: $expectedVersion" -ForegroundColor Red - $hasErrors = $true - } else { - Write-Host " OK: $depName = $templateVersion" -ForegroundColor Green - } - } - - Write-Host "" -} - -if ($hasErrors) { - Write-Host "Template version check FAILED!" -ForegroundColor Red - exit 1 -} else { - Write-Host "All template versions are correct!" -ForegroundColor Green - exit 0 -} diff --git a/.github/workflows/template-version-check.yaml b/.github/workflows/template-version-check.yaml deleted file mode 100644 index 44bb96917..000000000 --- a/.github/workflows/template-version-check.yaml +++ /dev/null @@ -1,27 +0,0 @@ -name: Template Version Check - -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 * * * - -concurrency: - group: ${{ github.workflow }}-${{ github.event.compare || github.head_ref || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} - -jobs: - check-template-versions: - name: Check Template Versions - runs-on: windows-2025 - - steps: - - name: Checkout Repository - uses: actions/checkout@v5 - - - name: Run Template Version Check - shell: pwsh - run: .github/scripts/check-template-versions.ps1 diff --git a/.github/workflows/version-checks.yaml b/.github/workflows/version-checks.yaml index e2e5cfdd2..c1af3519b 100644 --- a/.github/workflows/version-checks.yaml +++ b/.github/workflows/version-checks.yaml @@ -53,3 +53,174 @@ jobs: file2-version-regex: '^version\s*=\s*"\K[^"]+' file2-version-label: "wdk-sys crate version" error-message: "The workspace dependency must use an exact version constraint of wdk-macros which matches wdk-sys to enforce lockstep versioning" + + # Template version checks - ensure templates use latest workspace versions + + - name: Check KMDF template wdk version + uses: ./.github/actions/compare-regex-versions + with: + file1: crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp + file1-label: "KMDF template" + file1-version-regex: '^wdk\s*=\s*"\K[^"]+' + file1-version-label: "wdk version in KMDF template" + file2: Cargo.toml + file2-label: "workspace Cargo.toml" + file2-version-regex: '^wdk\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' + file2-version-label: "wdk workspace dependency version" + error-message: "KMDF template must use the same wdk version as defined in workspace dependencies." + + - name: Check KMDF template wdk-build version + uses: ./.github/actions/compare-regex-versions + with: + file1: crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp + file1-label: "KMDF template" + file1-version-regex: '^wdk-build\s*=\s*"\K[^"]+' + file1-version-label: "wdk-build version in KMDF template" + file2: Cargo.toml + file2-label: "workspace Cargo.toml" + file2-version-regex: '^wdk-build\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' + file2-version-label: "wdk-build workspace dependency version" + error-message: "KMDF template must use the same wdk-build version as defined in workspace dependencies." + + - name: Check KMDF template wdk-alloc version + uses: ./.github/actions/compare-regex-versions + with: + file1: crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp + file1-label: "KMDF template" + file1-version-regex: '^wdk-alloc\s*=\s*"\K[^"]+' + file1-version-label: "wdk-alloc version in KMDF template" + file2: Cargo.toml + file2-label: "workspace Cargo.toml" + file2-version-regex: '^wdk-alloc\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' + file2-version-label: "wdk-alloc workspace dependency version" + error-message: "KMDF template must use the same wdk-alloc version as defined in workspace dependencies." + + - name: Check KMDF template wdk-panic version + uses: ./.github/actions/compare-regex-versions + with: + file1: crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp + file1-label: "KMDF template" + file1-version-regex: '^wdk-panic\s*=\s*"\K[^"]+' + file1-version-label: "wdk-panic version in KMDF template" + file2: Cargo.toml + file2-label: "workspace Cargo.toml" + file2-version-regex: '^wdk-panic\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' + file2-version-label: "wdk-panic workspace dependency version" + error-message: "KMDF template must use the same wdk-panic version as defined in workspace dependencies." + + - name: Check KMDF template wdk-sys version + uses: ./.github/actions/compare-regex-versions + with: + file1: crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp + file1-label: "KMDF template" + file1-version-regex: '^wdk-sys\s*=\s*"\K[^"]+' + file1-version-label: "wdk-sys version in KMDF template" + file2: Cargo.toml + file2-label: "workspace Cargo.toml" + file2-version-regex: '^wdk-sys\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' + file2-version-label: "wdk-sys workspace dependency version" + error-message: "KMDF template must use the same wdk-sys version as defined in workspace dependencies." + + - name: Check UMDF template wdk version + uses: ./.github/actions/compare-regex-versions + with: + file1: crates/cargo-wdk/templates/umdf/Cargo.toml.tmp + file1-label: "UMDF template" + file1-version-regex: '^wdk\s*=\s*"\K[^"]+' + file1-version-label: "wdk version in UMDF template" + file2: Cargo.toml + file2-label: "workspace Cargo.toml" + file2-version-regex: '^wdk\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' + file2-version-label: "wdk workspace dependency version" + error-message: "UMDF template must use the same wdk version as defined in workspace dependencies." + + - name: Check UMDF template wdk-build version + uses: ./.github/actions/compare-regex-versions + with: + file1: crates/cargo-wdk/templates/umdf/Cargo.toml.tmp + file1-label: "UMDF template" + file1-version-regex: '^wdk-build\s*=\s*"\K[^"]+' + file1-version-label: "wdk-build version in UMDF template" + file2: Cargo.toml + file2-label: "workspace Cargo.toml" + file2-version-regex: '^wdk-build\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' + file2-version-label: "wdk-build workspace dependency version" + error-message: "UMDF template must use the same wdk-build version as defined in workspace dependencies." + + - name: Check UMDF template wdk-sys version + uses: ./.github/actions/compare-regex-versions + with: + file1: crates/cargo-wdk/templates/umdf/Cargo.toml.tmp + file1-label: "UMDF template" + file1-version-regex: '^wdk-sys\s*=\s*"\K[^"]+' + file1-version-label: "wdk-sys version in UMDF template" + file2: Cargo.toml + file2-label: "workspace Cargo.toml" + file2-version-regex: '^wdk-sys\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' + file2-version-label: "wdk-sys workspace dependency version" + error-message: "UMDF template must use the same wdk-sys version as defined in workspace dependencies." + + - name: Check WDM template wdk version + uses: ./.github/actions/compare-regex-versions + with: + file1: crates/cargo-wdk/templates/wdm/Cargo.toml.tmp + file1-label: "WDM template" + file1-version-regex: '^wdk\s*=\s*"\K[^"]+' + file1-version-label: "wdk version in WDM template" + file2: Cargo.toml + file2-label: "workspace Cargo.toml" + file2-version-regex: '^wdk\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' + file2-version-label: "wdk workspace dependency version" + error-message: "WDM template must use the same wdk version as defined in workspace dependencies." + + - name: Check WDM template wdk-build version + uses: ./.github/actions/compare-regex-versions + with: + file1: crates/cargo-wdk/templates/wdm/Cargo.toml.tmp + file1-label: "WDM template" + file1-version-regex: '^wdk-build\s*=\s*"\K[^"]+' + file1-version-label: "wdk-build version in WDM template" + file2: Cargo.toml + file2-label: "workspace Cargo.toml" + file2-version-regex: '^wdk-build\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' + file2-version-label: "wdk-build workspace dependency version" + error-message: "WDM template must use the same wdk-build version as defined in workspace dependencies." + + - name: Check WDM template wdk-alloc version + uses: ./.github/actions/compare-regex-versions + with: + file1: crates/cargo-wdk/templates/wdm/Cargo.toml.tmp + file1-label: "WDM template" + file1-version-regex: '^wdk-alloc\s*=\s*"\K[^"]+' + file1-version-label: "wdk-alloc version in WDM template" + file2: Cargo.toml + file2-label: "workspace Cargo.toml" + file2-version-regex: '^wdk-alloc\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' + file2-version-label: "wdk-alloc workspace dependency version" + error-message: "WDM template must use the same wdk-alloc version as defined in workspace dependencies." + + - name: Check WDM template wdk-panic version + uses: ./.github/actions/compare-regex-versions + with: + file1: crates/cargo-wdk/templates/wdm/Cargo.toml.tmp + file1-label: "WDM template" + file1-version-regex: '^wdk-panic\s*=\s*"\K[^"]+' + file1-version-label: "wdk-panic version in WDM template" + file2: Cargo.toml + file2-label: "workspace Cargo.toml" + file2-version-regex: '^wdk-panic\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' + file2-version-label: "wdk-panic workspace dependency version" + error-message: "WDM template must use the same wdk-panic version as defined in workspace dependencies." + + - name: Check WDM template wdk-sys version + uses: ./.github/actions/compare-regex-versions + with: + file1: crates/cargo-wdk/templates/wdm/Cargo.toml.tmp + file1-label: "WDM template" + file1-version-regex: '^wdk-sys\s*=\s*"\K[^"]+' + file1-version-label: "wdk-sys version in WDM template" + file2: Cargo.toml + file2-label: "workspace Cargo.toml" + file2-version-regex: '^wdk-sys\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' + file2-version-label: "wdk-sys workspace dependency version" + error-message: "WDM template must use the same wdk-sys version as defined in workspace dependencies." From f25e3b560b5241e4d008f99cdb89ffffee0a1b06 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 09:07:31 +0000 Subject: [PATCH 8/9] Remove blank line and simplify template version checks - 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> --- .github/workflows/version-checks.yaml | 40 --------------------------- 1 file changed, 40 deletions(-) diff --git a/.github/workflows/version-checks.yaml b/.github/workflows/version-checks.yaml index c1af3519b..2438db688 100644 --- a/.github/workflows/version-checks.yaml +++ b/.github/workflows/version-checks.yaml @@ -55,172 +55,132 @@ jobs: error-message: "The workspace dependency must use an exact version constraint of wdk-macros which matches wdk-sys to enforce lockstep versioning" # Template version checks - ensure templates use latest workspace versions - - name: Check KMDF template wdk version uses: ./.github/actions/compare-regex-versions with: file1: crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp - file1-label: "KMDF template" file1-version-regex: '^wdk\s*=\s*"\K[^"]+' file1-version-label: "wdk version in KMDF template" file2: Cargo.toml - file2-label: "workspace Cargo.toml" file2-version-regex: '^wdk\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' file2-version-label: "wdk workspace dependency version" - error-message: "KMDF template must use the same wdk version as defined in workspace dependencies." - name: Check KMDF template wdk-build version uses: ./.github/actions/compare-regex-versions with: file1: crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp - file1-label: "KMDF template" file1-version-regex: '^wdk-build\s*=\s*"\K[^"]+' file1-version-label: "wdk-build version in KMDF template" file2: Cargo.toml - file2-label: "workspace Cargo.toml" file2-version-regex: '^wdk-build\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' file2-version-label: "wdk-build workspace dependency version" - error-message: "KMDF template must use the same wdk-build version as defined in workspace dependencies." - name: Check KMDF template wdk-alloc version uses: ./.github/actions/compare-regex-versions with: file1: crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp - file1-label: "KMDF template" file1-version-regex: '^wdk-alloc\s*=\s*"\K[^"]+' file1-version-label: "wdk-alloc version in KMDF template" file2: Cargo.toml - file2-label: "workspace Cargo.toml" file2-version-regex: '^wdk-alloc\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' file2-version-label: "wdk-alloc workspace dependency version" - error-message: "KMDF template must use the same wdk-alloc version as defined in workspace dependencies." - name: Check KMDF template wdk-panic version uses: ./.github/actions/compare-regex-versions with: file1: crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp - file1-label: "KMDF template" file1-version-regex: '^wdk-panic\s*=\s*"\K[^"]+' file1-version-label: "wdk-panic version in KMDF template" file2: Cargo.toml - file2-label: "workspace Cargo.toml" file2-version-regex: '^wdk-panic\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' file2-version-label: "wdk-panic workspace dependency version" - error-message: "KMDF template must use the same wdk-panic version as defined in workspace dependencies." - name: Check KMDF template wdk-sys version uses: ./.github/actions/compare-regex-versions with: file1: crates/cargo-wdk/templates/kmdf/Cargo.toml.tmp - file1-label: "KMDF template" file1-version-regex: '^wdk-sys\s*=\s*"\K[^"]+' file1-version-label: "wdk-sys version in KMDF template" file2: Cargo.toml - file2-label: "workspace Cargo.toml" file2-version-regex: '^wdk-sys\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' file2-version-label: "wdk-sys workspace dependency version" - error-message: "KMDF template must use the same wdk-sys version as defined in workspace dependencies." - name: Check UMDF template wdk version uses: ./.github/actions/compare-regex-versions with: file1: crates/cargo-wdk/templates/umdf/Cargo.toml.tmp - file1-label: "UMDF template" file1-version-regex: '^wdk\s*=\s*"\K[^"]+' file1-version-label: "wdk version in UMDF template" file2: Cargo.toml - file2-label: "workspace Cargo.toml" file2-version-regex: '^wdk\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' file2-version-label: "wdk workspace dependency version" - error-message: "UMDF template must use the same wdk version as defined in workspace dependencies." - name: Check UMDF template wdk-build version uses: ./.github/actions/compare-regex-versions with: file1: crates/cargo-wdk/templates/umdf/Cargo.toml.tmp - file1-label: "UMDF template" file1-version-regex: '^wdk-build\s*=\s*"\K[^"]+' file1-version-label: "wdk-build version in UMDF template" file2: Cargo.toml - file2-label: "workspace Cargo.toml" file2-version-regex: '^wdk-build\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' file2-version-label: "wdk-build workspace dependency version" - error-message: "UMDF template must use the same wdk-build version as defined in workspace dependencies." - name: Check UMDF template wdk-sys version uses: ./.github/actions/compare-regex-versions with: file1: crates/cargo-wdk/templates/umdf/Cargo.toml.tmp - file1-label: "UMDF template" file1-version-regex: '^wdk-sys\s*=\s*"\K[^"]+' file1-version-label: "wdk-sys version in UMDF template" file2: Cargo.toml - file2-label: "workspace Cargo.toml" file2-version-regex: '^wdk-sys\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' file2-version-label: "wdk-sys workspace dependency version" - error-message: "UMDF template must use the same wdk-sys version as defined in workspace dependencies." - name: Check WDM template wdk version uses: ./.github/actions/compare-regex-versions with: file1: crates/cargo-wdk/templates/wdm/Cargo.toml.tmp - file1-label: "WDM template" file1-version-regex: '^wdk\s*=\s*"\K[^"]+' file1-version-label: "wdk version in WDM template" file2: Cargo.toml - file2-label: "workspace Cargo.toml" file2-version-regex: '^wdk\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' file2-version-label: "wdk workspace dependency version" - error-message: "WDM template must use the same wdk version as defined in workspace dependencies." - name: Check WDM template wdk-build version uses: ./.github/actions/compare-regex-versions with: file1: crates/cargo-wdk/templates/wdm/Cargo.toml.tmp - file1-label: "WDM template" file1-version-regex: '^wdk-build\s*=\s*"\K[^"]+' file1-version-label: "wdk-build version in WDM template" file2: Cargo.toml - file2-label: "workspace Cargo.toml" file2-version-regex: '^wdk-build\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' file2-version-label: "wdk-build workspace dependency version" - error-message: "WDM template must use the same wdk-build version as defined in workspace dependencies." - name: Check WDM template wdk-alloc version uses: ./.github/actions/compare-regex-versions with: file1: crates/cargo-wdk/templates/wdm/Cargo.toml.tmp - file1-label: "WDM template" file1-version-regex: '^wdk-alloc\s*=\s*"\K[^"]+' file1-version-label: "wdk-alloc version in WDM template" file2: Cargo.toml - file2-label: "workspace Cargo.toml" file2-version-regex: '^wdk-alloc\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' file2-version-label: "wdk-alloc workspace dependency version" - error-message: "WDM template must use the same wdk-alloc version as defined in workspace dependencies." - name: Check WDM template wdk-panic version uses: ./.github/actions/compare-regex-versions with: file1: crates/cargo-wdk/templates/wdm/Cargo.toml.tmp - file1-label: "WDM template" file1-version-regex: '^wdk-panic\s*=\s*"\K[^"]+' file1-version-label: "wdk-panic version in WDM template" file2: Cargo.toml - file2-label: "workspace Cargo.toml" file2-version-regex: '^wdk-panic\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' file2-version-label: "wdk-panic workspace dependency version" - error-message: "WDM template must use the same wdk-panic version as defined in workspace dependencies." - name: Check WDM template wdk-sys version uses: ./.github/actions/compare-regex-versions with: file1: crates/cargo-wdk/templates/wdm/Cargo.toml.tmp - file1-label: "WDM template" file1-version-regex: '^wdk-sys\s*=\s*"\K[^"]+' file1-version-label: "wdk-sys version in WDM template" file2: Cargo.toml - file2-label: "workspace Cargo.toml" file2-version-regex: '^wdk-sys\s*=\s*\{[^}]*version\s*=\s*"\K[^"]+' file2-version-label: "wdk-sys workspace dependency version" - error-message: "WDM template must use the same wdk-sys version as defined in workspace dependencies." From d3887672e654210ff7912b6e8f8294ea365e29fc Mon Sep 17 00:00:00 2001 From: Gurinder Singh Date: Wed, 12 Nov 2025 14:54:23 +0530 Subject: [PATCH 9/9] Update .github/workflows/version-checks.yaml Signed-off-by: Gurinder Singh --- .github/workflows/version-checks.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/version-checks.yaml b/.github/workflows/version-checks.yaml index 2438db688..995924aff 100644 --- a/.github/workflows/version-checks.yaml +++ b/.github/workflows/version-checks.yaml @@ -54,7 +54,8 @@ jobs: file2-version-label: "wdk-sys crate version" error-message: "The workspace dependency must use an exact version constraint of wdk-macros which matches wdk-sys to enforce lockstep versioning" - # Template version checks - ensure templates use latest workspace versions + # Template version checks - ensure cargo-wdk templates use latest dep + # versions by comparing them against those in the workspace's Cargo.toml file - name: Check KMDF template wdk version uses: ./.github/actions/compare-regex-versions with: