From 906b1a0bc4b8cb04e9eb879c26a4a5e3a7297fc9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 12 Sep 2022 12:29:57 -0400 Subject: ci: allow powershell variables assigned in env scripts to persist Load env scripts with `.` sourcing instead of `Invoke-Expression`. This allows powershell variables to persist, much like bash. Leave helper script loading unchanged, as those scripts may set powershell variables that we do not want to persist. --- .gitlab/ci/env.ps1 | 2 +- .gitlab/ci/env_windows_vs2022_x64_ninja.ps1 | 2 +- .gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 | 2 +- .gitlab/os-windows.yml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab/ci/env.ps1 b/.gitlab/ci/env.ps1 index e24bc37..aa7753f 100755 --- a/.gitlab/ci/env.ps1 +++ b/.gitlab/ci/env.ps1 @@ -1,3 +1,3 @@ if (Test-Path -Path ".gitlab/ci/env_$env:CMAKE_CONFIGURATION.ps1" -PathType Leaf) { - Invoke-Expression ".gitlab/ci/env_$env:CMAKE_CONFIGURATION.ps1" + . ".gitlab/ci/env_$env:CMAKE_CONFIGURATION.ps1" } diff --git a/.gitlab/ci/env_windows_vs2022_x64_ninja.ps1 b/.gitlab/ci/env_windows_vs2022_x64_ninja.ps1 index f8a86c4..a96658d 100755 --- a/.gitlab/ci/env_windows_vs2022_x64_ninja.ps1 +++ b/.gitlab/ci/env_windows_vs2022_x64_ninja.ps1 @@ -1,3 +1,3 @@ if ("$env:CMAKE_CI_NIGHTLY" -eq "true") { - Invoke-Expression ".gitlab/ci/ispc-env.ps1" + . ".gitlab/ci/ispc-env.ps1" } diff --git a/.gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 b/.gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 index e8d242c..f245319 100755 --- a/.gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 +++ b/.gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 @@ -1,5 +1,5 @@ if ("$env:CMAKE_CI_NIGHTLY" -eq "true") { - Invoke-Expression -Command ".gitlab/ci/ispc-env.ps1" + . ".gitlab/ci/ispc-env.ps1" } $pwdpath = $pwd.Path diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml index 282cf1e..92538a1 100644 --- a/.gitlab/os-windows.yml +++ b/.gitlab/os-windows.yml @@ -293,7 +293,7 @@ ## Windows-specific scripts .before_script_windows: &before_script_windows - - Invoke-Expression -Command .gitlab/ci/env.ps1 + - . .gitlab/ci/env.ps1 - $pwdpath = $pwd.Path - powershell -File ".gitlab/ci/wix.ps1" - Set-Item -Force -Path "env:WIX" -Value "$pwdpath\.gitlab\wix" @@ -352,7 +352,7 @@ stage: test-ext script: - - Invoke-Expression -Command .gitlab/ci/env.ps1 + - . .gitlab/ci/env.ps1 - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake interruptible: true -- cgit v0.12 From de32c8ddbe0766fe534e4af20f801b7fd8f72e14 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 9 Sep 2022 15:18:59 -0400 Subject: ci: start every windows job with custom environment script --- .gitlab/os-windows.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml index 92538a1..b4aa0eb 100644 --- a/.gitlab/os-windows.yml +++ b/.gitlab/os-windows.yml @@ -361,6 +361,7 @@ stage: test-ext script: + - . .gitlab/ci/env.ps1 - Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake @@ -370,6 +371,7 @@ stage: test-ext script: + - . .gitlab/ci/env.ps1 - Invoke-Expression -Command .gitlab/ci/jom.ps1 - $pwdpath = $pwd.Path - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\jom;$env:PATH" @@ -382,6 +384,7 @@ stage: test-ext script: + - . .gitlab/ci/env.ps1 - Invoke-Expression -Command .gitlab/ci/borland.ps1 - $pwdpath = $pwd.Path - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\bcc\bin;$env:PATH" @@ -393,6 +396,7 @@ stage: test-ext script: + - . .gitlab/ci/env.ps1 - $pwdpath = $pwd.Path - powershell -File ".gitlab/ci/ninja.ps1" - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab;$env:PATH" @@ -407,6 +411,7 @@ stage: test-ext script: + - . .gitlab/ci/env.ps1 - Invoke-Expression -Command .gitlab/ci/msvc.ps1 - Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake @@ -417,6 +422,7 @@ stage: test-ext script: + - . .gitlab/ci/env.ps1 - Invoke-Expression -Command .gitlab/ci/openwatcom.ps1 - $pwdpath = $pwd.Path - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\watcom\binnt;$pwdpath\.gitlab\watcom\binw;$env:PATH" -- cgit v0.12 From 94b27ccc361973cbbb19c715d702369a82efc700 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 9 Sep 2022 15:20:07 -0400 Subject: ci: add support for gitlab-runner 'shell = pwsh' executor Run powershell child scripts using the same powershell tool as the parent script. --- .gitlab/ci/env.ps1 | 1 + .gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 | 2 +- .gitlab/ci/ispc-env.ps1 | 2 +- .gitlab/os-windows.yml | 8 ++++---- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitlab/ci/env.ps1 b/.gitlab/ci/env.ps1 index aa7753f..72a8cb8 100755 --- a/.gitlab/ci/env.ps1 +++ b/.gitlab/ci/env.ps1 @@ -1,3 +1,4 @@ +$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().MainModule.FileName if (Test-Path -Path ".gitlab/ci/env_$env:CMAKE_CONFIGURATION.ps1" -PathType Leaf) { . ".gitlab/ci/env_$env:CMAKE_CONFIGURATION.ps1" } diff --git a/.gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 b/.gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 index f245319..e5f538a 100755 --- a/.gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 +++ b/.gitlab/ci/env_windows_vs2022_x64_ninja_multi.ps1 @@ -3,7 +3,7 @@ if ("$env:CMAKE_CI_NIGHTLY" -eq "true") { } $pwdpath = $pwd.Path -powershell -File ".gitlab/ci/ninja.ps1" +& "$pwsh" -File ".gitlab/ci/ninja.ps1" Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab;$env:PATH" ninja --version diff --git a/.gitlab/ci/ispc-env.ps1 b/.gitlab/ci/ispc-env.ps1 index 1baea31..816c485 100755 --- a/.gitlab/ci/ispc-env.ps1 +++ b/.gitlab/ci/ispc-env.ps1 @@ -1,4 +1,4 @@ $pwdpath = $pwd.Path -powershell -File ".gitlab/ci/ispc.ps1" +& "$pwsh" -File ".gitlab/ci/ispc.ps1" Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\ispc\bin;$env:PATH" ispc --version diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml index b4aa0eb..5c6be11 100644 --- a/.gitlab/os-windows.yml +++ b/.gitlab/os-windows.yml @@ -295,11 +295,11 @@ .before_script_windows: &before_script_windows - . .gitlab/ci/env.ps1 - $pwdpath = $pwd.Path - - powershell -File ".gitlab/ci/wix.ps1" + - (& "$pwsh" -File ".gitlab/ci/wix.ps1") - Set-Item -Force -Path "env:WIX" -Value "$pwdpath\.gitlab\wix" - - powershell -File ".gitlab/ci/cmake.ps1" + - (& "$pwsh" -File ".gitlab/ci/cmake.ps1") - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\cmake\bin;$env:PATH" - - powershell -File ".gitlab/ci/ninja.ps1" + - (& "$pwsh" -File ".gitlab/ci/ninja.ps1") - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab;$env:PATH" - (& "$env:WIX\bin\light.exe" -help) | Select -First 1 - cmake --version @@ -398,7 +398,7 @@ script: - . .gitlab/ci/env.ps1 - $pwdpath = $pwd.Path - - powershell -File ".gitlab/ci/ninja.ps1" + - (& "$pwsh" -File ".gitlab/ci/ninja.ps1") - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab;$env:PATH" - Invoke-Expression -Command .gitlab/ci/clang.ps1 - Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1 -- cgit v0.12