Skip to content

ci: stress-test Install-PSResource with expanded LLVM matrix#626

Closed
wmmc88 wants to merge 6 commits intomicrosoft:mainfrom
wmmc88:ci/stress-test-psresourceget
Closed

ci: stress-test Install-PSResource with expanded LLVM matrix#626
wmmc88 wants to merge 6 commits intomicrosoft:mainfrom
wmmc88:ci/stress-test-psresourceget

Conversation

@wmmc88
Copy link
Copy Markdown
Collaborator

@wmmc88 wmmc88 commented Mar 6, 2026

Stress-test branch: combines the expanded LLVM matrix from #593 with the Install-PSResource migration from #622. This exercises PSResourceGet across a large CI matrix to validate it works reliably before merging.

Do not merge — this is a temporary CI test branch.

wmmc88 and others added 6 commits March 3, 2026 19:31
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Melvin Wang <melvin.mc.wang@gmail.com>
Replace Install-Module (PowerShellGet v2) with Install-PSResource
(PSResourceGet, built into PowerShell 7.4+). PSResourceGet has its
own repository system that is independent of the legacy NuGet
pipeline, avoiding transient PSGallery registration failures on
freshly provisioned runners.

Also switch codeql.yaml to use the shared install-winget composite
action instead of inlining its own Install-Module step.

See actions/runner-images#13758
Copilot AI review requested due to automatic review settings March 6, 2026 08:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Stress-test CI changes to validate Install-PSResource (PSResourceGet) across a significantly expanded LLVM version matrix, prior to merging the migration.

Changes:

  • Expand the LLVM CI matrix to cover multiple newer LLVM releases across workflows.
  • Migrate WinGet PowerShell module installation to Install-PSResource via a shared install-winget action.
  • Update README guidance to reference CI-tested LLVM versions instead of pinning a single version.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
README.md Updates local setup docs to point at CI-tested LLVM versions
.github/workflows/test.yaml Expands LLVM matrix for test workflow
.github/workflows/local-development-makefile.yaml Expands LLVM matrix for local-development workflow
.github/workflows/lint.yaml Expands LLVM matrix for lint workflow
.github/workflows/docs.yaml Expands LLVM matrix for docs workflow
.github/workflows/codeql.yaml Expands LLVM matrix and switches to shared WinGet installer action
.github/workflows/build.yaml Expands LLVM matrix for build workflow
.github/actions/install-winget/action.yaml Migrates WinGet module install from Install-Module to Install-PSResource

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

