This repository has been archived on 2026-10-29. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
EveFlutter/scripts/capture-linux-flutter-parity.ps1
2026-07-10 09:57:05 +01:00

68 lines
2.9 KiB
PowerShell

param(
[string] $SshTarget = "nightwing",
[ValidateSet("phone", "tablet", "desktop")]
[string] $ViewportId = "desktop",
[string] $FixtureId = "cultui-inspector",
[Parameter(Mandatory = $true)]
[string] $SurfacePath,
[string] $LocalFlutterRoot = "E:\Projects\Eve\tools\deps\flutter",
[string] $OutputPath = "artifacts\parity\linux-flutter-cultui-inspector.png",
[string] $RemoteRoot = "~/.local/share/gamecult/eve-parity-runner",
[string] $RemoteFlutter = "~/.local/share/gamecult/flutter/bin/flutter"
)
$ErrorActionPreference = "Stop"
$projectRoot = Split-Path -Parent $PSScriptRoot
$sourceRoot = $projectRoot
$assetPath = Join-Path $sourceRoot "assets\current-surface.json"
$fontDir = Join-Path $sourceRoot "assets\fonts"
$absoluteOutput = if ([System.IO.Path]::IsPathRooted($OutputPath)) { $OutputPath } else { Join-Path $projectRoot $OutputPath }
$archivePath = Join-Path ([System.IO.Path]::GetTempPath()) "eve-parity-linux-$([guid]::NewGuid()).tar"
New-Item -ItemType Directory -Force (Split-Path -Parent $absoluteOutput) | Out-Null
New-Item -ItemType Directory -Force (Split-Path -Parent $assetPath) | Out-Null
New-Item -ItemType Directory -Force $fontDir | Out-Null
if (-not (Test-Path $sourceRoot)) {
throw "Flutter parity source not found: $sourceRoot"
}
Copy-Item -LiteralPath $SurfacePath -Destination $assetPath -Force
Copy-Item -LiteralPath (Join-Path $LocalFlutterRoot "bin\cache\artifacts\material_fonts\roboto-regular.ttf") -Destination (Join-Path $fontDir "Roboto-Regular.ttf") -Force
Copy-Item -LiteralPath (Join-Path $LocalFlutterRoot "bin\cache\artifacts\material_fonts\roboto-bold.ttf") -Destination (Join-Path $fontDir "Roboto-Bold.ttf") -Force
try {
Push-Location $sourceRoot
try {
tar --exclude .dart_tool --exclude build -cf $archivePath .
if ($LASTEXITCODE -ne 0) {
throw "tar failed with exit code $LASTEXITCODE"
}
} finally {
Pop-Location
}
ssh $SshTarget "rm -rf $RemoteRoot && mkdir -p $RemoteRoot"
scp $archivePath "${SshTarget}:/tmp/eve-parity-linux.tar" | Out-Host
ssh $SshTarget "tar -xf /tmp/eve-parity-linux.tar -C $RemoteRoot && rm /tmp/eve-parity-linux.tar"
ssh $SshTarget "cd $RemoteRoot && $RemoteFlutter test --update-goldens --dart-define=EVE_PARITY_FIXTURE=$FixtureId --plain-name $ViewportId" | Out-Host
if ($LASTEXITCODE -ne 0) {
throw "Nightwing Flutter golden smoke failed with exit code $LASTEXITCODE"
}
$remoteGolden = "$RemoteRoot/test/goldens/$FixtureId-$ViewportId.png"
scp "${SshTarget}:$remoteGolden" $absoluteOutput | Out-Host
if ($LASTEXITCODE -ne 0) {
throw "scp from Nightwing failed with exit code $LASTEXITCODE"
}
} finally {
if (Test-Path $archivePath) {
Remove-Item -LiteralPath $archivePath -Force
}
}
if (-not (Test-Path $absoluteOutput) -or (Get-Item $absoluteOutput).Length -le 0) {
throw "Nightwing Flutter capture did not produce a PNG: $absoluteOutput"
}
Write-Host $absoluteOutput