From 6b333b6e930399c73873911197ce1e63d567c034 Mon Sep 17 00:00:00 2001 From: Sonja M Thomas Date: Thu, 26 Nov 2026 17:38:30 -0600 Subject: [PATCH] Stage the native compiler under the agent execution policy --- Jenkinsfile | 5 ++-- tools/install_ci_compiler.py | 15 ---------- tools/prepare_windows_compiler.ps1 | 19 ------------- tools/prepare_windows_compiler.py | 45 ++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 36 deletions(-) delete mode 100644 tools/install_ci_compiler.py delete mode 100644 tools/prepare_windows_compiler.ps1 create mode 100644 tools/prepare_windows_compiler.py diff --git a/Jenkinsfile b/Jenkinsfile index 2881e18..18194ac 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,6 +21,7 @@ pipeline { script { env.ARM_SOURCE_COMMIT = bat(returnStdout: true, script: '@git rev-parse HEAD').trim() env.ARM_VERSION = readFile('VERSION.md').trim() + env.PYINSTALLER_CONFIG_DIR = "${env.WORKSPACE}\\.ci\\pyinstaller-cache" if (!(env.ARM_SOURCE_COMMIT ==~ /[0-9a-f]{40}/) || !(env.ARM_VERSION ==~ /v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)_(alpha|beta|rc|stable)/)) { error('Invalid Git commit or authoritative VERSION.md.') @@ -35,7 +36,7 @@ pipeline { bat 'py -3.12 -m venv .ci\\python' bat '.ci\\python\\Scripts\\python.exe -m pip install -r requirements-build.txt' bat '.ci\\python\\Scripts\\python.exe -m pip check' - bat 'powershell.exe -NoLogo -NoProfile -NonInteractive -File tools\\prepare_windows_compiler.ps1' + bat '.ci\\python\\Scripts\\python.exe tools\\prepare_windows_compiler.py' } } stage('Regression and native Windows checks') { @@ -71,7 +72,7 @@ pipeline { post { cleanup { deleteDir() - echo 'Removed the ARM build workspace. Verified candidates are stored in Jenkins archival.' + echo 'Removed the ARM build workspace. Any successfully archived artifacts remain in Jenkins.' } } } diff --git a/tools/install_ci_compiler.py b/tools/install_ci_compiler.py deleted file mode 100644 index 3012987..0000000 --- a/tools/install_ci_compiler.py +++ /dev/null @@ -1,15 +0,0 @@ -"""Extract the signed Inno compiler through its native portable installer.""" -from pathlib import Path -import sys -from uuid import uuid4 - -sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tests")) -from windows_gui import start_isolated - - -if __name__ == "__main__": - installer, destination = (Path(value).resolve() for value in sys.argv[1:]) - raise SystemExit(start_isolated( - [str(installer), "/PORTABLE=1", "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART", f"/DIR={destination}"], - f"ARM_Compiler_{uuid4().hex[:10]}", timeout=90, - )) diff --git a/tools/prepare_windows_compiler.ps1 b/tools/prepare_windows_compiler.ps1 deleted file mode 100644 index db41f37..0000000 --- a/tools/prepare_windows_compiler.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -$ErrorActionPreference = 'Stop' -$scratch = Join-Path $PWD '.ci' -$compiler = Join-Path $scratch 'inno' -$download = Join-Path $scratch 'innosetup-7.1.1-x64.exe' -$origin = 'https://github.com/jrsoftware/issrc/releases/download/is-7_1_1/innosetup-7.1.1-x64.exe' -$expected = '8a5a6711c3766a6e5fb74f280ba0e3551e719ce94538d901fdbd1f8f9920b3f0' -Invoke-WebRequest -UseBasicParsing -Uri $origin -OutFile $download -if ((Get-FileHash -LiteralPath $download -Algorithm SHA256).Hash -ine $expected) { - throw 'Inno Setup download SHA-256 mismatch' -} -$signature = Get-AuthenticodeSignature -LiteralPath $download -if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notmatch 'CN=Pyrsys B\.V\.') { - throw 'Inno Setup publisher verification failed' -} -& '.ci\python\Scripts\python.exe' tools\install_ci_compiler.py $download $compiler -if ($LASTEXITCODE -ne 0 -or -not (Test-Path -LiteralPath (Join-Path $compiler 'ISCC.exe'))) { - throw 'Portable Inno Setup staging failed' -} -Write-Host 'Inno Setup 7.1.1 x64 hash, publisher and portable staging verified.' diff --git a/tools/prepare_windows_compiler.py b/tools/prepare_windows_compiler.py new file mode 100644 index 0000000..6cab71e --- /dev/null +++ b/tools/prepare_windows_compiler.py @@ -0,0 +1,45 @@ +"""Stage the pinned Windows compiler without changing the agent's execution policy.""" +from hashlib import file_digest +from pathlib import Path +import shutil +import subprocess +import sys +from urllib.request import urlopen +from uuid import uuid4 + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT / "tests")) +from windows_gui import start_isolated + +NAME = "innosetup-7.1.1-x64.exe" +ORIGIN = f"https://github.com/jrsoftware/issrc/releases/download/is-7_1_1/{NAME}" +SHA256 = "8a5a6711c3766a6e5fb74f280ba0e3551e719ce94538d901fdbd1f8f9920b3f0" + + +def main(): + scratch = ROOT / ".ci" + installer = scratch / NAME + destination = scratch / "inno" + with urlopen(ORIGIN, timeout=60) as response, installer.open("xb") as output: + shutil.copyfileobj(response, output) + with installer.open("rb") as source: + if file_digest(source, "sha256").hexdigest() != SHA256: + raise RuntimeError("Inno Setup download SHA-256 mismatch") + signature = subprocess.check_output( + ["powershell.exe", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command", + f"(Get-AuthenticodeSignature -LiteralPath '{NAME}').Status.ToString()"], + cwd=scratch, text=True, + ).strip() + if signature != "Valid": + raise RuntimeError(f"Inno Setup Authenticode verification failed: {signature}") + code = start_isolated( + [str(installer), "/PORTABLE=1", "/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART", f"/DIR={destination}"], + f"ARM_Compiler_{uuid4().hex[:10]}", timeout=90, + ) + if code or not (destination / "ISCC.exe").is_file(): + raise RuntimeError(f"Portable Inno Setup staging failed: exit {code}") + print("Inno Setup 7.1.1 x64 hash, Authenticode and native portable staging verified.") + + +if __name__ == "__main__": + main()