Skip to content

ci: improve winget installation reliability#617

Merged
wmmc88 merged 1 commit intomicrosoft:mainfrom
wmmc88:winget-token
Mar 4, 2026
Merged

ci: improve winget installation reliability#617
wmmc88 merged 1 commit intomicrosoft:mainfrom
wmmc88:winget-token

Conversation

@wmmc88
Copy link
Copy Markdown
Collaborator

@wmmc88 wmmc88 commented Feb 26, 2026

Replaces Repair-WinGetPackageManager with authenticated gh CLI 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 Actions shell: pwsh already sets this.

Copilot AI review requested due to automatic review settings February 26, 2026 08:02
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

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-WinGetPackageManager with authenticated gh release downloads 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-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.41%. Comparing base (009dcd7) to head (d6b340b).

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.
📢 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.

Copilot AI review requested due to automatic review settings February 26, 2026 18:26
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

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.

Copilot AI review requested due to automatic review settings February 27, 2026 18:25
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

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.

Copilot AI review requested due to automatic review settings February 28, 2026 05:59
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

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 Stop on 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 Stop on 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 Stop on 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., from Import-Module / Get-WinGetPackage) to be logged but not fail the step. Consider restoring it (or adding -ErrorAction Stop on 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)
@wmmc88 wmmc88 marked this pull request as ready for review March 1, 2026 19:29
Copilot AI review requested due to automatic review settings March 1, 2026 19:29
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

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 each pwsh run: 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 each pwsh run: 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.

@wmmc88
Copy link
Copy Markdown
Collaborator Author

wmmc88 commented Mar 2, 2026

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).

@wmmc88 wmmc88 added this pull request to the merge queue Mar 3, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 3, 2026
@wmmc88 wmmc88 added this pull request to the merge queue Mar 4, 2026
Merged via the queue into microsoft:main with commit 547b792 Mar 4, 2026
234 checks passed
@wmmc88 wmmc88 deleted the winget-token branch March 4, 2026 01:28
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.

5 participants