Files
BadNote/.gitea/workflows/ci.yml
Akiba So 3e93c11744
Some checks failed
CI / Windows build (push) Has been cancelled
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) <noreply@anthropic.com>
2026-06-21 04:06:36 +08:00

126 lines
5.2 KiB
YAML

name: CI
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]
workflow_dispatch:
# 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
# gitea.com mirror. If gitea.com is also unreachable, use the manual
# checkout fallback below (it clones from your own Gitea instance).
# * Flutter must be pre-installed on the runner (the dev machine). We do NOT
# download the SDK.
# * pub/Flutter use the flutter-io.cn mirrors; the sqlite3 native binary is
# vendored (vendor/sqlite3/), so neither is downloaded from GitHub.
# * The flutter_onnxruntime plugin downloads the ONNX Runtime native lib from
# GitHub during the Windows build; we route that through the local proxy.
env:
PUB_HOSTED_URL: https://pub.flutter-io.cn
FLUTTER_STORAGE_BASE_URL: https://storage.flutter-io.cn
jobs:
windows:
name: Windows build
runs-on: windows-latest
steps:
- name: Checkout
uses: https://gitea.com/actions/checkout@v4
# Fallback if gitea.com is unreachable — clone from your own Gitea
# instance (always reachable from the runner). Comment out the line
# above and uncomment this block:
#
# - name: Checkout (manual, from local Gitea)
# shell: pwsh
# run: |
# $t = "${{ github.token }}"
# $h = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("x-access-token:$t"))
# git init
# git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
# git -c http.extraheader="AUTHORIZATION: basic $h" fetch --depth=1 origin "${{ github.sha }}"
# git checkout --force FETCH_HEAD
# 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
run: flutter pub get
# Quality gates run but never block the build, so a usable .exe is always
# produced even if a different toolchain version reports new lints.
- name: Format check (non-blocking)
continue-on-error: true
run: dart format --output=none --set-exit-if-changed lib test
- name: Analyze (non-blocking)
continue-on-error: true
run: flutter analyze
- name: Test (non-blocking)
continue-on-error: true
run: flutter test --reporter expanded
- name: Enable Windows desktop
run: flutter config --enable-windows-desktop
# CMake's file(DOWNLOAD) honours these proxy vars when fetching ONNX
# Runtime. Defaults to the local clash/v2ray proxy; override with repo
# secrets HTTP_PROXY / HTTPS_PROXY if yours differs. Install ONNX Runtime
# system-wide to skip the download entirely.
- name: Build Windows release
env:
HTTP_PROXY: ${{ secrets.HTTP_PROXY || 'http://127.0.0.1:7890' }}
HTTPS_PROXY: ${{ secrets.HTTPS_PROXY || 'http://127.0.0.1:7890' }}
http_proxy: ${{ secrets.HTTP_PROXY || 'http://127.0.0.1:7890' }}
https_proxy: ${{ secrets.HTTPS_PROXY || 'http://127.0.0.1:7890' }}
run: flutter build windows --release
- name: Show build output
shell: pwsh
run: Get-ChildItem build\windows\x64\runner\Release
- name: Package artifact
shell: pwsh
run: Compress-Archive -Path "build/windows/x64/runner/Release/*" -DestinationPath "badnote-windows-x64.zip" -Force
- name: Upload artifact (best-effort)
continue-on-error: true
uses: https://gitea.com/actions/upload-artifact@v3
with:
name: badnote-windows-x64
path: badnote-windows-x64.zip
if-no-files-found: warn