Skip to content

Add coverage report #10

Add coverage report

Add coverage report #10

Workflow file for this run

name: Coverage
on:
push:
branches: [ main ]
jobs:
coverage:
name: Run tests and generate coverage report
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "target/coverage/%p-%m.profraw"
SPIFFE_ENDPOINT_SOCKET: unix:/tmp/spire-agent/public/api.sock
SPIRE_ADMIN_ENDPOINT_SOCKET: unix:/tmp/spire-agent/admin/api.sock
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
- name: Cache Project
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Install toolchain
uses: ./.github/actions/setup-env
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: install LLVM
run: rustup component add llvm-tools-preview
- name: Install grcov
run: cargo install grcov
- name: Start SPIRE
run: ./scripts/run-spire.sh &
- name: Run Tests
run: cargo test --all-features
- name: Generate Coveralls JSON Report
run: |
grcov . \
--binary-path ./target/debug/ -t coveralls -s . \
--token ${{ secrets.COVERALLS_TOKEN }} \
--ignore-not-existing \
--ignore "$HOME/.cargo/**" \
--ignore "*/proto/*" \
--ignore "*/spire-api-sdk/*" \
--ignore "*/build.rs" \
--keep-only '*/src/*' > coveralls.json
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 # v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-json: ./coveralls.json
- name: Clean up SPIRE
run: ./scripts/cleanup-spire.sh