Skip to content

Commit 8ccaf19

Browse files
committed
Add error handling for exit code of Chocolatey
Powershell does not automatically exit a script when an `.exe` returns a non-successful exit code. This is due to a lack of exit code standardisation across programs for the Windows platform. Therefore we need to check for the particular exit code of an `.exe` in order to report it to the github actions platform. Note that exit codes from `.exe` invocations are placed in `$LastExitCode` and exit codes from Powershell cmdlets such as `Write-Output` are placed in the separate `$?` variable.
1 parent a202116 commit 8ccaf19

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

.github/workflows/pull-request-checks.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,11 @@ jobs:
611611
- name: Fetch dependencies
612612
run: |
613613
choco install winflexbison3
614+
if($LastExitCode -ne 0)
615+
{
616+
Write-Output "::error ::Dependency installation via Chocolatey failed."
617+
exit $LastExitCode
618+
}
614619
nuget install clcache -OutputDirectory "c:\tools" -ExcludeVersion -Version 4.1.0
615620
echo "c:\tools\clcache\clcache-4.1.0" >> $env:GITHUB_PATH
616621
Invoke-WebRequest -Uri https://github.com/Z3Prover/z3/releases/download/z3-4.8.10/z3-4.8.10-x64-win.zip -OutFile .\z3.zip
@@ -664,6 +669,11 @@ jobs:
664669
- name: Fetch dependencies
665670
run: |
666671
choco install -y winflexbison3 strawberryperl wget
672+
if($LastExitCode -ne 0)
673+
{
674+
Write-Output "::error ::Dependency installation via Chocolatey failed."
675+
exit $LastExitCode
676+
}
667677
nuget install clcache -OutputDirectory "c:\tools" -ExcludeVersion -Version 4.1.0
668678
echo "c:\tools\clcache\clcache-4.1.0" >> $env:GITHUB_PATH
669679
echo "c:\ProgramData\chocolatey\bin" >> $env:GITHUB_PATH
@@ -731,6 +741,11 @@ jobs:
731741
- name: Fetch dependencies
732742
run: |
733743
choco install winflexbison3
744+
if($LastExitCode -ne 0)
745+
{
746+
Write-Output "::error ::Dependency installation via Chocolatey failed."
747+
exit $LastExitCode
748+
}
734749
nuget install clcache -OutputDirectory "c:\tools" -ExcludeVersion -Version 4.1.0
735750
echo "c:\tools\clcache\clcache-4.1.0" >> $env:GITHUB_PATH
736751
- name: Setup Visual Studio environment

0 commit comments

Comments
 (0)