name: Rust Coverage
on: [push, pull_request]
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: llvm-tools-preview
profile: minimal
- name: Install grcov
run: cargo install grcov
- name: Run tests with coverage
run: |
export RUSTFLAGS="-Cinstrument-coverage"
export LLVM_PROFILE_FILE="rust-coverage-%p-%m.profraw"
cargo test --tests
mkdir -p ./coverage # 新增:确保目录存在
grcov . \
--binary-path ./target/debug/ \
-s . \
--branch \
--ignore-not-existing \
--ignore "/*" \
--ignore "examples/*" \
--ignore "benches/*" \
--ignore "src/tests/*" \
-t lcov \
-o ./coverage/lcov.info
- name: Upload to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: Treagzhao/zmatrix
files: ./coverage/lcov.info
verbose: true