From b0207c9972eafa46b6d819e0dbc297ff12ee09a3 Mon Sep 17 00:00:00 2001 From: Lixi20 Date: Fri, 4 Sep 2026 18:20:40 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=96=B0=E5=A2=9E=20Flutter=20CI=20?= =?UTF-8?q?=E9=97=A8=E7=A6=81=E5=B7=A5=E4=BD=9C=E6=B5=81=EF=BC=88=E9=9B=B6?= =?UTF-8?q?=20GitHub=20=E4=BE=9D=E8=B5=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - format/analyze/test 三连,与本地门禁同一套命令 - Flutter SDK 从 flutter-io.cn 下载并缓存于 runner toolcache 卷,pub 走国内镜像 - checkout 手动克隆本 Gitea 实例,concurrency 取消旧 run --- .gitea/workflows/ci.yml | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .gitea/workflows/ci.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..da03c19 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,54 @@ +# Gitea Actions 门禁:与 docs/development/git-workflow.md 的本地门禁同一套命令。 +# 零外部 action / 零 GitHub 依赖(原因见 patbond-api 的 ci.yml 头注释)。 +# Flutter SDK 从中国镜像(flutter-io.cn)下载并缓存在 runner 的 toolcache 卷中, +# 首跑约需下载 ~900MB,之后复用缓存秒级就绪。 +# 前提:runner config.yaml 的 container.options 挂载了 toolcache 卷: +# options: "-v /var/run/docker.sock:/var/run/docker.sock -v gitea_toolcache:/opt/hostedtoolcache" +name: CI + +on: + push: + branches: [dev] + pull_request: + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + flutter-gates: + runs-on: ubuntu-latest + steps: + - name: Checkout (manual) + run: | + git init -q . + AUTH_URL=$(echo "${{ github.server_url }}" | sed "s#https://#https://oauth2:${{ github.token }}@#") + git remote add origin "$AUTH_URL/${{ github.repository }}.git" + git fetch -q --depth 1 origin "+${{ github.ref }}:refs/ci-head" + git checkout -q refs/ci-head + - name: Install Flutter (flutter-io.cn mirror, toolcache reuse) + run: | + FLUTTER_VERSION=3.44.6 + FLUTTER_HOME=/opt/hostedtoolcache/flutter-$FLUTTER_VERSION + if [ ! -x "$FLUTTER_HOME/bin/flutter" ]; then + echo "Downloading Flutter $FLUTTER_VERSION from flutter-io.cn ..." + curl -fsSL -o /tmp/flutter.tar.xz \ + "https://storage.flutter-io.cn/flutter_infra_release/releases/stable/linux/flutter_linux_${FLUTTER_VERSION}-stable.tar.xz" + mkdir -p /opt/hostedtoolcache + tar -xf /tmp/flutter.tar.xz -C /tmp + mv /tmp/flutter "$FLUTTER_HOME" + else + echo "Reusing cached Flutter at $FLUTTER_HOME" + fi + git config --global --add safe.directory "$FLUTTER_HOME" + echo "$FLUTTER_HOME/bin" >> "$GITHUB_PATH" + echo "PUB_HOSTED_URL=https://pub.flutter-io.cn" >> "$GITHUB_ENV" + echo "FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn" >> "$GITHUB_ENV" + # 与本地门禁同一套命令(git-workflow.md) + - name: Gates + run: | + flutter --version + flutter pub get + dart format --output=none --set-exit-if-changed lib test + flutter analyze + flutter test