From faa212147639db0416372262671b31a6ba04c994 Mon Sep 17 00:00:00 2001 From: Junyi Ou Date: Tue, 27 Oct 2026 13:55:33 -0400 Subject: [PATCH] ci: retry the Pester installs from PSGallery PSGallery intermittently answers that no module named Pester matches, which fails CI for a reason that has nothing to do with the change. #2167 stopped the oracle marker check tests from installing Pester when the check is unchanged, but the PowerShell module job and the Windows service account tests still install it on every run, and the oracle marker check tests still install it when the check changes. Each Pester install now makes up to four attempts, waiting 30, 60 and 90 seconds between them, and fails with PSGallery's error once all four fail, like the Chocolatey installs (#2115). The loop is inline in each step because these jobs may check out an older commit than the workflow's own. Co-authored-by: Claude Opus 5.5 --- .github/workflows/ci.yml | 56 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa5161393..389eb5ce0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -282,7 +282,19 @@ jobs: - name: Install Pester if: ${{ steps.changes.outputs.changed == 'true' }} - run: Install-Module Pester -RequiredVersion 5.6.0 -Force + run: | + # Retry because PSGallery intermittently answers that no module named Pester matches. + # The retry is inline because this job may check out an older commit that lacks any shared helper. + for ($Attempt = 1; $true; $Attempt++) { + try { + Install-Module Pester -RequiredVersion 5.6.0 -Force -ErrorAction Stop + break + } catch { + if ($Attempt -ge 4) { throw } + Write-Warning "Installing Pester failed on attempt ${Attempt}: $_" + Start-Sleep -Seconds (30 * $Attempt) + } + } shell: pwsh - name: Pester tests @@ -696,7 +708,19 @@ jobs: - name: Install Pester id: prepare - run: Install-Module Pester -RequiredVersion 5.6.0 + run: | + # Retry because PSGallery intermittently answers that no module named Pester matches. + # The retry is inline because this job may check out an older commit that lacks any shared helper. + for ($Attempt = 1; $true; $Attempt++) { + try { + Install-Module Pester -RequiredVersion 5.6.0 -ErrorAction Stop + break + } catch { + if ($Attempt -ge 4) { throw } + Write-Warning "Installing Pester failed on attempt ${Attempt}: $_" + Start-Sleep -Seconds (30 * $Attempt) + } + } shell: pwsh - name: Build module @@ -743,7 +767,19 @@ jobs: ref: ${{ needs.preflight.outputs.ref }} - name: Install Pester for Windows PowerShell - run: Install-Module Pester -RequiredVersion 5.6.0 -Scope CurrentUser -Force + run: | + # Retry because PSGallery intermittently answers that no module named Pester matches. + # The retry is inline because this job may check out an older commit that lacks any shared helper. + for ($Attempt = 1; $true; $Attempt++) { + try { + Install-Module Pester -RequiredVersion 5.6.0 -Scope CurrentUser -Force -ErrorAction Stop + break + } catch { + if ($Attempt -ge 4) { throw } + Write-Warning "Installing Pester failed on attempt ${Attempt}: $_" + Start-Sleep -Seconds (30 * $Attempt) + } + } shell: powershell - name: Run service account tests in Windows PowerShell @@ -756,7 +792,19 @@ jobs: shell: powershell - name: Install Pester for PowerShell 7 - run: Install-Module Pester -RequiredVersion 5.6.0 -Scope CurrentUser -Force + run: | + # Retry because PSGallery intermittently answers that no module named Pester matches. + # The retry is inline because this job may check out an older commit that lacks any shared helper. + for ($Attempt = 1; $true; $Attempt++) { + try { + Install-Module Pester -RequiredVersion 5.6.0 -Scope CurrentUser -Force -ErrorAction Stop + break + } catch { + if ($Attempt -ge 4) { throw } + Write-Warning "Installing Pester failed on attempt ${Attempt}: $_" + Start-Sleep -Seconds (30 * $Attempt) + } + } shell: pwsh - name: Run service account tests in PowerShell 7