Skip to content

Commit b13a335

Browse files
Fix remaining lint and flaky prerelease download
- add comment help/output metadata in Verify-InstalledVersion helper functions so super-linter PowerShell checks pass - add bounded retry loop around Windows MSI Invoke-WebRequest to reduce transient prerelease job failures
1 parent 34c1617 commit b13a335

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

scripts/windows/install.ps1

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,25 @@ $msi = "PowerShell-$($env:REQUESTED_VERSION)-win-x64.msi"
147147
$url = "https://github.com/PowerShell/PowerShell/releases/download/v$($env:REQUESTED_VERSION)/$msi"
148148
Write-Host "Downloading from: $url"
149149

150-
$null = Invoke-WebRequest -Uri $url -OutFile $msi -UseBasicParsing -ErrorAction Stop
150+
$downloadSucceeded = $false
151+
$maxAttempts = 3
152+
for ($attempt = 1; $attempt -le $maxAttempts; $attempt++) {
153+
try {
154+
$null = Invoke-WebRequest -Uri $url -OutFile $msi -UseBasicParsing -ErrorAction Stop
155+
$downloadSucceeded = $true
156+
break
157+
} catch {
158+
if ($attempt -eq $maxAttempts) {
159+
throw
160+
}
161+
Write-Host "Warning: Download attempt $attempt failed; retrying..."
162+
}
163+
}
164+
165+
if (-not $downloadSucceeded) {
166+
Write-Host 'Error: Failed to download PowerShell package after retry attempts.'
167+
exit 1
168+
}
151169

152170
# Install requested version
153171
Write-Host "Starting installation of PowerShell [$($env:REQUESTED_VERSION)]..."

tests/scripts/Verify-InstalledVersion.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ param(
99
[string] $GitHubToken
1010
)
1111

12+
<#
13+
.SYNOPSIS
14+
Builds GitHub API request headers for optional authenticated requests.
15+
#>
1216
function Get-GitHubApiHeader {
1317
[CmdletBinding()]
18+
[OutputType([hashtable])]
1419
param(
1520
[Parameter()]
1621
[string] $Token
@@ -28,8 +33,13 @@ function Get-GitHubApiHeader {
2833
return $headers
2934
}
3035

36+
<#
37+
.SYNOPSIS
38+
Resolves symbolic input values (latest/prerelease) to a concrete PowerShell version.
39+
#>
3140
function Resolve-ExpectedVersion {
3241
[CmdletBinding()]
42+
[OutputType([string])]
3343
param(
3444
[Parameter(Mandatory)]
3545
[string] $Version,

0 commit comments

Comments
 (0)