Skip to content

test(frontend): 添加完整的单元测试覆盖 #2

test(frontend): 添加完整的单元测试覆盖

test(frontend): 添加完整的单元测试覆盖 #2

Workflow file for this run

name: Rust CI
on:
push:
paths:
- '**/*.rs'
- 'Cargo.toml'
- 'Cargo.lock'
- 'scripts/coverage-summary.mjs'
- '.github/workflows/rust.yml'
branches: [main]
pull_request:
paths:
- '**/*.rs'
- 'Cargo.toml'
- 'Cargo.lock'
- 'scripts/coverage-summary.mjs'
- '.github/workflows/rust.yml'
branches: [main, develop]
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Install media processing dependencies
run: sudo apt-get update && sudo apt-get install -y ffmpeg
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- name: Cache Rust build artifacts
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --verbose
- name: Format check
run: cargo fmt -- --check
- name: Prepare coverage output directory
run: mkdir -p coverage/rust
- name: Setup bun
uses: oven-sh/setup-bun@v2
- name: Run tests with coverage
run: cargo llvm-cov --workspace --no-fail-fast --verbose --lcov --output-path coverage/rust/lcov.info
- name: Generate HTML coverage report
if: success()
run: cargo llvm-cov report --html --output-dir coverage/rust/html
- name: Publish coverage summary
if: always() && hashFiles('coverage/rust/lcov.info') != ''
run: bun scripts/coverage-summary.mjs "Rust" coverage/rust/lcov.info
- name: Upload coverage reports to Codecov
if: always() && hashFiles('coverage/rust/lcov.info') != ''
uses: codecov/codecov-action@v7
with:
files: coverage/rust/lcov.info
flags: rust
name: rust-backend
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
- name: Upload coverage artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: rust-coverage
if-no-files-found: ignore
path: coverage/rust
- name: Clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings