oudecheng c724bbf864 chore(web): prettier 一次性格式化并在 CI 启用 format:check
对 47 个前端文件统一执行 npm run format,消除存量格式差异。
随后在 CI 与 Makefile check 中启用 format:check,确保后续提交强制遵守 prettier 风格。
2026-08-03 23:25:22 +08:00

88 lines
2.2 KiB
YAML
Raw 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
run: cargo build --lib
- name: Run tests
run: cargo test --lib
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