ci: improve winget installation reliability#617
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the repository’s composite GitHub Action for installing WinGet in Windows CI to be more reliable on runner images where winget may be missing, by switching from Repair-WinGetPackageManager to authenticated gh-based release asset downloads and adding version consistency checks.
Changes:
- Replace
Repair-WinGetPackageManagerwith authenticatedgh releasedownloads of WinGet release assets. - Add architecture-aware dependency installation for WinGet CLI.
- Add a post-install verification step intended to ensure WinGet CLI and PowerShell module versions match.
💡 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 #617 +/- ##
=======================================
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:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (8)
.github/actions/install-llvm/action.yaml:26
- Removing
$ErrorActionPreference = 'Stop'can allow non-terminating errors during input validation to be ignored. Consider keeping the explicit preference (or using-ErrorAction Stopon cmdlets) so the step consistently fails on validation/runtime errors across runner environments.
This issue also appears in the following locations of the same file:
- line 36
- line 13
shell: pwsh
run: |
Set-StrictMode -Version Latest
$version = '${{ inputs.version }}'
Write-Host "Validating LLVM installation inputs..."
Write-Host "Version: $version"
# Basic version format validation (LLVM uses semantic versioning)
if ([string]::IsNullOrWhiteSpace($version)) {
throw "Version cannot be empty"
}
Write-Host "✅ Input validation passed"
.github/actions/install-llvm/action.yaml:42
- This verification step previously forced non-terminating errors to fail the step via
$ErrorActionPreference = 'Stop'. Without it, some command failures could be logged but not stop the job depending on how errors surface. Consider restoring it to keep verification strictly fail-fast.
shell: pwsh
run: |
Set-StrictMode -Version Latest
$clangVersion = & clang --version 2>&1
Write-Host "✅ LLVM/Clang verification successful:"
Write-Host $clangVersion
.github/actions/install-wdk/action.yaml:33
- Removing
$ErrorActionPreference = 'Stop'changes error-handling semantics for this validation step: non-terminating errors from cmdlets could be ignored, potentially allowing invalid state to slip through. Consider restoring the explicit preference (or using-ErrorAction Stopon cmdlets where needed) to keep the action behavior deterministic.
This issue also appears in the following locations of the same file:
- line 249
- line 76
run: |
Set-StrictMode -Version Latest
$source = '${{ inputs.source }}'
$version = '${{ inputs.version }}'
$hostArch = '${{ inputs.host }}'
$targetArch = '${{ inputs.target }}'
.github/actions/install-wdk/action.yaml:260
- Removing
$ErrorActionPreference = 'Stop'can allow non-terminating errors to continue, which is risky in a step that computes and exports environment variables used by later steps. Consider restoring it (or making any potentially failing cmdlets use-ErrorAction Stop) so later steps don't run with partially computed state.
shell: pwsh
run: |
Set-StrictMode -Version Latest
$inputVersion = '${{ inputs.version }}'
Write-Host "Processing WDK version: $inputVersion"
$versionParts = $inputVersion.Split('.')
$sdkVersion = $versionParts[0..2] -join '.'
Write-Host "Calculated SDK version: $sdkVersion from input version: $inputVersion"
Write-Output "SDK_VERSION=$sdkVersion" >> $env:GITHUB_ENV
Write-Output "Version_Number=$sdkVersion.0" >> $env:GITHUB_ENV
.github/actions/install-llvm/action.yaml:16
- The PR description focuses on improving WinGet installation in
.github/actions/install-winget/action.yaml, but this change also removes$ErrorActionPreference = 'Stop'from other composite actions (e.g., install-llvm/install-wdk/install-winget-package/uninstall-winget-package). If that broader error-handling change is intended, please call it out in the PR description; otherwise consider splitting/reverting it to keep this PR focused.
shell: pwsh
run: |
Set-StrictMode -Version Latest
.github/actions/uninstall-winget-package/action.yaml:19
- Removing
$ErrorActionPreference = 'Stop'can allow non-terminating PowerShell errors to be logged but not fail the step, which reduces reliability of the uninstall action. Consider restoring it (or using-ErrorAction Stopon critical commands) so CI fails fast on real errors.
run: |
Set-StrictMode -Version Latest
# Import WinGet PowerShell module
Import-Module Microsoft.WinGet.Client -Force
.github/actions/install-winget-package/action.yaml:41
- Removing
$ErrorActionPreference = 'Stop'can allow non-terminating PowerShell errors (e.g., fromImport-Module/Get-WinGetPackage) to be logged but not fail the step. Consider restoring it (or adding-ErrorAction Stopon the critical cmdlets) to keep install failures from being silently ignored.
run: |
Set-StrictMode -Version Latest
# Import WinGet PowerShell module
Import-Module Microsoft.WinGet.Client -Force
.github/actions/install-wdk/action.yaml:80
- This step previously forced PowerShell to fail on non-terminating errors via
$ErrorActionPreference = 'Stop'. Dropping that can make some failures harder to detect (especially inside larger scripts). Consider restoring it here to preserve the action's "robust error handling" intent.
# Optimization: Set strict mode and error handling
Set-StrictMode -Version Latest
$ProgressPreference = 'SilentlyContinue'
# Helper function to select a single package from a collection
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Replace Repair-WinGetPackageManager with authenticated gh CLI downloads to avoid GitHub API rate limits in CI - Pin all downloads to a single resolved release tag to prevent TOCTOU race - Add explicit LASTEXITCODE checks after each gh CLI command - Use proper enum-based architecture detection instead of string comparison - Install CLI first (if forced), then install matching PowerShell module version based on the installed CLI version - Add -ForceUpdateFromAnyVersion to dependency package installs - Fix dependency filter to include .appx files (not just .msix)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (4)
.github/actions/uninstall-winget-package/action.yaml:19
- This step used to set
$ErrorActionPreference = 'Stop', but that line has been removed. Without it, non-terminating errors from cmdlets can be logged while the script continues, potentially reporting success even though parts of the uninstall failed. Consider restoring$ErrorActionPreference = 'Stop'at the top of the script block to preserve fail-fast behavior.
Set-StrictMode -Version Latest
# Import WinGet PowerShell module
Import-Module Microsoft.WinGet.Client -Force
.github/actions/install-winget-package/action.yaml:41
- This step removed
$ErrorActionPreference = 'Stop'. Without it, some cmdlets can emit non-terminating errors and the script may continue (potentially reaching the verification loop) even though earlier operations failed. Consider restoring$ErrorActionPreference = 'Stop'at the start of the script block to keep the action's error handling robust.
Set-StrictMode -Version Latest
# Import WinGet PowerShell module
Import-Module Microsoft.WinGet.Client -Force
.github/actions/install-wdk/action.yaml:33
- All three PowerShell script blocks in this action had
$ErrorActionPreference = 'Stop'removed. That changes failure semantics: non-terminating errors can be printed and the script can continue, which can lead to misleading CI success and harder-to-diagnose failures later. Consider restoring$ErrorActionPreference = 'Stop'at the start of eachpwshrun:block.
shell: pwsh
run: |
Set-StrictMode -Version Latest
$source = '${{ inputs.source }}'
$version = '${{ inputs.version }}'
$hostArch = '${{ inputs.host }}'
$targetArch = '${{ inputs.target }}'
.github/actions/install-llvm/action.yaml:19
- Both PowerShell script blocks in this action removed
$ErrorActionPreference = 'Stop'. Without it, non-terminating errors can be emitted while the script continues, which reduces the reliability of the validation/verification steps. Consider restoring$ErrorActionPreference = 'Stop'at the top of eachpwshrun:block.
shell: pwsh
run: |
Set-StrictMode -Version Latest
$version = '${{ inputs.version }}'
Write-Host "Validating LLVM installation inputs..."
Write-Host "Version: $version"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This change has also been validated on the expand-llvm PR (#593) which has a significantly expanded CI matrix (multiple LLVM versions across all runner/arch/toolchain permutations). All WinGet-related jobs pass — the only failures are unrelated pre-existing issues (missing cargo-make on ARM64 nightly). |
Replaces
Repair-WinGetPackageManagerwith authenticatedghCLI downloads for installing WinGet CLI on CI runners. Fixes rate-limit failures (winget-cli#5949).Also removes redundant
$ErrorActionPreference = 'Stop'across all action files — GitHub Actionsshell: pwshalready sets this.