From fa725b4846872ac30c44ece11e9993b49670aa8d Mon Sep 17 00:00:00 2001 From: Mike Mueller Date: Mon, 4 May 2026 22:27:13 +0200 Subject: [PATCH] ci(windows): atomic restore+build to close inter-step deletion window --- .gitea/workflows/build-windows.yml | 56 ++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/.gitea/workflows/build-windows.yml b/.gitea/workflows/build-windows.yml index cbdb66400..007d9dd98 100644 --- a/.gitea/workflows/build-windows.yml +++ b/.gitea/workflows/build-windows.yml @@ -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\