name: Verify Web on: push: branches: [main] # 只改文档/CI 自身不触发:省 GitHub Actions 免费分钟(额度按 job 分钟累计) paths-ignore: - '**/*.md' - 'docs/**' - '.github/**' pull_request: branches: [main] workflow_dispatch: # 同一分支连推多次时取消旧任务,只跑最后一次 concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: contents: read jobs: gate: name: gate (build · lint · unit · facts) runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@v4 with: # 完整历史(非浅克隆):事实守门第 7 组要读 package.json 的**父提交**来定位 # 「最近一次 bump 版本的提交」⇒ 浅克隆下 `HEAD^` 不存在会导致门禁误报失败。 # 仓库很小(打包后 ~3MB),取全历史成本可忽略。 fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: 22 cache: npm - run: npm ci - run: npm run verify:ci e2e: name: e2e (Playwright) # e2e 是最贵的 job:push 到 main 不再跑,只在 PR / 手动触发时跑 if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: 22 cache: npm - run: npm ci - name: Cache Playwright browsers uses: actions/cache@v4 with: path: ~/.cache/ms-playwright key: playwright-${{ runner.os }}-${{ hashFiles('package-lock.json') }} - run: npx playwright install --with-deps chromium - run: npm run test:e2e # 桌面端 Rust 门禁(2026-11-26 新增)。此前 25 个 tauri 命令、mac/Win32 双平台分支 # 完全没有 CI,只能靠人工在 mac / win 上构建验证。 # 选 macOS runner:Linux 编译 tauri 需要 webkit2gtk 等系统库,macOS 自带,成本也最低; # 且 src-tauri 的 #[cfg(target_os = "macos")] 分支只有 mac 能真正编译到。 rust: name: rust (fmt · clippy · test) runs-on: macos-latest timeout-minutes: 30 steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 with: workspaces: src-tauri - name: fmt run: cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check - name: clippy run: cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets -- -D warnings - name: test run: cargo test --manifest-path src-tauri/Cargo.toml