99 lines
2.7 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
env:
CARGO_TERM_COLOR: always
# 跳过前端构建build.rs 会触发 npm install + npm run build
# CI 中独立处理前端检查,避免 cargo check 时重复构建
SKIP_FRONTEND_BUILD: "1"
jobs:
rust-checks:
name: Rust fmt + clippy + test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt --all -- --check
# 不使用 -D warnings现有代码有大量 warn 级别的存量问题
# unwrap/expect/clone 等),一上线会让 CI 一直红。
# 仅 correctness 类别clippy 默认 deny会失败先渐进收集。
# 等存量清理后再考虑加 -- -D warnings
- name: Clippy
run: cargo clippy --all-targets --all-features
- name: Build
# 构建 lib + 二进制入口main.rs确保 gateway 二进制也被编译验证
run: cargo build
- name: Run tests
# 运行 lib 单元测试 + tests/ 集成测试
# test_integration.rs / test_tool_calling.rs 中的 #[ignore] 测试
# 需要真实 API key会被跳过test_request_format.rs 的测试会实际执行
run: cargo test
- name: Security audit
run: cargo install cargo-audit --locked && cargo audit
frontend-checks:
name: Frontend build + test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: web/package-lock.json
- name: Install dependencies
working-directory: web
run: npm ci
- name: Lint (eslint)
working-directory: web
run: npm run lint
- name: Format check (prettier)
working-directory: web
run: npm run format:check
- name: Type check
working-directory: web
run: npx tsc --noEmit
- name: Run tests
working-directory: web
run: npm run test
- name: Security audit
working-directory: web
run: npm audit --audit-level=high