From 3e93c1174484b376636ef625f335b17c12e9b017 Mon Sep 17 00:00:00 2001 From: Akiba So Date: Sun, 21 Jun 2026 04:06:36 +0800 Subject: [PATCH] CI: locate Flutter on the runner instead of assuming it is on PATH Root cause of the failing Windows runs (seen in the runner logs): the Actions shell does not inherit Flutter on PATH, so `flutter --version` failed in ~30s. Checkout via the gitea.com mirror works fine. Add a "Locate Flutter" step that checks PATH, the FLUTTER_ROOT repo variable, and common Windows install locations, then prepends it via GITHUB_PATH so later steps find flutter. Fails with a clear message if not found. Co-Authored-By: Claude Opus 4.8 (1M context) --- .gitea/workflows/ci.yml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 6c53b01..52ab336 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -44,7 +44,36 @@ jobs: # git -c http.extraheader="AUTHORIZATION: basic $h" fetch --depth=1 origin "${{ github.sha }}" # git checkout --force FETCH_HEAD - - name: Flutter version (must be pre-installed on the runner) + # The runner's Actions shell often does not inherit Flutter on PATH, so + # locate it and add it to PATH for subsequent steps. Override by setting + # the repo variable FLUTTER_ROOT (Settings > Actions > Variables) to your + # Flutter SDK directory, or just add Flutter's bin to the system PATH. + - name: Locate Flutter + shell: pwsh + run: | + if (Get-Command flutter -ErrorAction SilentlyContinue) { + Write-Host "flutter already on PATH"; exit 0 + } + $candidates = @() + if ("${{ vars.FLUTTER_ROOT }}") { $candidates += (Join-Path "${{ vars.FLUTTER_ROOT }}" 'bin') } + if ($env:FLUTTER_ROOT) { $candidates += (Join-Path $env:FLUTTER_ROOT 'bin') } + $candidates += @( + 'C:\flutter\bin','C:\src\flutter\bin','C:\tools\flutter\bin','C:\dev\flutter\bin', + "$env:USERPROFILE\flutter\bin","$env:USERPROFILE\development\flutter\bin", + "$env:LOCALAPPDATA\flutter\bin",'C:\fvm\default\bin' + ) + $found = $null + foreach ($c in $candidates) { + if ($c -and (Test-Path (Join-Path $c 'flutter.bat'))) { $found = $c; break } + } + if (-not $found) { + Write-Error "Flutter not found on PATH or in common locations. Add Flutter's bin to the runner PATH, or set repo variable FLUTTER_ROOT to your Flutter SDK directory." + exit 1 + } + Write-Host "Found Flutter at $found" + Add-Content -Path $env:GITHUB_PATH -Value $found + + - name: Flutter version run: flutter --version - name: Install dependencies