Make on-device OCR a pluggable local service so it runs locally on every platform (not just Windows), aimed at GoodNotes/Notability-class handwriting on low-power hardware (e.g. Zen2 APU, CPU/iGPU). - New OcrBackend abstraction (lib/services/ocr/): selector prefers an embedded ONNX recognition backend, falling back to the OS-native backend (Windows WinRT), and to a clean no-op when neither is available. - OnnxRecognitionBackend: flutter_onnxruntime session from a bundled asset, dart:ui preprocessing (resize to 48px, CHW float32, normalized), pure-Dart CTC greedy decode. Fully guarded — absent model/dict is a no-op; never throws. - ocr_engine.dart kept as a thin facade (recognizeImage) delegating to the selector, so ocr_service.dart is unchanged. - CtcDecoder unit-tested (6 tests). flutter analyze clean; all tests pass. - Model is not committed; tool/fetch_ocr_model.sh + assets/models/ocr/README.md document fetching PP-OCRv4 rec + dict on the dev machine. - CI: forward HTTPS_PROXY to the Windows build so CMake can fetch the ONNX Runtime native lib behind the GFW; README documents the system-install alternative. PP-OCR geometry/blank assumptions documented for on-device tuning. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
93 lines
3.2 KiB
YAML
93 lines
3.2 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ["v*"]
|
|
pull_request:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
# This pipeline targets a self-hosted Windows runner inside mainland China.
|
|
# Notes on the design (so it works behind the GFW):
|
|
# * Actions are fetched from the gitea.com mirror, NOT github.com, which is
|
|
# unreachable here. (Alternatively set DEFAULT_ACTIONS_URL=https://gitea.com
|
|
# in the runner's config and drop the full URL prefix.)
|
|
# * Flutter is expected to be pre-installed on the runner (the same machine
|
|
# used for local development) — we do NOT download the SDK from Google.
|
|
# * pub / Flutter artifacts use the flutter-io.cn mirrors.
|
|
# * The sqlite3 native binary is vendored in the repo (vendor/sqlite3/), so no
|
|
# GitHub-releases download happens during the build.
|
|
env:
|
|
PUB_HOSTED_URL: https://pub.flutter-io.cn
|
|
FLUTTER_STORAGE_BASE_URL: https://storage.flutter-io.cn
|
|
|
|
jobs:
|
|
flutter:
|
|
name: Flutter (analyze, test, Windows build)
|
|
runs-on: windows-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://gitea.com/actions/checkout@v4
|
|
|
|
- name: Flutter version (must be pre-installed on the runner)
|
|
run: flutter --version
|
|
|
|
- name: Install dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Verify formatting
|
|
run: dart format --output=none --set-exit-if-changed lib test
|
|
|
|
- name: Static analysis
|
|
run: flutter analyze
|
|
|
|
- name: Run tests
|
|
run: flutter test --reporter expanded
|
|
|
|
- name: Enable Windows desktop
|
|
run: flutter config --enable-windows-desktop
|
|
|
|
# The flutter_onnxruntime plugin's CMake downloads the ONNX Runtime native
|
|
# library from github.com/microsoft/onnxruntime/releases at build time.
|
|
# That host is blocked here, but CMake's file(DOWNLOAD) honours proxy env
|
|
# vars, so we forward HTTP(S)_PROXY (set them as repo secrets, e.g.
|
|
# http://127.0.0.1:7890). Alternatively install ONNX Runtime system-wide
|
|
# and pass -DUSE_SYSTEM_ONNXRUNTIME=ON -DONNXRUNTIME_ROOT_DIR=... .
|
|
- name: Build Windows release
|
|
env:
|
|
HTTP_PROXY: ${{ secrets.HTTP_PROXY }}
|
|
HTTPS_PROXY: ${{ secrets.HTTPS_PROXY }}
|
|
run: flutter build windows --release
|
|
|
|
- name: Package artifact
|
|
run: Compress-Archive -Path "build/windows/x64/runner/Release/*" -DestinationPath "badnote-windows-x64.zip" -Force
|
|
|
|
- name: Upload artifact
|
|
uses: https://gitea.com/actions/upload-artifact@v3
|
|
with:
|
|
name: badnote-windows-x64
|
|
path: badnote-windows-x64.zip
|
|
if-no-files-found: error
|
|
|
|
server:
|
|
name: Server tests (optional)
|
|
runs-on: windows-latest
|
|
# The Python backend is optional/experimental; never block the pipeline.
|
|
continue-on-error: true
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://gitea.com/actions/checkout@v4
|
|
|
|
- name: Install dependencies (Tsinghua PyPI mirror)
|
|
working-directory: server
|
|
run: |
|
|
python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
|
|
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
|
|
|
|
- name: Run tests
|
|
working-directory: server
|
|
env:
|
|
BADNOTE_JWT_SECRET: ci-test-secret
|
|
run: pytest -q
|