From e19c77b7958242fa4773c50477ca2858b83112a9 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 12 Aug 2026 09:24:41 -0700 Subject: [PATCH] Address when Choclately fails on IIS runners --- .github/workflows/tests.yml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4a75a88..3b0d932 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -696,9 +696,33 @@ jobs: run: | Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole, IIS-WebServer, IIS-CommonHttpFeatures, IIS-ManagementConsole, IIS-HttpErrors, IIS-HttpRedirect, IIS-WindowsAuthentication, IIS-StaticContent, IIS-DefaultDocument, IIS-HttpCompressionStatic, IIS-DirectoryBrowsing, IIS-WebServerManagementTools, IIS-CGI -All Set-Service wuauserv -StartupType Manual - (Get-Content ${env:GITHUB_WORKSPACE}\phpBB3\phpBB\web.config).replace("", "`n`t`n`t`t`n`t") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB3\phpBB\web.config - (Get-Content ${env:GITHUB_WORKSPACE}\phpBB3\phpBB\web.config).replace("`t", "`t`t`n`t") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB3\phpBB\web.config - choco install urlrewrite -y + $webConfig = "${env:GITHUB_WORKSPACE}\phpBB3\phpBB\web.config" + # Install URL Rewrite with retries because Chocolatey feed requests can timeout on GitHub runners. + $installed = $false + for ($i = 1; $i -le 3; $i++) { + try { + choco install urlrewrite -y --no-progress + $installed = $true + break + } catch { + Write-Warning "URL Rewrite install attempt $i failed: $($_.Exception.Message)" + Start-Sleep -Seconds (10 * $i) + } + } + if (-not $installed) { + throw "Failed to install URL Rewrite after 3 attempts." + } + # Only patch web.config after rewrite is installed. + $content = Get-Content $webConfig -Raw + $content = $content.Replace( + "", + "`n`t`n`t`t`n`t" + ) + $content = $content.Replace( + "`t", + "`t`t`n`t" + ) + Set-Content $webConfig -Value $content -Encoding UTF8 Import-Module WebAdministration New-WebSite -Name 'phpBBTest' -PhysicalPath "${env:GITHUB_WORKSPACE}\phpBB3\phpBB" -Force $session = Get-PSSession -Name WinPSCompatSession