ci: faster SDK download, supersede stale runs
Some checks failed
CI / Windows build (push) Has been cancelled

Run 9's Invoke-WebRequest download of the ~1GB SDK was very slow. Use
curl.exe (bundled on Windows 10+) which streams to disk, with an IWR
fallback. Add a concurrency group so a new push cancels an in-progress
run instead of queuing behind it.
This commit is contained in:
2026-06-21 04:30:23 +08:00
parent 74ed001d76
commit 265f127c3c

View File

@@ -8,6 +8,12 @@ on:
branches: [main]
workflow_dispatch:
# Supersede an in-progress run when a new commit is pushed (so a slow run does
# not block the next iteration). Ignored by older Gitea, harmless if so.
concurrency:
group: windows-ci
cancel-in-progress: true
# Targets a self-hosted Windows runner inside mainland China. See README
# "Continuous integration" for runner prerequisites. Key points:
# * github.com is unreachable here, so the checkout action is pulled from the
@@ -66,9 +72,19 @@ jobs:
New-Item -ItemType Directory -Force -Path $root | Out-Null
Write-Host "Downloading Flutter SDK from $url"
$ok = $false
for ($i = 1; $i -le 3 -and -not $ok; $i++) {
try { Invoke-WebRequest -Uri $url -OutFile $zip -UseBasicParsing; $ok = $true }
catch { Write-Host "download attempt $i failed: $_"; Start-Sleep 5 }
# curl.exe (bundled on Windows 10+) streams to disk and is far
# faster than Invoke-WebRequest for a ~1GB file. Fall back to IWR.
$curl = "$env:SystemRoot\System32\curl.exe"
if (Test-Path $curl) {
& $curl -L --fail --retry 3 --retry-delay 5 -o $zip $url
if ($LASTEXITCODE -eq 0 -and (Test-Path $zip)) { $ok = $true }
else { Write-Host "curl download failed (exit $LASTEXITCODE), falling back" }
}
if (-not $ok) {
for ($i = 1; $i -le 3 -and -not $ok; $i++) {
try { Invoke-WebRequest -Uri $url -OutFile $zip -UseBasicParsing; $ok = $true }
catch { Write-Host "IWR attempt $i failed: $_"; Start-Sleep 5 }
}
}
if (-not $ok) { Write-Error "Failed to download Flutter SDK"; exit 1 }
Write-Host "Extracting to $root (this is slow on first run)"