Jelajahi Sumber

ci: 让 Windows release 缓存跨 tag 复用,并锁死 lancedb 默认特征

GitHub cache 按 ref 隔离,release workflow 只在 tag 上跑,Windows 每次都是
619 个 crate 冷编译(约 30 分钟)。用稳定 shared-key 在 main 上预热
target/release,失败也写 cache;tag 构建可以从 default branch 还原。

lancedb 0.27.2 的 default features 本就为空,显式 default-features = false
防止以后误开 aws/gcs/remote。DataFusion 是硬依赖,裁不掉。

Co-authored-by: darknessomi <darknessomi@users.noreply.github.com>
Cursor Agent 3 minggu lalu
induk
melakukan
d5e7ef4735
3 mengubah file dengan 83 tambahan dan 1 penghapusan
  1. 3 0
      .github/workflows/build.yml
  2. 76 0
      .github/workflows/ci.yml
  3. 4 1
      src-tauri/Cargo.toml

+ 3 - 0
.github/workflows/build.yml

@@ -75,6 +75,9 @@ jobs:
         uses: Swatinem/rust-cache@v2
         with:
           workspaces: src-tauri
+          shared-key: qmai-release
+          add-job-id-key: false
+          cache-on-failure: true
 
       - name: Install macOS dependencies
         if: runner.os == 'macOS'

+ 76 - 0
.github/workflows/ci.yml

@@ -5,6 +5,7 @@ on:
     branches: [main]
   pull_request:
     branches: [main]
+  workflow_dispatch:
 
 jobs:
   check:
@@ -47,6 +48,7 @@ jobs:
         uses: Swatinem/rust-cache@v2
         with:
           workspaces: src-tauri
+          cache-on-failure: true
 
       - name: Setup Node.js
         uses: actions/setup-node@v5
@@ -62,3 +64,77 @@ jobs:
       - 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' || matrix.on_pr
+    runs-on: ${{ matrix.platform }}
+    env:
+      CARGO_PROFILE_RELEASE_LTO: "false"
+      CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "16"
+      CARGO_PROFILE_RELEASE_OPT_LEVEL: "1"
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - platform: windows-latest
+            display: Windows x64
+            on_pr: true
+          - platform: ubuntu-22.04
+            display: Linux x64
+            on_pr: false
+          - platform: macos-latest
+            display: macOS
+            on_pr: false
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v5
+
+      - 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'
+        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:
+          workspaces: src-tauri
+          shared-key: qmai-release
+          add-job-id-key: false
+          cache-on-failure: true
+
+      - name: Setup Node.js
+        uses: actions/setup-node@v5
+        with:
+          node-version: 24
+          cache: npm
+
+      - name: Install frontend dependencies
+        run: npm ci
+
+      - name: Build frontend
+        run: npx vite build
+
+      - name: Cargo release build
+        working-directory: src-tauri
+        run: cargo build --release

+ 4 - 1
src-tauri/Cargo.toml

@@ -30,7 +30,10 @@ calamine = "0.34.0"
 docx-rs = "0.4.22"
 cfb = "0.7.3"
 encoding_rs = "0.8.35"
-lancedb = "0.27.2"
+# Local vector store only. lancedb 0.27.2 already has empty default features;
+# keep them off so aws/gcs/azure/remote/openai never sneak in. DataFusion is a
+# hard dependency of this crate and cannot be feature-gated away.
+lancedb = { version = "0.27.2", default-features = false }
 # tokio provided by tauri runtime for async commands
 arrow-array = "57"
 arrow-schema = "57"