ci(windows): atomic restore+build to close inter-step deletion window
build-windows / build-windows-x64 (push) Failing after 1h0m29s

This commit is contained in:
2026-05-04 22:27:13 +02:00
parent 9f131e7113
commit fa725b4846
+41 -15
View File
@@ -237,27 +237,53 @@ jobs:
throw "target\release\librustdesk.dll missing after cargo build"
}
- name: Restore flutter/windows if cargo build wiped it
shell: bash
run: |
if [ ! -d flutter/windows ]; then
echo "flutter/windows missing after cargo build -- restoring from git"
git status --porcelain | grep -E "flutter/windows" | head -10 || true
git checkout HEAD -- flutter/windows
fi
test -d flutter/windows && echo "flutter/windows present: $(find flutter/windows -type f | wc -l) files"
test -f flutter/windows/CMakeLists.txt || { echo "CMakeLists.txt missing"; exit 1; }
- name: Flutter build windows
# Restore + build are intentionally one step. flutter/windows has been
# observed to disappear between steps on this runner (cause unidentified --
# likely Windows Defender quarantine, possibly act_runner workspace handling).
# Keeping them atomic eliminates any window of opportunity for that to happen.
- name: Flutter build windows (with last-second restore)
shell: pwsh
run: |
$cmake = '.\flutter\windows\CMakeLists.txt'
Write-Host "== Pre-flight check =="
Write-Host "pwd: $(Get-Location)"
if (Test-Path .\flutter\windows) {
Write-Host "flutter/windows present: $((Get-ChildItem -Recurse .\flutter\windows -File).Count) files"
} else {
Write-Host "flutter/windows MISSING"
}
if (-not (Test-Path $cmake)) {
Write-Host "`n== Restoring flutter/windows from git index =="
git status --porcelain | Where-Object { $_ -match 'flutter/windows' } | Select-Object -First 10
git checkout HEAD -- flutter/windows
if ($LASTEXITCODE -ne 0) { throw "git checkout HEAD -- flutter/windows failed" }
if (-not (Test-Path $cmake)) {
Write-Host "git ls-files flutter/windows:"
git ls-files flutter/windows | Select-Object -First 5
throw "Restore did not produce $cmake"
}
Write-Host "Restored: $((Get-ChildItem -Recurse .\flutter\windows -File).Count) files"
}
# Touch a marker so we can confirm later (in logs) that this guard ran.
$marker = ".\flutter\windows\.restored-at"
Set-Content -Path $marker -Value (Get-Date -Format o)
Write-Host "`n== Running flutter build windows --release =="
Push-Location flutter
flutter build windows --release
if ($LASTEXITCODE -ne 0) { throw "flutter build windows failed" }
$rc = $LASTEXITCODE
Pop-Location
if ($rc -ne 0) {
Write-Host "`n!! flutter build failed -- post-mortem state of flutter/windows: !!"
if (Test-Path .\flutter\windows) { Get-ChildItem .\flutter\windows -Force }
else { Write-Host "(does not exist)" }
throw "flutter build windows failed ($rc)"
}
# Mirror what build.py's build_flutter_windows() does after flutter build:
# copy the virtual_display dylib next to rustdesk.exe.
# Mirror what build.py's build_flutter_windows() does after flutter build.
Copy-Item -Force `
target\release\deps\dylib_virtual_display.dll `
flutter\build\windows\x64\runner\Release\