#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 UseGitClone If set, skips host-side git clone and delegates cloning to the guest VM. Uses -GuestRepoUrl (HTTP) instead of the SSH alias URL. Mirrors the -UseGitClone mode of Invoke-CIJob.ps1 (same as ยง3.3 for Windows). .PARAMETER GuestRepoUrl HTTP(S) URL used for in-VM clone when -UseGitClone is set. Must be reachable from inside the Linux guest VM. Default: https://gitea.emulab.it/Simone/nsis-plugin-ns7zip.git .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 # Guest-side clone (no host clone, guest fetches via HTTPS): .\Test-Ns7zipBuild-Linux.ps1 -UseGitClone #> [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] $UseGitClone, [string] $GuestRepoUrl = 'https://gitea.emulab.it/Simone/nsis-plugin-ns7zip.git', [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 " Clone mode : $(if ($UseGitClone) { 'in-VM git clone (-UseGitClone)' } else { 'host clone + tar/scp' })" 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" # Without -UseGitClone: host clones via SSH alias, transfers source via tar+scp. # With -UseGitClone: host clone is skipped; guest clones via HTTPS URL. $repoUrl = if ($UseGitClone) { $GuestRepoUrl } else { 'ssh://gitea-ci/Simone/nsis-plugin-ns7zip.git' } $params = @{ JobId = $JobId RepoUrl = $repoUrl Branch = $Branch TemplatePath = $TemplatePath SnapshotName = $SnapshotName Submodules = $true BuildCommand = $buildCmd GuestArtifactSource = 'plugins' GuestOS = 'Linux' SshKeyPath = $SshKeyPath SshUser = 'ci_build' } if ($UseGitClone) { $params['UseGitClone'] = $true } 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