From 69b3e075ed8874f7934c1bbc9ef2860e8e11bb30 Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Tue, 25 Jan 2022 16:08:22 +0100 Subject: [PATCH 1/2] Windows Build: Fail early on all errors Currently, build errors such as failure to download Qt do not fail the script. As such, they do not fail the workflow step either. The workflow continues and fails at a very late stage, which is annoying and wastes ressources. This commit sets `$ErrorActionPreference = "Stop"` for all relevant PowerShell scripts in order to fail early for PowerShell-internal errors. This commits also adds exit code checks for all relevant external commands as PowerShell does not consider them to be errors otherwise. Fixes #2276 Co-authored-by: ann0see <20726856+ann0see@users.noreply.github.com> --- .../autobuild_windowsinstaller_1_prepare.ps1 | 23 +++++++++++++++++++ .../autobuild_windowsinstaller_2_build.ps1 | 9 +++++++- ...utobuild_windowsinstaller_3_copy_files.ps1 | 9 +++++++- windows/deploy_windows.ps1 | 9 ++++---- 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1 b/autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1 index d4f837b52b..af6c0d79e5 100644 --- a/autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1 +++ b/autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1 @@ -12,6 +12,8 @@ param( [string] $BuildOption = "" ) +# Fail early on all errors +$ErrorActionPreference = "Stop" ################### ### PROCEDURE ### @@ -20,13 +22,26 @@ param( echo "Install Qt..." # Install Qt pip install aqtinstall +if ( !$? ) +{ + throw "pip install aqtinstall failed with exit code $LastExitCode" +} + echo "Get Qt 64 bit..." # intermediate solution if the main server is down: append e.g. " -b https://mirrors.ocf.berkeley.edu/qt/" to the "aqt"-line below aqt install --outputdir C:\Qt 5.15.2 windows desktop win64_msvc2019_64 +if ( !$? ) +{ + throw "64bit Qt installation failed with exit code $LastExitCode" +} echo "Get Qt 32 bit..." # intermediate solution if the main server is down: append e.g. " -b https://mirrors.ocf.berkeley.edu/qt/" to the "aqt"-line below aqt install --outputdir C:\Qt 5.15.2 windows desktop win32_msvc2019 +if ( !$? ) +{ + throw "32bit Qt installation failed with exit code $LastExitCode" +} ################################# @@ -38,9 +53,17 @@ if ($BuildOption -Eq "jackonwindows") echo "Install JACK2 64-bit..." # Install JACK2 64-bit choco install --no-progress -y jack + if ( !$? ) + { + throw "64bit jack installation failed with exit code $LastExitCode" + } echo "Install JACK2 32-bit..." # Install JACK2 32-bit (need to force choco install as it detects 64 bits as installed) choco install --no-progress -y -f --forcex86 jack + if ( !$? ) + { + throw "32bit jack installation failed with exit code $LastExitCode" + } } diff --git a/autobuild/windows/autobuild_windowsinstaller_2_build.ps1 b/autobuild/windows/autobuild_windowsinstaller_2_build.ps1 index 84493d7823..6ec1e0409e 100644 --- a/autobuild/windows/autobuild_windowsinstaller_2_build.ps1 +++ b/autobuild/windows/autobuild_windowsinstaller_2_build.ps1 @@ -2,7 +2,6 @@ # autobuild_2_build: actual build process - #################### ### PARAMETERS ### #################### @@ -12,6 +11,10 @@ param ( [string] $jamulus_project_path = $Env:jamulus_project_path, [string] $BuildOption = "" ) + +# Fail early on all errors +$ErrorActionPreference = "Stop" + # Sanity check of parameters if (("$jamulus_project_path" -eq $null) -or ("$jamulus_project_path" -eq "")) { throw "expecting ""jamulus_project_path"" as parameter or ENV" @@ -36,3 +39,7 @@ else { powershell "$jamulus_project_path\windows\deploy_windows.ps1" "C:\Qt\5.15.2" } +if ( !$? ) +{ + throw "deploy_windows.ps1 failed with exit code $LastExitCode" +} diff --git a/autobuild/windows/autobuild_windowsinstaller_3_copy_files.ps1 b/autobuild/windows/autobuild_windowsinstaller_3_copy_files.ps1 index 67b2f15813..02a87163b3 100644 --- a/autobuild/windows/autobuild_windowsinstaller_3_copy_files.ps1 +++ b/autobuild/windows/autobuild_windowsinstaller_3_copy_files.ps1 @@ -2,7 +2,6 @@ # autobuild_3_copy_files: copy the built files to deploy folder - #################### ### PARAMETERS ### #################### @@ -13,6 +12,10 @@ param ( [string] $jamulus_buildversionstring = $Env:jamulus_buildversionstring, [string] $BuildOption = "" ) + +# Fail early on all errors +$ErrorActionPreference = "Stop" + # Sanity check of parameters if (("$jamulus_project_path" -eq $null) -or ("$jamulus_project_path" -eq "")) { throw "expecting ""jamulus_project_path"" as parameter or ENV" @@ -51,6 +54,10 @@ else echo "rename deploy file to $artifact_deploy_filename" cp "$jamulus_project_path\deploy\Jamulus*installer-win.exe" "$jamulus_project_path\deploy\$artifact_deploy_filename" +if ( !$? ) +{ + throw "cp failed with exit code $LastExitCode"; +} Function github_output_value diff --git a/windows/deploy_windows.ps1 b/windows/deploy_windows.ps1 index 4084f20e07..77190118e2 100644 --- a/windows/deploy_windows.ps1 +++ b/windows/deploy_windows.ps1 @@ -1,4 +1,4 @@ -param( +param ( # Replace default path with system Qt installation folder if necessary [string] $QtInstallPath = "C:\Qt\5.15.2", [string] $QtCompile32 = "msvc2019", @@ -10,6 +10,9 @@ param( [string] $BuildOption = "" ) +# Fail early on all errors +$ErrorActionPreference = "Stop" + # change directory to the directory above (if needed) Set-Location -Path "$PSScriptRoot\..\" @@ -20,10 +23,6 @@ $DeployPath = "$RootPath\deploy" $WindowsPath ="$RootPath\windows" $AppName = "Jamulus" -# Stop at all errors -$ErrorActionPreference = "Stop" - - # Execute native command with errorlevel handling Function Invoke-Native-Command { param( From 15db09e4da3beacbb5a130767217c142828feecc Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Tue, 25 Jan 2022 18:24:29 +0100 Subject: [PATCH 2/2] Windows Build: Clean up style/wording --- autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1 | 1 - autobuild/windows/autobuild_windowsinstaller_2_build.ps1 | 2 +- .../windows/autobuild_windowsinstaller_3_copy_files.ps1 | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1 b/autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1 index af6c0d79e5..50d8789d26 100644 --- a/autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1 +++ b/autobuild/windows/autobuild_windowsinstaller_1_prepare.ps1 @@ -66,4 +66,3 @@ if ($BuildOption -Eq "jackonwindows") throw "32bit jack installation failed with exit code $LastExitCode" } } - diff --git a/autobuild/windows/autobuild_windowsinstaller_2_build.ps1 b/autobuild/windows/autobuild_windowsinstaller_2_build.ps1 index 6ec1e0409e..b18394de1e 100644 --- a/autobuild/windows/autobuild_windowsinstaller_2_build.ps1 +++ b/autobuild/windows/autobuild_windowsinstaller_2_build.ps1 @@ -19,7 +19,7 @@ $ErrorActionPreference = "Stop" if (("$jamulus_project_path" -eq $null) -or ("$jamulus_project_path" -eq "")) { throw "expecting ""jamulus_project_path"" as parameter or ENV" } elseif (!(Test-Path -Path $jamulus_project_path)) { - throw "non.existing jamulus_project_path: $jamulus_project_path" + throw "non-existing jamulus_project_path: $jamulus_project_path" } else { echo "jamulus_project_path is valid: $jamulus_project_path" } diff --git a/autobuild/windows/autobuild_windowsinstaller_3_copy_files.ps1 b/autobuild/windows/autobuild_windowsinstaller_3_copy_files.ps1 index 02a87163b3..dabd6660c2 100644 --- a/autobuild/windows/autobuild_windowsinstaller_3_copy_files.ps1 +++ b/autobuild/windows/autobuild_windowsinstaller_3_copy_files.ps1 @@ -41,8 +41,8 @@ switch ($BuildOption) ### PROCEDURE ### ################### -# Rename the file -echo "rename" +# Copy the file +echo "copy" if ($BuildOption -ne "") { $artifact_deploy_filename = "jamulus_${Env:jamulus_buildversionstring}_win_${BuildOption}.exe" @@ -52,7 +52,7 @@ else $artifact_deploy_filename = "jamulus_${Env:jamulus_buildversionstring}_win.exe" } -echo "rename deploy file to $artifact_deploy_filename" +echo "copying deploy file to $artifact_deploy_filename" cp "$jamulus_project_path\deploy\Jamulus*installer-win.exe" "$jamulus_project_path\deploy\$artifact_deploy_filename" if ( !$? ) {