From 265f127c3cab16b0aeca9395f7ce2de1c95b70a2 Mon Sep 17 00:00:00 2001 From: Akiba So Date: Sun, 21 Jun 2026 04:30:23 +0800 Subject: [PATCH] ci: faster SDK download, supersede stale runs 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. --- .gitea/workflows/ci.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index df5bd86..4cd8496 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -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)"