From 52c764b9868101b6ce36b5904f506bd069994032 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Tue, 19 Dec 2023 17:42:18 +0530 Subject: [PATCH] ci: Fix pwsh scripts not exiting on error We all know that external utilities returning a non-zero exit code do not terminate a powershell script. However, most do not know (and neither did I) that it is impossible to promote error exit codes to script-terminating errors with ErrorActionPreference. Explicitly check the return codes and Exit. https://github.com/MicrosoftDocs/PowerShell-Docs/issues/1583 Part-of: --- ci/images_template.yml | 2 +- ci/windows-docker/Dockerfile | 4 +--- ci/windows-docker/install_gst.ps1 | 25 +++++++++++++++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ci/images_template.yml b/ci/images_template.yml index d1007d083..a206dfc1f 100644 --- a/ci/images_template.yml +++ b/ci/images_template.yml @@ -1,4 +1,4 @@ variables: - GST_RS_IMG_TAG: "2023-12-19.1" + GST_RS_IMG_TAG: "2023-12-19.2" GST_RS_STABLE: "1.74.1" GST_RS_MSRV: "1.70.0" diff --git a/ci/windows-docker/Dockerfile b/ci/windows-docker/Dockerfile index e77aa13b8..190864ba4 100644 --- a/ci/windows-docker/Dockerfile +++ b/ci/windows-docker/Dockerfile @@ -2,9 +2,7 @@ FROM "registry.freedesktop.org/gstreamer/gstreamer/amd64/windows:2023-07-17.0-main" -# Make sure any failure in PowerShell is fatal -ENV ErrorActionPreference='Stop' -SHELL ["powershell","-NoLogo", "-NonInteractive", "-Command"] +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] ARG DEFAULT_BRANCH="main" ARG RUST_VERSION="invalid" diff --git a/ci/windows-docker/install_gst.ps1 b/ci/windows-docker/install_gst.ps1 index 16119582b..10fdfa83a 100644 --- a/ci/windows-docker/install_gst.ps1 +++ b/ci/windows-docker/install_gst.ps1 @@ -1,9 +1,11 @@ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; -# Make sure powershell exits on errors -$ErrorActionPreference = "Stop" # Download gstreamer and all its subprojects git clone -b $env:DEFAULT_BRANCH --depth 1 https://gitlab.freedesktop.org/gstreamer/gstreamer.git C:\gstreamer +if (!$?) { + Write-Host "Failed to clone gstreamer" + Exit 1 +} Set-Location C:\gstreamer @@ -13,6 +15,10 @@ Move-Item C:/subprojects/* C:\gstreamer\subprojects # Update the subprojects cache Write-Output "Running meson subproject reset" meson subprojects update --reset +if (!$?) { + Write-Host "Failed to update gstreamer subprojects" + Exit 1 +} $MESON_ARGS = @(` "--prefix=C:\gst-install", ` @@ -42,9 +48,24 @@ echo "subproject('gtk')" >> meson.build Write-Output "Building gstreamer" meson setup --vsenv $MESON_ARGS _build +if (!$?) { + type "_build\meson-logs\meson-log.txt" + Write-Host "Failed to run meson setup, see log above" + Exit 1 +} + +Write-Output "Compiling gstreamer" meson compile -C _build +if (!$?) { + Write-Host "Failed to run meson compile" + Exit 1 +} # meson install does a spurious rebuild sometimes that then fails meson install --no-rebuild -C _build +if (!$?) { + Write-Host "Failed to run meson install" + Exit 1 +} cd c:\ Remove-Item -LiteralPath "C:\gstreamer" -Force -Recurse