Skip to content

Commit

Permalink
ci: Implement coverage tests
Browse files Browse the repository at this point in the history
and upload the results to codecov.io, which is free for opensource projects.
  • Loading branch information
AiyionPrime committed Jun 17, 2024
1 parent b6648bb commit 9618552
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci_code_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Determine code coverage
'on':
workflow_call: null
jobs:
cov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Test with profiling data
run: cargo test
env:
CARGO_INCREMENTAL: 0
LLVM_PROFILE_FILE: 'cargo-test-%p-%m.profraw'
RUSTFLAGS: '-Cinstrument-coverage'

- name: Install grcov fast
uses: SierraSoftworks/setup-grcov@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: latest

- name: Add llvm-tools-preview
run: rustup component add llvm-tools-preview

- name: Create lcov output dir
run: |
mkdir target/coverage
- name: Generate lcov from profiling data
run: grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '**/generated/**/*' --ignore '**/integration/**/*' --ignore '**/tests/**/*' --ignore '../*' --ignore "/*" -o target/coverage/tests.lcov

- name: Upload lcov to codecov.io
uses: codecov/codecov-action@v4
with:
files: target/coverage/*.lcov

- name: Wipe stray profiling files
run: find . -type f -name "*.profraw"
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ jobs:
run: cargo build --features test-vendored-openssl
- name: Run tests
run: cargo test --features test-vendored-openssl --verbose

code-coverage:
uses: ./.github/workflows/ci_code_coverage.yml

0 comments on commit 9618552

Please sign in to comment.