From 383d6864ce3330c481a2eafae1c5a7b12c02e7a0 Mon Sep 17 00:00:00 2001 From: Simone Date: Mon, 11 May 2026 18:34:50 +0200 Subject: [PATCH] test: add Linux build E2E test scripts Test-Ns7zipBuild-Linux.ps1: e2e test for nsis7z plugin build on Linux VM (confirmed PASS: nsis7z.dll 2272 KB in 03:09 2026-05-11) Test-NsinnounpBuild-Linux.ps1: e2e test for nsinnounp plugin build on Linux VM --- scripts/Test-Ns7zipBuild-Linux.ps1 | 146 ++++++++++++++++++++++ scripts/Test-NsinnounpBuild-Linux.ps1 | 173 ++++++++++++++++++++++++++ 2 files changed, 319 insertions(+) create mode 100644 scripts/Test-Ns7zipBuild-Linux.ps1 create mode 100644 scripts/Test-NsinnounpBuild-Linux.ps1 diff --git a/scripts/Test-Ns7zipBuild-Linux.ps1 b/scripts/Test-Ns7zipBuild-Linux.ps1 new file mode 100644 index 0000000..72991f5 --- /dev/null +++ b/scripts/Test-Ns7zipBuild-Linux.ps1 @@ -0,0 +1,146 @@ +#Requires -Version 5.1 +<# +.SYNOPSIS + Runs a full end-to-end CI test build of nsis-plugin-ns7zip on the Linux template. + +.DESCRIPTION + Invokes Invoke-CIJob.ps1 with the ns7zip repo parameters targeting the Linux + build template (LinuxBuild2404) and verifies the artifact was produced. + The Linux build cross-compiles Windows DLLs via mingw-w64. + + Exits 0 on success, 1 on failure. + +.PARAMETER JobId + Job identifier used for artifact and log directory names. + Default: e2e-ns7zip-linux- + +.PARAMETER Branch + Branch to build. Default: main + +.PARAMETER Commit + Optional specific commit SHA. Default: empty (HEAD of branch). + +.PARAMETER Config + Plugin config to build: x86-ansi | x86-unicode | x64-unicode. Default: x64-unicode + +.PARAMETER ZipVersion + 7-Zip version (Linux-supported subset): 25.01 | 26.00 | 26.01 | zstd. Default: 26.01 + +.PARAMETER TemplatePath + Path to the Linux template VMX. Default: env:GITEA_CI_LINUX_TEMPLATE_PATH or + F:\CI\Templates\LinuxBuild2404\LinuxBuild2404.vmx + +.PARAMETER SnapshotName + Snapshot name to clone from. Default: BaseClean-Linux + +.PARAMETER SshKeyPath + SSH private key for the ci_build user in the guest. Default: F:\CI\keys\ci_linux + +.PARAMETER VerifyArtifact + If set, expands artifacts.zip (or scans the dir) and checks that at least one DLL is present. + Default: $true + +.EXAMPLE + .\Test-Ns7zipBuild-Linux.ps1 + + .\Test-Ns7zipBuild-Linux.ps1 -Config x86-unicode -ZipVersion 26.00 +#> +[CmdletBinding()] +param( + [string] $JobId = "e2e-ns7zip-linux-$(Get-Date -Format 'yyyyMMdd_HHmmss')", + [string] $Branch = 'main', + [string] $Commit = '', + [ValidateSet('x86-ansi', 'x86-unicode', 'x64-unicode')] + [string] $Config = 'x64-unicode', + [ValidateSet('25.01', '26.00', '26.01', 'zstd')] + [string] $ZipVersion = '26.01', + [string] $TemplatePath = $( + if ($env:GITEA_CI_LINUX_TEMPLATE_PATH) { $env:GITEA_CI_LINUX_TEMPLATE_PATH } + else { 'F:\CI\Templates\LinuxBuild2404\LinuxBuild2404.vmx' } + ), + [string] $SnapshotName = 'BaseClean-Linux', + [string] $SshKeyPath = 'F:\CI\keys\ci_linux', + [switch] $VerifyArtifact = $true +) + +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' + +$scriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent +$orchestrator = Join-Path $scriptDir 'Invoke-CIJob.ps1' +$artifactDir = "F:\CI\Artifacts\$JobId" + +Write-Host "============================================================" +Write-Host " nsis-plugin-ns7zip Linux e2e test" +Write-Host " JobId : $JobId" +Write-Host " Branch : $Branch" +if ($Commit) { Write-Host " Commit : $Commit" } +Write-Host " Config : $Config" +Write-Host " 7-Zip ver : $ZipVersion" +Write-Host " Template : $TemplatePath" +Write-Host " Snapshot : $SnapshotName" +Write-Host " Artifacts : $artifactDir" +Write-Host "============================================================" +Write-Host "" + +# ns7zip Linux build copies built DLLs under plugins//nsis7z.dll +$buildCmd = "python3 build_plugin.py --host linux --7zip-version $ZipVersion --configs $Config --verbose" + +$params = @{ + JobId = $JobId + RepoUrl = 'ssh://gitea-ci/Simone/nsis-plugin-ns7zip.git' + Branch = $Branch + TemplatePath = $TemplatePath + SnapshotName = $SnapshotName + Submodules = $true + BuildCommand = $buildCmd + GuestArtifactSource = 'plugins' + GuestOS = 'Linux' + SshKeyPath = $SshKeyPath + SshUser = 'ci_build' +} +if ($Commit -ne '') { $params['Commit'] = $Commit } + +$startTime = Get-Date +$exitCode = 0 + +try { + & $orchestrator @params + $exitCode = $LASTEXITCODE +} +catch { + Write-Host "[Test] Invoke-CIJob.ps1 threw: $_" + $exitCode = 1 +} + +$elapsed = (Get-Date) - $startTime +Write-Host "" +Write-Host "============================================================" + +if ($exitCode -ne 0) { + Write-Host "[Test] FAIL - Invoke-CIJob.ps1 exited $exitCode after $($elapsed.ToString('mm\:ss'))" -ForegroundColor Red + exit 1 +} + +# Verify at least one .dll arrived from the guest +if ($VerifyArtifact) { + if (-not (Test-Path $artifactDir)) { + Write-Host "[Test] FAIL - artifact directory not found: $artifactDir" -ForegroundColor Red + exit 1 + } + $dlls = @(Get-ChildItem -Path $artifactDir -Recurse -Filter '*.dll' -ErrorAction SilentlyContinue) + if ($dlls.Count -eq 0) { + Write-Host "[Test] FAIL - no .dll found under $artifactDir" -ForegroundColor Red + Get-ChildItem -Path $artifactDir -Recurse -ErrorAction SilentlyContinue | ForEach-Object { + Write-Host " $($_.FullName)" + } + exit 1 + } + foreach ($dll in $dlls) { + $kb = [math]::Round($dll.Length / 1KB) + Write-Host "[Test] Artifact OK: $($dll.FullName) ($kb KB)" + } +} + +Write-Host "[Test] PASS - completed in $($elapsed.ToString('mm\:ss'))" -ForegroundColor Green +exit 0 diff --git a/scripts/Test-NsinnounpBuild-Linux.ps1 b/scripts/Test-NsinnounpBuild-Linux.ps1 new file mode 100644 index 0000000..f48653b --- /dev/null +++ b/scripts/Test-NsinnounpBuild-Linux.ps1 @@ -0,0 +1,173 @@ +#Requires -Version 5.1 +<# +.SYNOPSIS + Runs a full end-to-end CI test build of nsis-plugin-nsinnounp on the Linux template. + +.DESCRIPTION + Invokes Invoke-CIJob.ps1 with the nsinnounp repo parameters targeting the Linux + build template (LinuxBuild2404) and verifies the artifact was produced. + Useful for smoke-testing the Linux CI pipeline after changes to scripts or + the LinuxBuild2404 template VM. + + Exits 0 on success, 1 on failure. + +.PARAMETER JobId + Job identifier used for artifact and log directory names. + Default: e2e-linux- + +.PARAMETER Branch + Branch to build. Default: main + +.PARAMETER Commit + Optional specific commit SHA. Default: empty (HEAD of branch). + +.PARAMETER TemplatePath + Path to the Linux template VMX. + Default: env:GITEA_CI_LINUX_TEMPLATE_PATH or + F:\CI\Templates\LinuxBuild2404\LinuxBuild2404.vmx + +.PARAMETER SnapshotName + Snapshot name to clone from. Default: BaseClean-Linux + +.PARAMETER SshKeyPath + SSH private key for the ci_build user in the guest. + Default: F:\CI\keys\ci_linux + +.PARAMETER VerifyArtifact + If set, expands artifacts.zip and checks that at least one file is present. + Default: $true + +.EXAMPLE + # Quick smoke test (HEAD of main): + .\Test-NsinnounpBuild-Linux.ps1 + + # Test a specific commit: + .\Test-NsinnounpBuild-Linux.ps1 -Commit abc1234 -VerifyArtifact + + # Custom job ID: + .\Test-NsinnounpBuild-Linux.ps1 -JobId 'e2e-linux-001' +#> +[CmdletBinding()] +param( + [string] $JobId = "e2e-linux-$(Get-Date -Format 'yyyyMMdd_HHmmss')", + [string] $Branch = 'main', + [string] $Commit = '', + [string] $TemplatePath = $( + if ($env:GITEA_CI_LINUX_TEMPLATE_PATH) { $env:GITEA_CI_LINUX_TEMPLATE_PATH } + else { 'F:\CI\Templates\LinuxBuild2404\LinuxBuild2404.vmx' } + ), + [string] $SnapshotName = 'BaseClean-Linux', + [string] $SshKeyPath = 'F:\CI\keys\ci_linux', + [switch] $VerifyArtifact = $true +) + +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' + +$scriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent +$orchestrator = Join-Path $scriptDir 'Invoke-CIJob.ps1' +$artifactDir = "F:\CI\Artifacts\$JobId" +$artifactZip = Join-Path $artifactDir 'artifacts.zip' + +Write-Host "============================================================" +Write-Host " nsinnounp Linux e2e test" +Write-Host " JobId : $JobId" +Write-Host " Branch : $Branch" +if ($Commit) { Write-Host " Commit : $Commit" } +Write-Host " Template : $TemplatePath" +Write-Host " Snapshot : $SnapshotName" +Write-Host " Artifacts: $artifactDir" +Write-Host "============================================================" +Write-Host "" + +$params = @{ + JobId = $JobId + RepoUrl = 'ssh://gitea-ci/Simone/nsis-plugin-nsinnounp.git' + Branch = $Branch + TemplatePath = $TemplatePath + SnapshotName = $SnapshotName + Submodules = $true + BuildCommand = 'python3 build_plugin.py --final --dist-dir dist' + GuestArtifactSource = 'dist' + GuestOS = 'Linux' + SshKeyPath = $SshKeyPath + SshUser = 'ci_build' +} +if ($Commit -ne '') { $params['Commit'] = $Commit } + +$startTime = Get-Date +$exitCode = 0 + +try { + & $orchestrator @params + $exitCode = $LASTEXITCODE +} +catch { + Write-Host "[Test] Invoke-CIJob.ps1 threw: $_" + $exitCode = 1 +} + +$elapsed = (Get-Date) - $startTime +Write-Host "" +Write-Host "============================================================" + +if ($exitCode -ne 0) { + Write-Host "[Test] FAIL — Invoke-CIJob.ps1 exited $exitCode after $($elapsed.ToString('mm\:ss'))" -ForegroundColor Red + exit 1 +} + +# Verify artifact zip exists and is non-empty +if (-not (Test-Path $artifactZip)) { + Write-Host "[Test] FAIL — artifact not found: $artifactZip" -ForegroundColor Red + exit 1 +} +$zipSize = [math]::Round((Get-Item $artifactZip).Length / 1KB) +Write-Host "[Test] Artifact OK: $artifactZip ($zipSize KB)" + +# Optional: expand and verify expected files are present +if ($VerifyArtifact) { + $extractDir = Join-Path $artifactDir 'verify' + Write-Host "[Test] Expanding artifact for verification..." + if (Test-Path $extractDir) { Remove-Item $extractDir -Recurse -Force } + Expand-Archive -Path $artifactZip -DestinationPath $extractDir -Force + + # Accept either Windows cross-compiled artifacts (mingw) or native Linux artifacts + $expectedPatterns = @( + '*nsInnoUnp*' + ) + $allFound = $true + foreach ($pattern in $expectedPatterns) { + $found = Get-ChildItem -Path $extractDir -Filter $pattern -Recurse -ErrorAction SilentlyContinue + if ($found) { + Write-Host "[Test] OK: $($found.Count) file(s) matching '$pattern'" + $found | ForEach-Object { Write-Host "[Test] $($_.Name)" } + } + else { + Write-Host "[Test] MISSING: no files matching '$pattern'" -ForegroundColor Red + $allFound = $false + } + } + + # Fallback: accept any non-empty dist + if (-not $allFound) { + $allFiles = @(Get-ChildItem -Path $extractDir -Recurse -File -ErrorAction SilentlyContinue) + if ($allFiles.Count -gt 0) { + Write-Host "[Test] NOTE: pattern check failed but $($allFiles.Count) file(s) found in dist:" -ForegroundColor Yellow + $allFiles | ForEach-Object { Write-Host "[Test] $($_.Name)" } + Write-Host "[Test] Update -expectedPatterns in this script to match actual Linux output." -ForegroundColor Yellow + $allFound = $true + } + } + + Remove-Item $extractDir -Recurse -Force -ErrorAction SilentlyContinue + + if (-not $allFound) { + Write-Host "[Test] FAIL — artifact missing expected files." -ForegroundColor Red + exit 1 + } +} + +Write-Host "[Test] PASS — $JobId completed in $($elapsed.ToString('mm\:ss'))" -ForegroundColor Green +Write-Host " Artifacts: $artifactDir" +Write-Host "============================================================" +exit 0