ci: use Install-PSResource instead of Install-Module for WinGet#622
ci: use Install-PSResource instead of Install-Module for WinGet#622wmmc88 merged 3 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Guards Windows CI against intermittently missing PowerShell Gallery registration on windows-2025 runners by re-registering the default PS repositories before installing Microsoft.WinGet.Client.
Changes:
- Add a preflight check for
PSGalleryregistration and callRegister-PSRepository -Defaultwhen missing. - Apply the same workaround in both the CodeQL workflow and the
install-wingetcomposite action.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| .github/workflows/codeql.yaml | Adds a PSGallery-registration guard before installing the WinGet PowerShell module in the CodeQL job. |
| .github/actions/install-winget/action.yaml | Adds the same PSGallery-registration guard to the shared composite action. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cb5c267 to
fcc4578
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #622 +/- ##
=======================================
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. 🚀 New features to boost your workflow:
|
fcc4578 to
57b0194
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
31d6b7a to
57b0194
Compare
57b0194 to
09ef591
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
.github/actions/install-winget/action.yaml:179
Get-Module -ListAvailable Microsoft.WinGet.Client | Select-Object -First 1is not guaranteed to return the highest installed version if multiple versions exist, so the loggedInstalled module versioncan be inaccurate. To make the output deterministic (and more useful for debugging), select the highest version explicitly (e.g., sort byVersiondescending) and consider handling the case where the module isn’t present to emit a clearer error.
$moduleVersion = (Get-Module -ListAvailable Microsoft.WinGet.Client | Select-Object -First 1).Version.ToString()
Write-Host "Installed module version: $moduleVersion"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
09ef591 to
29d273a
Compare
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
29d273a to
1006d38
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
.github/actions/install-winget/action.yaml:144
Get-Module -ListAvailable ... | Select-Object -First 1does not reliably return the version that was just installed (ordering isn’t guaranteed and multiple versions may be present). This can make the log incorrect and can mask cases where an older version is still the one being resolved. Prefer querying the installed resource via PSResourceGet (e.g.,Get-InstalledPSResource -Name Microsoft.WinGet.Client) or, at minimum, sort the available module versions byVersiondescending before selecting.
$moduleVersion = (Get-Module -ListAvailable Microsoft.WinGet.Client | Select-Object -First 1).Version.ToString()
Write-Host "Installed module version: $moduleVersion"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Melvin Wang <melvin.mc.wang@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
.github/actions/install-winget/action.yaml:143
- Install-PSResource calls here don’t use -ErrorAction Stop / try-catch, and the script then unconditionally dereferences the result of Get-InstalledPSResource. If installation fails (or returns no installed resources), this will either mask the real error or hit a null dereference when accessing .Version. Recommend making Install-PSResource failures terminating (e.g., -ErrorAction Stop and/or $ErrorActionPreference='Stop') and validating a module was installed before reading its version.
Install-PSResource -Name Microsoft.WinGet.Client -Repository PSGallery -TrustRepository -Quiet
}
}
$moduleVersion = (Get-InstalledPSResource -Name Microsoft.WinGet.Client | Sort-Object Version -Descending | Select-Object -First 1).Version.ToString()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace
Install-Module(PowerShellGet v2) withInstall-PSResource(PSResourceGet, built into PowerShell 7.4+) for installing theMicrosoft.WinGet.Clientmodule. PSResourceGet has its own repository system that is independent of the legacy NuGet pipeline, avoiding transient PSGallery registration failures on freshly provisionedwindows-2025runners.Also switches
codeql.yamlto use the sharedinstall-wingetcomposite action instead of inlining its ownInstall-Modulestep.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).