فهرست منبع

ci: debug 检查只留 Ubuntu,Rust 变更才加 Windows

三平台 debug 编译没有测试、前端编三遍、merge 后再编一遍。
PR 默认只跑 Ubuntu;src-tauri 有改动才加 Windows cargo build。
push 到 main 不再跑 debug check,只保留 release 缓存预热。

Co-authored-by: darknessomi <darknessomi@users.noreply.github.com>
Cursor Agent 3 هفته پیش
والد
کامیت
c7291643ae
1فایلهای تغییر یافته به همراه56 افزوده شده و 26 حذف شده
  1. 56 26
      .github/workflows/ci.yml

+ 56 - 26
.github/workflows/ci.yml

@@ -8,17 +8,32 @@ on:
   workflow_dispatch:
 
 jobs:
-  check:
-    strategy:
-      fail-fast: false
-      matrix:
-        include:
-          - platform: macos-latest
-          - platform: ubuntu-22.04
-          - platform: windows-latest
+  changes:
+    name: Detect changes
+    if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
+    runs-on: ubuntu-22.04
+    outputs:
+      rust: ${{ github.event_name == 'workflow_dispatch' && 'true' || steps.filter.outputs.rust }}
+    steps:
+      - name: Checkout
+        if: github.event_name == 'pull_request'
+        uses: actions/checkout@v5
 
-    runs-on: ${{ matrix.platform }}
+      - name: Filter paths
+        if: github.event_name == 'pull_request'
+        uses: dorny/paths-filter@v3
+        id: filter
+        with:
+          filters: |
+            rust:
+              - 'src-tauri/**'
 
+  # PR / manual only. Merge to main already passed this on the PR;
+  # do not compile the same debug tree again.
+  check:
+    name: Check Ubuntu
+    needs: changes
+    runs-on: ubuntu-22.04
     steps:
       - name: Checkout
         uses: actions/checkout@v5
@@ -26,24 +41,11 @@ jobs:
       - name: Install Rust stable
         uses: dtolnay/rust-toolchain@stable
 
-      - name: Install protoc (macOS)
-        if: matrix.platform == 'macos-latest'
-        run: |
-          brew untap aws/tap || true
-          brew install protobuf
-
-      - name: Install dependencies (Ubuntu)
-        if: matrix.platform == 'ubuntu-22.04'
+      - name: Install dependencies
         run: |
           sudo apt-get update
           sudo apt-get install -y curl libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf protobuf-compiler
 
-      - name: Install protoc (Windows)
-        if: matrix.platform == 'windows-latest'
-        uses: arduino/setup-protoc@v3
-        with:
-          repo-token: ${{ secrets.GITHUB_TOKEN }}
-
       - name: Rust cache
         uses: Swatinem/rust-cache@v2
         with:
@@ -54,9 +56,10 @@ jobs:
         uses: actions/setup-node@v5
         with:
           node-version: 24
+          cache: npm
 
       - name: Install frontend dependencies
-        run: npm install
+        run: npm ci
 
       - name: Check frontend build
         run: npx vite build
@@ -65,9 +68,35 @@ jobs:
         working-directory: src-tauri
         run: cargo build
 
-  # Warm target/release so tag builds can restore it from the default branch.
+  check-windows:
+    name: Check Windows (Rust)
+    needs: changes
+    if: needs.changes.outputs.rust == 'true'
+    runs-on: windows-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v5
+
+      - name: Install Rust stable
+        uses: dtolnay/rust-toolchain@stable
+
+      - name: Install protoc
+        uses: arduino/setup-protoc@v3
+        with:
+          repo-token: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Rust cache
+        uses: Swatinem/rust-cache@v2
+        with:
+          workspaces: src-tauri
+          cache-on-failure: true
+
+      - name: Check Rust build
+        working-directory: src-tauri
+        run: cargo build
+
+  # Warm target/release on the default branch so tag builds can restore it.
   # GitHub cache is ref-scoped: tags cannot see other tags, but they can see main.
-  # Windows also runs on PRs so this branch can measure release compile time.
   release-compile:
     name: Release compile ${{ matrix.display }}
     if: github.event_name != 'pull_request'
@@ -130,6 +159,7 @@ jobs:
 
   release-compile-windows:
     name: Release compile Windows x64
+    if: github.event_name != 'pull_request'
     runs-on: windows-latest
     env:
       CARGO_PROFILE_RELEASE_LTO: "false"