Skip to content

Commit 24daec8

Browse files
committed
More Choclatey error handling
1 parent c1b0eaa commit 24daec8

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,13 +698,19 @@ jobs:
698698
$httpErrors = $webConfigXml.CreateElement('httpErrors')
699699
$httpErrors.SetAttribute('errorMode', 'Detailed')
700700
[void]$systemWebServer.AppendChild($httpErrors)
701+
$appCmd = Join-Path $env:windir 'System32\inetsrv\appcmd.exe'
701702
$rewriteInstalled = $false
702703
try {
703704
choco install urlrewrite -y --no-progress
704705
# Native command failures do not necessarily throw in PowerShell.
705706
if ($LASTEXITCODE -ne 0) {
706707
throw "Chocolatey URL Rewrite installation exited with code $LASTEXITCODE."
707708
}
709+
# Chocolatey can report success even when its feed failed and no packages were installed.
710+
$iisModules = @(& $appCmd list modules /text:MODULE.NAME)
711+
if ($LASTEXITCODE -ne 0 -or $iisModules -notcontains 'RewriteModule') {
712+
throw 'IIS URL Rewrite module is not registered after installation.'
713+
}
708714
$rewriteInstalled = $true
709715
} catch {
710716
Write-Warning "URL Rewrite installation failed; continuing without rewrite-specific IIS configuration. $_"
@@ -731,6 +737,11 @@ jobs:
731737
New-WebHandler -Name "PHP-FastCGI" -Path "*.php" -Modules FastCgiModule -ScriptProcessor "C:\tools\php\php-cgi.exe" -Verb '*' -ResourceType Either
732738
iisreset
733739
NET START W3SVC
740+
$iisConfiguration = & $appCmd list config 'phpBBTest/'
741+
if ($LASTEXITCODE -ne 0) {
742+
Get-Content $webConfig
743+
throw "IIS rejected the phpBB test site configuration: $iisConfiguration"
744+
}
734745
mkdir "${env:GITHUB_WORKSPACE}\phpBB3\phpBB\cache\test"
735746
mkdir "${env:GITHUB_WORKSPACE}\phpBB3\phpBB\cache\installer"
736747
icacls "${env:GITHUB_WORKSPACE}\phpBB3\phpBB\cache" /grant Users:F /T

0 commit comments

Comments
 (0)