name: Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.cargo
key: ${{ runner.os }}
- name: Install grcov
run: cargo install grcov
- name: Install llvm-tools-preview
run: rustup component add llvm-tools-preview
- name: Build
run: cargo build --verbose
env:
RUSTFLAGS: "-Cinstrument-coverage"
- name: Run tests
run: cargo test --verbose
env:
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "%p-%m.profraw"
- name: Compute coverage
run: grcov . --binary-path ./target/debug/ --source-dir . --output-path lcov.info --output-type lcov --branch --ignore-not-existing
- uses: codecov/codecov-action@v3
publish:
runs-on: ubuntu-latest
needs: [test]
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v3
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}