From ee16cc89f30a08a117d4fcc35d3e1c1a715c4877 Mon Sep 17 00:00:00 2001 From: Melvin Wang Date: Sun, 9 Nov 2025 20:16:32 -0800 Subject: [PATCH 1/8] ci: leverage winget & llvm actions from windows-drivers-rs repo --- .github/actions/winget-install/action.yml | 56 ----------------------- .github/workflows/build.yaml | 25 ++++------ .github/workflows/docs.yaml | 25 ++++------ .github/workflows/lint.yaml | 39 ++++++---------- 4 files changed, 29 insertions(+), 116 deletions(-) delete mode 100644 .github/actions/winget-install/action.yml diff --git a/.github/actions/winget-install/action.yml b/.github/actions/winget-install/action.yml deleted file mode 100644 index a10a986..0000000 --- a/.github/actions/winget-install/action.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: "Install Winget" -description: "Install winget on windows runners since its not installed by default: https://github.com/actions/runner-images/issues/6472" -inputs: - GITHUB_TOKEN: - description: "GitHub token to execute authenticated Github API requests (for higher rate limit)" - required: true -runs: - using: "composite" - steps: - - name: Get URIs for Winget v1.8.1911 assets - shell: pwsh - run: | - $AuthenticatedHeaders = @{ "Authorization" = "Bearer ${{ inputs.GITHUB_TOKEN }}" } - - $ReleaseInfo = Invoke-RestMethod -Headers $AuthenticatedHeaders 'https://api.github.com/repos/microsoft/winget-cli/releases/164835566' - $WingetDownloadUri = $ReleaseInfo.assets.browser_download_url | Where-Object { $_.EndsWith('.msixbundle') } - $WingetLicenseDownloadUri = $ReleaseInfo.assets.browser_download_url | Where-Object { $_.EndsWith('License1.xml') } - - # Print to logs - Write-Host "WingetDownloadUri=$WingetDownloadUri" - Write-Host "WingetLicenseDownloadUri=$WingetLicenseDownloadUri" - - # Save output for next step - Write-Output "WingetDownloadUri=$WingetDownloadUri" >> $env:GITHUB_ENV - Write-Output "WingetLicenseDownloadUri=$WingetLicenseDownloadUri" >> $env:GITHUB_ENV - - - name: Download Winget Assets and Dependencies - shell: pwsh - run: | - New-Item -Type Directory $env:RUNNER_TEMP/winget-install - Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -OutFile $env:RUNNER_TEMP/winget-install/Microsoft.UI.Xaml.2.8.x64.appx - Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile $env:RUNNER_TEMP/winget-install/Microsoft.VCLibs.x64.14.00.Desktop.appx # Needed per https://github.com/microsoft/winget-cli/blob/21de1607ed5c90174e6bb931406975c18681a5dd/README.md?plain=1#L35C19-L35C19 - Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri $env:WingetDownloadUri -OutFile $env:RUNNER_TEMP/winget-install/winget.msixbundle - Invoke-WebRequest -Headers $AuthenticatedHeaders -Uri $env:WingetLicenseDownloadUri -OutFile $env:RUNNER_TEMP/winget-install/license.xml - - - name: Start Winget Installation for all Users - shell: pwsh - run: | - Add-AppxProvisionedPackage -Online -PackagePath $env:RUNNER_TEMP/winget-install/winget.msixbundle -LicensePath $env:RUNNER_TEMP/winget-install/license.xml -DependencyPackagePath $env:RUNNER_TEMP/winget-install/Microsoft.UI.Xaml.2.8.x64.appx, $env:RUNNER_TEMP/winget-install/Microsoft.VCLibs.x64.14.00.Desktop.appx - - - name: Install Winget for Current User (for better install diagnostics) - shell: powershell - run: | - Add-AppxPackage $env:RUNNER_TEMP/winget-install/winget.msixbundle - - - name: Wait for Completion of Winget Installation - shell: pwsh - run: | - while ((Get-Command * | Select-String winget)?.ToString() -ne "winget.exe") { - Start-Sleep -Seconds 1 - } - Write-Output "Winget Version: $(winget --version)" - - - name: Install winget Powershell Module - shell: pwsh - run: Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -Force diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a97c3a7..7cbb325 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -45,29 +45,20 @@ jobs: uses: actions/checkout@v4 - name: Install Winget - uses: ./.github/actions/winget-install + uses: microsoft/windows-drivers-rs/.github/actions/install-winget@main with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install LLVM ${{ matrix.llvm }} - run: | - if ((Get-WinGetPackage -Id LLVM -Source winget -MatchOption Equals).InstalledVersion -eq '${{ matrix.llvm }}') { - Write-Host "LLVM ${{ matrix.llvm }} is already installed." - } else { - Write-Host "Installing LLVM ${{ matrix.llvm }}..." - Install-WinGetPackage -Id LLVM.LLVM -Version ${{ matrix.llvm }} -Source winget -MatchOption Equals -Mode Silent -Force - } - clang --version + uses: microsoft/windows-drivers-rs/.github/actions/install-llvm@main + with: + version: ${{ matrix.llvm }} - name: Install WDK (${{ matrix.wdk }}) - run: | - if ((Get-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals).Id -eq '${{ matrix.wdk }}') { - Write-Host "${{ matrix.wdk }} is already installed. Attempting to update..." - Update-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force - } else { - Write-Host "Installing ${{ matrix.wdk }}..." - Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force - } + uses: microsoft/windows-drivers-rs/.github/actions/install-wdk@main + with: + version: ${{ matrix.wdk }} + source: winget - name: Install Rust Toolchain (${{ matrix.rust_toolchain }}) uses: dtolnay/rust-toolchain@master diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 56f9412..48c2a88 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -40,29 +40,20 @@ jobs: uses: actions/checkout@v4 - name: Install Winget - uses: ./.github/actions/winget-install + uses: microsoft/windows-drivers-rs/.github/actions/install-winget@main with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install LLVM ${{ matrix.llvm }} - run: | - if ((Get-WinGetPackage -Id LLVM -Source winget -MatchOption Equals).InstalledVersion -eq '${{ matrix.llvm }}') { - Write-Host "LLVM ${{ matrix.llvm }} is already installed." - } else { - Write-Host "Installing LLVM ${{ matrix.llvm }}..." - Install-WinGetPackage -Id LLVM.LLVM -Version ${{ matrix.llvm }} -Source winget -MatchOption Equals -Mode Silent -Force - } - clang --version + uses: microsoft/windows-drivers-rs/.github/actions/install-llvm@main + with: + version: ${{ matrix.llvm }} - name: Install WDK (${{ matrix.wdk }}) - run: | - if ((Get-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals).Id -eq '${{ matrix.wdk }}') { - Write-Host "${{ matrix.wdk }} is already installed. Attempting to update..." - Update-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force - } else { - Write-Host "Installing ${{ matrix.wdk }}..." - Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force - } + uses: microsoft/windows-drivers-rs/.github/actions/install-wdk@main + with: + version: ${{ matrix.wdk }} + source: winget - name: Install Rust Toolchain (${{ matrix.rust_toolchain }}) uses: dtolnay/rust-toolchain@master diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 9692d5e..d84bb9f 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -39,29 +39,20 @@ jobs: uses: actions/checkout@v4 - name: Install Winget - uses: ./.github/actions/winget-install + uses: microsoft/windows-drivers-rs/.github/actions/install-winget@main with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install LLVM ${{ matrix.llvm }} - run: | - if ((Get-WinGetPackage -Id LLVM -Source winget -MatchOption Equals).InstalledVersion -eq '${{ matrix.llvm }}') { - Write-Host "LLVM ${{ matrix.llvm }} is already installed." - } else { - Write-Host "Installing LLVM ${{ matrix.llvm }}..." - Install-WinGetPackage -Id LLVM.LLVM -Version ${{ matrix.llvm }} -Source winget -MatchOption Equals -Mode Silent -Force - } - clang --version + uses: microsoft/windows-drivers-rs/.github/actions/install-llvm@main + with: + version: ${{ matrix.llvm }} - name: Install WDK (${{ matrix.wdk }}) - run: | - if ((Get-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals).Id -eq '${{ matrix.wdk }}') { - Write-Host "${{ matrix.wdk }} is already installed. Attempting to update..." - Update-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force - } else { - Write-Host "Installing ${{ matrix.wdk }}..." - Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force - } + uses: microsoft/windows-drivers-rs/.github/actions/install-wdk@main + with: + version: ${{ matrix.wdk }} + source: winget - name: Install Rust Toolchain (${{ matrix.rust_toolchain }}) uses: dtolnay/rust-toolchain@master @@ -90,19 +81,15 @@ jobs: uses: actions/checkout@v4 - name: Install Winget - uses: ./.github/actions/winget-install + uses: microsoft/windows-drivers-rs/.github/actions/install-winget@main with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install WDK (${{ matrix.wdk }}) - run: | - if ((Get-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals).Id -eq '${{ matrix.wdk }}') { - Write-Host "${{ matrix.wdk }} is already installed. Attempting to update..." - Update-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force - } else { - Write-Host "Installing ${{ matrix.wdk }}..." - Install-WinGetPackage -Id ${{ matrix.wdk }} -Source winget -MatchOption Equals -Mode Silent -Force - } + uses: microsoft/windows-drivers-rs/.github/actions/install-wdk@main + with: + version: ${{ matrix.wdk }} + source: winget - name: Install Rust Toolchain uses: dtolnay/rust-toolchain@stable From 03e114a702caef5e0c5faa9f44e2672ee74ad5bd Mon Sep 17 00:00:00 2001 From: Melvin Wang Date: Mon, 17 Nov 2025 16:36:21 -0800 Subject: [PATCH 2/8] ci: update workflows to checkout windows-drivers-rs and use local action paths --- .github/workflows/build.yaml | 17 ++++++++++++++--- .github/workflows/docs.yaml | 17 ++++++++++++++--- .github/workflows/lint.yaml | 32 +++++++++++++++++++++++++++----- 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7cbb325..5839429 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -44,18 +44,29 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 + - name: Checkout windows-drivers-rs + uses: actions/checkout@v4 + with: + repository: microsoft/windows-drivers-rs + ref: main + path: windows-drivers-rs + - name: Install Winget - uses: microsoft/windows-drivers-rs/.github/actions/install-winget@main + uses: ./windows-drivers-rs/.github/actions/install-winget with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Install Winget PowerShell Module + shell: pwsh + run: Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -Force + - name: Install LLVM ${{ matrix.llvm }} - uses: microsoft/windows-drivers-rs/.github/actions/install-llvm@main + uses: ./windows-drivers-rs/.github/actions/install-llvm with: version: ${{ matrix.llvm }} - name: Install WDK (${{ matrix.wdk }}) - uses: microsoft/windows-drivers-rs/.github/actions/install-wdk@main + uses: ./windows-drivers-rs/.github/actions/install-wdk with: version: ${{ matrix.wdk }} source: winget diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 48c2a88..9379e00 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -39,18 +39,29 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 + - name: Checkout windows-drivers-rs + uses: actions/checkout@v4 + with: + repository: microsoft/windows-drivers-rs + ref: main + path: windows-drivers-rs + - name: Install Winget - uses: microsoft/windows-drivers-rs/.github/actions/install-winget@main + uses: ./windows-drivers-rs/.github/actions/install-winget with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Install Winget PowerShell Module + shell: pwsh + run: Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -Force + - name: Install LLVM ${{ matrix.llvm }} - uses: microsoft/windows-drivers-rs/.github/actions/install-llvm@main + uses: ./windows-drivers-rs/.github/actions/install-llvm with: version: ${{ matrix.llvm }} - name: Install WDK (${{ matrix.wdk }}) - uses: microsoft/windows-drivers-rs/.github/actions/install-wdk@main + uses: ./windows-drivers-rs/.github/actions/install-wdk with: version: ${{ matrix.wdk }} source: winget diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d84bb9f..b048bc4 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -38,18 +38,29 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 + - name: Checkout windows-drivers-rs + uses: actions/checkout@v4 + with: + repository: microsoft/windows-drivers-rs + ref: main + path: windows-drivers-rs + - name: Install Winget - uses: microsoft/windows-drivers-rs/.github/actions/install-winget@main + uses: ./windows-drivers-rs/.github/actions/install-winget with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Install Winget PowerShell Module + shell: pwsh + run: Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -Force + - name: Install LLVM ${{ matrix.llvm }} - uses: microsoft/windows-drivers-rs/.github/actions/install-llvm@main + uses: ./windows-drivers-rs/.github/actions/install-llvm with: version: ${{ matrix.llvm }} - name: Install WDK (${{ matrix.wdk }}) - uses: microsoft/windows-drivers-rs/.github/actions/install-wdk@main + uses: ./windows-drivers-rs/.github/actions/install-wdk with: version: ${{ matrix.wdk }} source: winget @@ -80,13 +91,24 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 + - name: Checkout windows-drivers-rs + uses: actions/checkout@v4 + with: + repository: microsoft/windows-drivers-rs + ref: main + path: windows-drivers-rs + - name: Install Winget - uses: microsoft/windows-drivers-rs/.github/actions/install-winget@main + uses: ./windows-drivers-rs/.github/actions/install-winget with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Install Winget PowerShell Module + shell: pwsh + run: Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -Force + - name: Install WDK (${{ matrix.wdk }}) - uses: microsoft/windows-drivers-rs/.github/actions/install-wdk@main + uses: ./windows-drivers-rs/.github/actions/install-wdk with: version: ${{ matrix.wdk }} source: winget From e9aa39507bb979e9262c5da59b4dd5280ade9a5a Mon Sep 17 00:00:00 2001 From: Melvin Wang Date: Mon, 17 Nov 2025 20:14:41 -0800 Subject: [PATCH 3/8] ci: update workflows to use windows-2025 and local action paths --- .github/workflows/build.yaml | 8 ++++---- .github/workflows/cargo-audit.yaml | 2 +- .github/workflows/code-formatting-check.yaml | 7 +++---- .github/workflows/docs.yaml | 4 ++-- .github/workflows/lint.yaml | 8 ++++---- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5839429..9fb4d5e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,7 +15,7 @@ env: jobs: build: name: Build - runs-on: windows-latest + runs-on: windows-2025 strategy: fail-fast: false # Allow all matrix variants to complete even if some fail matrix: @@ -52,7 +52,7 @@ jobs: path: windows-drivers-rs - name: Install Winget - uses: ./windows-drivers-rs/.github/actions/install-winget + uses: ./.github/actions/install-winget with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -61,12 +61,12 @@ jobs: run: Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -Force - name: Install LLVM ${{ matrix.llvm }} - uses: ./windows-drivers-rs/.github/actions/install-llvm + uses: ./.github/actions/install-llvm with: version: ${{ matrix.llvm }} - name: Install WDK (${{ matrix.wdk }}) - uses: ./windows-drivers-rs/.github/actions/install-wdk + uses: ./.github/actions/install-wdk with: version: ${{ matrix.wdk }} source: winget diff --git a/.github/workflows/cargo-audit.yaml b/.github/workflows/cargo-audit.yaml index 63e7ff0..f55691b 100644 --- a/.github/workflows/cargo-audit.yaml +++ b/.github/workflows/cargo-audit.yaml @@ -12,7 +12,7 @@ on: jobs: cargo_audit: name: Cargo Audit - runs-on: windows-latest + runs-on: windows-2025 permissions: issues: write checks: write diff --git a/.github/workflows/code-formatting-check.yaml b/.github/workflows/code-formatting-check.yaml index fe4ff92..2245b68 100644 --- a/.github/workflows/code-formatting-check.yaml +++ b/.github/workflows/code-formatting-check.yaml @@ -6,11 +6,10 @@ on: schedule: # Trigger a job on default branch at 4AM PST everyday - cron: 0 11 * * * - jobs: cargo-fmt: name: .rs Formatting Check - runs-on: windows-latest + runs-on: windows-2025 steps: - name: Checkout Repository @@ -18,7 +17,7 @@ jobs: - name: Install Rust Toolchain (Nightly) uses: dtolnay/rust-toolchain@nightly - with: + with: components: rustfmt - name: Run Cargo Format @@ -26,7 +25,7 @@ jobs: taplo-fmt: name: .toml Formatting Check - runs-on: windows-latest + runs-on: windows-2025 steps: - name: Checkout Repository diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 9379e00..f374a17 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -13,7 +13,7 @@ env: jobs: docs: name: Docs - runs-on: windows-latest + runs-on: windows-2025 strategy: matrix: wdk: @@ -47,7 +47,7 @@ jobs: path: windows-drivers-rs - name: Install Winget - uses: ./windows-drivers-rs/.github/actions/install-winget + uses: ./.github/actions/install-winget with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index b048bc4..2f4cfc9 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -10,7 +10,7 @@ name: Lint jobs: clippy: name: Clippy - runs-on: windows-latest + runs-on: windows-2025 permissions: checks: write strategy: @@ -46,7 +46,7 @@ jobs: path: windows-drivers-rs - name: Install Winget - uses: ./windows-drivers-rs/.github/actions/install-winget + uses: ./.github/actions/install-winget with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -81,7 +81,7 @@ jobs: machete: name: Detect Unused Cargo Dependencies - runs-on: windows-latest + runs-on: windows-2025 strategy: matrix: wdk: @@ -99,7 +99,7 @@ jobs: path: windows-drivers-rs - name: Install Winget - uses: ./windows-drivers-rs/.github/actions/install-winget + uses: ./.github/actions/install-winget with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 87939c6a16f98772921195fdf9439527db453a3c Mon Sep 17 00:00:00 2001 From: Melvin Wang Date: Mon, 17 Nov 2025 20:14:48 -0800 Subject: [PATCH 4/8] ci: update workflows to use sparse-checkout for windows-drivers-rs actions --- .github/workflows/build.yaml | 11 +++++++++-- .github/workflows/docs.yaml | 15 +++++++++++---- .github/workflows/lint.yaml | 17 ++++++++++++----- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9fb4d5e..b228a9f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -44,12 +44,19 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Checkout windows-drivers-rs + - name: Checkout windows-drivers-rs actions uses: actions/checkout@v4 with: repository: microsoft/windows-drivers-rs ref: main - path: windows-drivers-rs + path: _temp/windows-drivers-rs + sparse-checkout: | + .github/actions + sparse-checkout-cone-mode: false + + - name: Copy actions to workspace + shell: pwsh + run: Copy-Item -Recurse -Force _temp/windows-drivers-rs/.github/actions .github/ - name: Install Winget uses: ./.github/actions/install-winget diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index f374a17..13d3d0d 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -39,12 +39,19 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Checkout windows-drivers-rs + - name: Checkout windows-drivers-rs actions uses: actions/checkout@v4 with: repository: microsoft/windows-drivers-rs ref: main - path: windows-drivers-rs + path: _temp/windows-drivers-rs + sparse-checkout: | + .github/actions + sparse-checkout-cone-mode: false + + - name: Copy actions to workspace + shell: pwsh + run: Copy-Item -Recurse -Force _temp/windows-drivers-rs/.github/actions .github/ - name: Install Winget uses: ./.github/actions/install-winget @@ -56,12 +63,12 @@ jobs: run: Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -Force - name: Install LLVM ${{ matrix.llvm }} - uses: ./windows-drivers-rs/.github/actions/install-llvm + uses: ./.github/actions/install-llvm with: version: ${{ matrix.llvm }} - name: Install WDK (${{ matrix.wdk }}) - uses: ./windows-drivers-rs/.github/actions/install-wdk + uses: ./.github/actions/install-wdk with: version: ${{ matrix.wdk }} source: winget diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 2f4cfc9..4a0cc96 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -55,12 +55,12 @@ jobs: run: Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -Force - name: Install LLVM ${{ matrix.llvm }} - uses: ./windows-drivers-rs/.github/actions/install-llvm + uses: ./.github/actions/install-llvm with: version: ${{ matrix.llvm }} - name: Install WDK (${{ matrix.wdk }}) - uses: ./windows-drivers-rs/.github/actions/install-wdk + uses: ./.github/actions/install-wdk with: version: ${{ matrix.wdk }} source: winget @@ -91,12 +91,19 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Checkout windows-drivers-rs + - name: Checkout windows-drivers-rs actions uses: actions/checkout@v4 with: repository: microsoft/windows-drivers-rs ref: main - path: windows-drivers-rs + path: _temp/windows-drivers-rs + sparse-checkout: | + .github/actions + sparse-checkout-cone-mode: false + + - name: Copy actions to workspace + shell: pwsh + run: Copy-Item -Recurse -Force _temp/windows-drivers-rs/.github/actions .github/ - name: Install Winget uses: ./.github/actions/install-winget @@ -108,7 +115,7 @@ jobs: run: Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -Force - name: Install WDK (${{ matrix.wdk }}) - uses: ./windows-drivers-rs/.github/actions/install-wdk + uses: ./.github/actions/install-wdk with: version: ${{ matrix.wdk }} source: winget From 41b86b18ebf69c3b5654d3b4c5585b6032f7e714 Mon Sep 17 00:00:00 2001 From: Melvin Wang Date: Mon, 17 Nov 2025 21:06:14 -0800 Subject: [PATCH 5/8] ci: simplify WDK version specification and update sparse-checkout for actions --- .github/workflows/build.yaml | 2 +- .github/workflows/docs.yaml | 2 +- .github/workflows/lint.yaml | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b228a9f..5a01c1d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,7 +20,7 @@ jobs: fail-fast: false # Allow all matrix variants to complete even if some fail matrix: wdk: - - Microsoft.WindowsWDK.10.0.22621 # NI WDK + - 10.0.22621 # NI WDK llvm: - 17.0.6 diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 13d3d0d..4ddfded 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -17,7 +17,7 @@ jobs: strategy: matrix: wdk: - - Microsoft.WindowsWDK.10.0.22621 # NI WDK + - 10.0.22621 # NI WDK llvm: - 17.0.6 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 4a0cc96..e49d959 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -16,7 +16,7 @@ jobs: strategy: matrix: wdk: - - Microsoft.WindowsWDK.10.0.22621 # NI WDK + - 10.0.22621 # NI WDK llvm: - 17.0.6 @@ -38,12 +38,19 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Checkout windows-drivers-rs + - name: Checkout windows-drivers-rs actions uses: actions/checkout@v4 with: repository: microsoft/windows-drivers-rs ref: main - path: windows-drivers-rs + path: _temp/windows-drivers-rs + sparse-checkout: | + .github/actions + sparse-checkout-cone-mode: false + + - name: Copy actions to workspace + shell: pwsh + run: Copy-Item -Recurse -Force _temp/windows-drivers-rs/.github/actions .github/ - name: Install Winget uses: ./.github/actions/install-winget @@ -85,7 +92,7 @@ jobs: strategy: matrix: wdk: - - Microsoft.WindowsWDK.10.0.22621 # NI WDK + - 10.0.22621 # NI WDK steps: - name: Checkout Repository From 0e95395ebae7e8d5abe3e8d65e4f38e1b0789bb9 Mon Sep 17 00:00:00 2001 From: Melvin Wang Date: Mon, 17 Nov 2025 22:39:15 -0800 Subject: [PATCH 6/8] remove inaccurate doc --- general/echo/kmdf/exe/src/main.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/general/echo/kmdf/exe/src/main.rs b/general/echo/kmdf/exe/src/main.rs index bcdf6db..b5abee2 100644 --- a/general/echo/kmdf/exe/src/main.rs +++ b/general/echo/kmdf/exe/src/main.rs @@ -5,9 +5,6 @@ //! find a 1 to 1 mapping to the original C sample app code versus a full proper //! Rust implementation -//! Idiomatic Rust wrappers for the Windows Driver Kit (WDK) APIs. This crate is -//! built on top of the raw FFI bindings provided by [`wdk-sys`], and provides a -//! safe, idiomatic rust interface to the WDK. #![deny(missing_docs)] #![deny(unsafe_op_in_unsafe_fn)] #![deny(clippy::all)] From 0dcc428499dfce993f979ee8aa65ae5da9d3fea9 Mon Sep 17 00:00:00 2001 From: Melvin Wang Date: Tue, 18 Nov 2025 18:19:20 -0800 Subject: [PATCH 7/8] fix clippy triggering on format! (nightly bug) --- general/echo/kmdf/exe/src/main.rs | 189 +++++++++++++++++------------- 1 file changed, 105 insertions(+), 84 deletions(-) diff --git a/general/echo/kmdf/exe/src/main.rs b/general/echo/kmdf/exe/src/main.rs index b5abee2..8b9d911 100644 --- a/general/echo/kmdf/exe/src/main.rs +++ b/general/echo/kmdf/exe/src/main.rs @@ -125,12 +125,17 @@ Exit the app anytime by pressing Ctrl-C ); } - // SAFETY: - // Call Win32 API FFI GetLastError() to check for any errors - unsafe { - if h_device == INVALID_HANDLE_VALUE { - return Err(format!("Failed to open device. Error {}", GetLastError()).into()); - } + if h_device == INVALID_HANDLE_VALUE { + return Err(format!( + "Failed to open device. Error {}", + // SAFETY: + // - FFI contract: Called immediately after CreateFileW failure before any intervening + // Win32/CRT calls that would overwrite thread-local error slot + // - Concurrency: Reads thread-local storage only (no data races) + // - Memory safety: Returns u32 value (no pointer dereferences) + unsafe { GetLastError() } + ) + .into()); } println!("Opened device successfully"); @@ -204,16 +209,17 @@ fn perform_write_read_test(h_device: HANDLE, test_length: u32) -> Result<(), Box ); } - // SAFETY: - // Call Win32 API FFI GetLastError() to check for any errors from WriteFile - unsafe { - if r == FALSE { - return Err(format!( - "PerformWriteReadTest: WriteFile failed: Error {}", - GetLastError() - ) - .into()); - } + if r == FALSE { + return Err(format!( + "PerformWriteReadTest: WriteFile failed: Error {}", + // SAFETY: + // - FFI contract: Called immediately after WriteFile failure before any intervening + // Win32/CRT calls that would overwrite thread-local error slot + // - Concurrency: Reads thread-local storage only (no data races) + // - Memory safety: Returns u32 value (no pointer dereferences) + unsafe { GetLastError() } + ) + .into()); } if bytes_returned != test_length { @@ -239,16 +245,17 @@ fn perform_write_read_test(h_device: HANDLE, test_length: u32) -> Result<(), Box ); } - // SAFETY: - // Call Win32 API FFI GetLastError() to check for any errors from ReadFile - unsafe { - if r == FALSE { - return Err(format!( - "PerformWriteReadTest: ReadFile failed: Error {}", - GetLastError() - ) - .into()); - } + if r == FALSE { + return Err(format!( + "PerformWriteReadTest: ReadFile failed: Error {}", + // SAFETY: + // - FFI contract: Called immediately after ReadFile failure before any intervening + // Win32/CRT calls that would overwrite thread-local error slot + // - Concurrency: Reads thread-local storage only (no data races) + // - Memory safety: Returns u32 value (no pointer dereferences) + unsafe { GetLastError() } + ) + .into()); } // SAFETY: @@ -309,17 +316,18 @@ fn async_io_work(io_type: u32) -> Result<(), Box> { ); } - // SAFETY: - // Call Win32 API FFI GetLastError() to check for any errors from CreateFileW - unsafe { - if h_device == INVALID_HANDLE_VALUE { - return Err(format!( - "Cannot open {} error {}", - globals.device_path, - GetLastError() - ) - .into()); - } + if h_device == INVALID_HANDLE_VALUE { + return Err(format!( + "Cannot open {} error {}", + globals.device_path, + // SAFETY: + // - FFI contract: Called immediately after CreateFileW failure before any intervening + // Win32/CRT calls that would overwrite thread-local error slot + // - Concurrency: Reads thread-local storage only (no data races) + // - Memory safety: Returns u32 value (no pointer dereferences) + unsafe { GetLastError() } + ) + .into()); } // SAFETY: @@ -329,14 +337,18 @@ fn async_io_work(io_type: u32) -> Result<(), Box> { h_completion_port = CreateIoCompletionPort(h_device, 0, 1, 0); } - // SAFETY: - // Call Win32 API FFI to check for CreateIoCompletionPort result from - // GetLastError() - unsafe { - // CreateIoCompletionPort returns NULL on failure, not INVALID_HANDLE_VALUE - if h_completion_port == 0 { - return Err(format!("Cannot open completion port {}", GetLastError()).into()); - } + // CreateIoCompletionPort returns NULL on failure, not INVALID_HANDLE_VALUE + if h_completion_port == 0 { + return Err(format!( + "Cannot open completion port {}", + // SAFETY: + // - FFI contract: Called immediately after CreateIoCompletionPort failure before any + // intervening Win32/CRT calls that would overwrite thread-local error slot + // - Concurrency: Reads thread-local storage only (no data races) + // - Memory safety: Returns u32 value (no pointer dereferences) + unsafe { GetLastError() } + ) + .into()); } let mut remaining_requests_to_receive = 0; @@ -394,14 +406,15 @@ fn async_io_work(io_type: u32) -> Result<(), Box> { ); } - // SAFETY: - // Call Win32 API FFI GetLastError() to check for any errors from ReadFile - unsafe { - if r == FALSE { - let error = GetLastError(); - if error != ERROR_IO_PENDING { - return Err(format!("{i}th Read failed {error}").into()); - } + if r == FALSE { + // SAFETY: + // - FFI contract: Called immediately after ReadFile failure before any + // intervening Win32/CRT calls that would overwrite thread-local error slot + // - Concurrency: Reads thread-local storage only (no data races) + // - Memory safety: Returns u32 value (no pointer dereferences) + let error = unsafe { GetLastError() }; + if error != ERROR_IO_PENDING { + return Err(format!("{i}th Read failed {error}",).into()); } } } else { @@ -419,14 +432,15 @@ fn async_io_work(io_type: u32) -> Result<(), Box> { ); } - // SAFETY: - // Call Win32 API FFI GetLastError() to check for any errors from WriteFile - unsafe { - if r == FALSE { - let error = GetLastError(); - if error != ERROR_IO_PENDING { - return Err(format!("{i}th Write failed {error}").into()); - } + if r == FALSE { + // SAFETY: + // - FFI contract: Called immediately after WriteFile failure before any + // intervening Win32/CRT calls that would overwrite thread-local error slot + // - Concurrency: Reads thread-local storage only (no data races) + // - Memory safety: Returns u32 value (no pointer dereferences) + let error = unsafe { GetLastError() }; + if error != ERROR_IO_PENDING { + return Err(format!("{i}th Write failed {error}").into()); } } } @@ -450,13 +464,18 @@ fn async_io_work(io_type: u32) -> Result<(), Box> { ); } - // SAFETY: - // Call Win32 API FFI GetLastError() to check for any errors from - // GetQueuedCompletionStatus - unsafe { - if r == FALSE { - return Err(format!("GetQueuedCompletionStatus failed {}", GetLastError()).into()); - } + if r == FALSE { + return Err(format!( + "GetQueuedCompletionStatus failed {}", + // SAFETY: + // - FFI contract: Called immediately after GetQueuedCompletionStatus failure + // before any intervening Win32/CRT calls that would overwrite thread-local error + // slot + // - Concurrency: Reads thread-local storage only (no data races) + // - Memory safety: Returns u32 value (no pointer dereferences) + unsafe { GetLastError() } + ) + .into()); } let i; @@ -508,14 +527,15 @@ fn async_io_work(io_type: u32) -> Result<(), Box> { ); } - // SAFETY: - // Call Win32 API FFI GetLastError() to check for any errors from ReadFile - unsafe { - if r == FALSE { - let error = GetLastError(); - if error != ERROR_IO_PENDING { - return Err(format!("{i}th Read failed {error}").into()); - } + if r == FALSE { + // SAFETY: + // - FFI contract: Called immediately after ReadFile failure before any + // intervening Win32/CRT calls that would overwrite thread-local error slot + // - Concurrency: Reads thread-local storage only (no data races) + // - Memory safety: Returns u32 value (no pointer dereferences) + let error = unsafe { GetLastError() }; + if error != ERROR_IO_PENDING { + return Err(format!("{i}th Read failed {error}").into()); } } } else { @@ -559,14 +579,15 @@ fn async_io_work(io_type: u32) -> Result<(), Box> { ); } - // SAFETY: - // Call Win32 API FFI GetLastError() to check for any errors from WriteFile - unsafe { - if r == FALSE { - let error = GetLastError(); - if error != ERROR_IO_PENDING { - return Err(format!("{i}th write failed {error}").into()); - } + if r == FALSE { + // SAFETY: + // - FFI contract: Called immediately after WriteFile failure before any + // intervening Win32/CRT calls that would overwrite thread-local error slot + // - Concurrency: Reads thread-local storage only (no data races) + // - Memory safety: Returns u32 value (no pointer dereferences) + let error = unsafe { GetLastError() }; + if error != ERROR_IO_PENDING { + return Err(format!("{i}th write failed {error}").into()); } } } From 7218dd0a004299f0ebf80a0917b4c5b24fc83440 Mon Sep 17 00:00:00 2001 From: Melvin Wang Date: Wed, 19 Nov 2025 14:11:54 -0800 Subject: [PATCH 8/8] ci: temporarily disable triggers in build workflow until new wdk-build version is ingested --- .github/workflows/build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5a01c1d..372f896 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,7 @@ on: push: - pull_request: + # Temporarily disable until new wdk-build version is ingested: https://github.com/microsoft/Windows-rust-driver-samples/pull/46 + # pull_request: merge_group: schedule: # Trigger a job on default branch at 4AM PST everyday - cron: "0 11 * * *"