Comment thread README.md
* `winget install -i LLVM.LLVM`
* Ensure you select the GUI option to add LLVM to the PATH
* LLVM 18 has a bug that causes bindings to fail to generate for ARM64. Continue using LLVM 17 until LLVM 19 comes out with [the fix](https://github.com/llvm/llvm-project/pull/93235). See [this](https://github.com/rust-lang/rust-bindgen/issues/2842) for more details.
* See list of [tested/supported versions](https://github.com/microsoft/windows-drivers-rs/blob/main/.github/workflows/build.yaml#L39) in the [CI workflow](./.github/workflows/build.yaml)
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The README links to a specific line number in build.yaml (#L39), which is brittle and will easily drift as the workflow changes. Prefer linking to the file without a line anchor (or to a stable section/README that enumerates supported LLVM versions) so the documentation stays accurate over time.

Suggested change
* See list of [tested/supported versions](https://github.com/microsoft/windows-drivers-rs/blob/main/.github/workflows/build.yaml#L39) in the [CI workflow](./.github/workflows/build.yaml)
* See list of [tested/supported versions](https://github.com/microsoft/windows-drivers-rs/blob/main/.github/workflows/build.yaml) in the [CI workflow](./.github/workflows/build.yaml)

Copilot uses AI. Check for mistakes.
Comment on lines +113 to +120
# Use Install-PSResource (PSResourceGet, built into PowerShell 7.4+) instead of the
# legacy Install-Module. PSResourceGet has its own repository system that is independent
# of the old PowerShellGet/NuGet pipeline, which avoids transient PSGallery registration
# failures on freshly provisioned runners.
# See https://github.com/actions/runner-images/issues/13758
if (-not (Get-PSResourceRepository -Name PSGallery -ErrorAction SilentlyContinue)) {
Register-PSResourceRepository -PSGallery -Trusted
}
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

This assumes PSResourceGet cmdlets (Get-PSResourceRepository / Find-PSResource / Install-PSResource) are available (PowerShell 7.4+ per the comment). If the runner executes this action under Windows PowerShell 5.1 or older PowerShell 7.x, the action will fail immediately. Add an explicit version/cmdlet availability check and either (a) install/enable PSResourceGet first, or (b) fall back to the previous Install-Module path when PSResourceGet isn't available.

See below for a potential fix:

        $cliVersion = (winget --version).Trim() -replace '^v', ''
        $cliMajor = ($cliVersion -split '\.')[0]
        Write-Host "WinGet CLI version: $cliVersion (major: $cliMajor)"

        # Prefer PSResourceGet (PowerShell 7.4+) when available, but fall back to
        # PowerShellGet's Install-Module on older PowerShell versions.
        if (Get-Command -Name Get-PSResourceRepository -ErrorAction SilentlyContinue) {
            Write-Host "PSResourceGet detected. Using Install-PSResource path."

            # Use Install-PSResource (PSResourceGet, built into PowerShell 7.4+) instead of the
            # legacy Install-Module. PSResourceGet has its own repository system that is independent
            # of the old PowerShellGet/NuGet pipeline, which avoids transient PSGallery registration
            # failures on freshly provisioned runners.
            # See https://github.com/actions/runner-images/issues/13758
            if (-not (Get-PSResourceRepository -Name PSGallery -ErrorAction SilentlyContinue)) {
                Register-PSResourceRepository -PSGallery -Trusted
            }

            # Try exact match first, then best matching major version, then latest
            $found = Find-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -Version $cliVersion -ErrorAction SilentlyContinue
            if ($found) {
                Write-Host "Installing exact matching module version via PSResourceGet: $cliVersion"
                Install-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -Version $cliVersion -TrustRepository -Quiet
            } else {
                $allVersions = Find-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -Version "[$cliMajor.0.0, $([int]$cliMajor + 1).0.0)" -ErrorAction SilentlyContinue
                if ($allVersions) {
                    $best = ($allVersions | Sort-Object Version -Descending | Select-Object -First 1).Version
                    Write-Host "Exact match not found. Installing latest module with matching major version via PSResourceGet: $best"
                    Install-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -Version $best -TrustRepository -Quiet
                } else {
                    Write-Warning "No module with major version $cliMajor found on PSGallery. Installing latest version via PSResourceGet."
                    Install-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -TrustRepository -Quiet
                }
            }
        }
        else {
            Write-Warning "PSResourceGet cmdlets not found. Falling back to PowerShellGet (Install-Module)."

            if (-not (Get-Command -Name Install-Module -ErrorAction SilentlyContinue)) {
                Write-Error "Neither PSResourceGet (Install-PSResource) nor PowerShellGet (Install-Module) is available. Cannot install Microsoft.WinGet.Client."
                exit 1
            }

            try {
                # Install latest Microsoft.WinGet.Client from PSGallery for this fallback path.
                # This mirrors the previous Install-Module-based behavior on older PowerShell versions.
                Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -Scope CurrentUser -Force -AllowClobber -ErrorAction Stop
            }
            catch {
                Write-Error "Failed to install Microsoft.WinGet.Client via Install-Module: $($_.Exception.Message)"
                exit 1
            }
        }

        $module = Get-Module -ListAvailable Microsoft.WinGet.Client | Select-Object -First 1
        if (-not $module) {
            Write-Error "Microsoft.WinGet.Client module was not found after installation."
            exit 1
        }

        $moduleVersion = $module.Version.ToString()

Copilot uses AI. Check for mistakes.
Comment on lines +127 to +130
$found = Find-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -Version $cliVersion -ErrorAction SilentlyContinue
if ($found) {
Write-Host "Installing exact matching module version: $cliVersion"
Install-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -Version $cliVersion -TrustRepository -Quiet
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

This assumes PSResourceGet cmdlets (Get-PSResourceRepository / Find-PSResource / Install-PSResource) are available (PowerShell 7.4+ per the comment). If the runner executes this action under Windows PowerShell 5.1 or older PowerShell 7.x, the action will fail immediately. Add an explicit version/cmdlet availability check and either (a) install/enable PSResourceGet first, or (b) fall back to the previous Install-Module path when PSResourceGet isn't available.

See below for a potential fix:

        $psResourceGetAvailable = $false
        if (Get-Command -Name Install-PSResource -ErrorAction SilentlyContinue) {
            $psResourceGetAvailable = $true
        }

        $cliVersion = (winget --version).Trim() -replace '^v', ''
        $cliMajor = ($cliVersion -split '\.')[0]
        Write-Host "WinGet CLI version: $cliVersion (major: $cliMajor)"

        if ($psResourceGetAvailable) {
            # Use Install-PSResource (PSResourceGet, built into PowerShell 7.4+) instead of the
            # legacy Install-Module. PSResourceGet has its own repository system that is independent
            # of the old PowerShellGet/NuGet pipeline, which avoids transient PSGallery registration
            # failures on freshly provisioned runners.
            # See https://github.com/actions/runner-images/issues/13758
            if (-not (Get-PSResourceRepository -Name PSGallery -ErrorAction SilentlyContinue)) {
                Register-PSResourceRepository -PSGallery -Trusted
            }

            # Try exact match first, then best matching major version, then latest
            $found = Find-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -Version $cliVersion -ErrorAction SilentlyContinue
            if ($found) {
                Write-Host "Installing exact matching module version via PSResourceGet: $cliVersion"
                Install-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -Version $cliVersion -TrustRepository -Quiet
            } else {
                $allVersions = Find-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -Version "[$cliMajor.0.0, $([int]$cliMajor + 1).0.0)" -ErrorAction SilentlyContinue
                if ($allVersions) {
                    $best = ($allVersions | Sort-Object Version -Descending | Select-Object -First 1).Version
                    Write-Host "Exact match not found. Installing latest module with matching major version via PSResourceGet: $best"
                    Install-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -Version $best -TrustRepository -Quiet
                } else {
                    Write-Warning "No module with major version $cliMajor found on PSGallery. Installing latest version via PSResourceGet."
                    Install-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -TrustRepository -Quiet
                }
            }
        } else {
            Write-Host "PSResourceGet cmdlets not available. Falling back to PowerShellGet (Install-Module/Find-Module)."

            # Ensure PSGallery is registered and trusted for PowerShellGet
            if (-not (Get-PSRepository -Name PSGallery -ErrorAction SilentlyContinue)) {
                try {
                    Register-PSRepository -Default -ErrorAction Stop
                } catch {
                    Write-Warning "Failed to register default PSGallery repository via PowerShellGet: $_"
                }
            }

            try {
                Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -ErrorAction SilentlyContinue
            } catch {
                Write-Warning "Failed to set PSGallery as Trusted via PowerShellGet: $_"
            }

            # Try exact match first, then best matching major version, then latest using PowerShellGet
            $found = Find-Module -Name Microsoft.WinGet.Client -Repository PSGallery -RequiredVersion $cliVersion -ErrorAction SilentlyContinue
            if ($found) {
                Write-Host "Installing exact matching module version via PowerShellGet: $cliVersion"
                Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -RequiredVersion $cliVersion -Scope CurrentUser -Force
            } else {
                $allVersions = Find-Module -Name Microsoft.WinGet.Client -Repository PSGallery -AllVersions -ErrorAction SilentlyContinue |
                    Where-Object { $_.Version.Major -eq [int]$cliMajor }
                if ($allVersions) {
                    $best = ($allVersions | Sort-Object Version -Descending | Select-Object -First 1).Version
                    Write-Host "Exact match not found. Installing latest module with matching major version via PowerShellGet: $best"
                    Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -RequiredVersion $best -Scope CurrentUser -Force
                } else {
                    Write-Warning "No module with major version $cliMajor found on PSGallery. Installing latest version via PowerShellGet."
                    Install-Module -Name Microsoft.WinGet.Client -Repository PSGallery -Scope CurrentUser -Force
                }

Copilot uses AI. Check for mistakes.
}

$moduleVersion = (Get-InstalledModule Microsoft.WinGet.Client).Version.ToString()
$moduleVersion = (Get-Module -ListAvailable Microsoft.WinGet.Client | Select-Object -First 1).Version.ToString()
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

Get-Module -ListAvailable ... | Select-Object -First 1 does not guarantee you get the version that was just installed (or the highest version) because ordering is not reliable. Sort by Version descending before selecting, or query the installed resource directly (e.g., via the PSResourceGet installed-resource cmdlet) to ensure the reported version is deterministic and accurate.

Suggested change
$moduleVersion = (Get-Module -ListAvailable Microsoft.WinGet.Client | Select-Object -First 1).Version.ToString()
$moduleVersion = (Get-Module -ListAvailable Microsoft.WinGet.Client | Sort-Object Version -Descending | Select-Object -First 1).Version.ToString()

Copilot uses AI. Check for mistakes.
Comment on lines 34 to +38
llvm:
- 17.0.6
- 19.1.7
- 20.1.8
- 21.1.2
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The same LLVM version list is duplicated across multiple workflows (test, build, lint, docs, codeql, local-development-makefile). This increases the chance of workflows drifting out of sync. Consider centralizing the LLVM version matrix (e.g., via a reusable workflow invoked by each job, or by defining a single JSON list in one place and using fromJSON(...) in each workflow) so updates happen once.

Copilot uses AI. Check for mistakes.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.41%. Comparing base (547b792) to head (ddea1c0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #626   +/-   ##
=======================================
  Coverage   77.41%   77.41%           
=======================================
  Files          24       24           
  Lines        4853     4853           
  Branches     4853     4853           
=======================================
  Hits         3757     3757           
  Misses        979      979           
  Partials      117      117           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wmmc88
Copy link
Copy Markdown
Collaborator Author

wmmc88 commented Mar 7, 2026

Stress test for #622 -- all 12 workflows passed with zero failures across the expanded LLVM matrix. Closing.

@wmmc88 wmmc88 closed this Mar 7, 2026
@wmmc88 wmmc88 deleted the ci/stress-test-psresourceget branch March 7, 2026 19:27
github-merge-queue Bot pushed a commit that referenced this pull request Mar 20, 2026
Replace `Install-Module` (PowerShellGet v2) with `Install-PSResource`
(PSResourceGet, built into PowerShell 7.4+) for installing the
`Microsoft.WinGet.Client` module. PSResourceGet has its own repository
system that is independent of the legacy NuGet pipeline, avoiding
transient PSGallery registration failures on freshly provisioned
`windows-2025` runners.

Also switches `codeql.yaml` to use the shared `install-winget` composite
action instead of inlining its own `Install-Module` step.

Example failure:
https://github.com/microsoft/windows-drivers-rs/actions/runs/22659747111/job/65677070595?pr=621

Upstream issue: actions/runner-images#13758

Stress-tested in #626 (expanded LLVM matrix).

---------

Signed-off-by: Melvin Wang <melvin.mc.wang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants