Skip to content

Commit

Permalink
ci: add test coverage computation & upload (#38)
Browse files Browse the repository at this point in the history
* ci: add test coverage computation & upload

using codecov as the host

* ci: fix binary path arg of grcov

* fix: update multi-line command syntax

* fix: correct target file path

* chore: add codecov badge to readme

* fix: add cache usage to coverage & tests CI
  • Loading branch information
imrn99 authored Apr 15, 2024
1 parent a7bded6 commit 0ac8458
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
61 changes: 61 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: codecov

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: 1

jobs:
coverage:
runs-on: ubuntu-latest
steps:
# checkout
- uses: actions/checkout@v4
with:
submodules: recursive
# install requirements
- uses: dtolnay/rust-toolchain@stable
- name: Install llvm-tools-preview
run: rustup component add llvm-tools-preview
- name: Install grcov
run: cargo install grcov
- uses: Swatinem/rust-cache@v2
# generate raw coverage data
# excluding the benchmark / example crates to remove some bias
- name: Build code
run: cargo build --features utils --workspace --exclude honeycomb-benches --exclude honeycomb-examples
env:
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw"
- name: Run tests
run: cargo test --features utils --workspace --exclude honeycomb-benches --exclude honeycomb-examples
env:
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw"
# generate lcov file using grcov
- name: Run grcov
run: |
grcov . \
--binary-path ./target/debug/ \
-s . \
-t lcov \
--branch \
--ignore-not-existing \
--ignore '../*' \
--ignore "/*" \
-o target/tests.lcov
# upload results
- name: Upload reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target/tests.lcov
slug: LIHPC-Computational-Geometry/honeycomb
3 changes: 3 additions & 0 deletions .github/workflows/rust-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Check Format
run: cargo fmt -- --check
clippy:
Expand All @@ -31,6 +32,7 @@ jobs:
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run Clippy
run: cargo clippy --features ${{ matrix.features }} -- -D warnings
tests:
Expand All @@ -45,5 +47,6 @@ jobs:
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run Tests
run: cargo test --features ${{ matrix.features }} --all
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ Cargo.lock

# ignore csv & svg files in root directory
/*.csv
/*.svg
/*.svg

# ignore coverage-related files
*.profraw
*.lcov
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Rust Tests](https://github.com/LIHPC-Computational-Geometry/honeycomb/actions/workflows/rust-test.yml/badge.svg)](https://github.com/LIHPC-Computational-Geometry/honeycomb/actions/workflows/rust-test.yml)
[![Documentation](https://github.com/LIHPC-Computational-Geometry/honeycomb/actions/workflows/doc.yml/badge.svg)][UG]
[![Build Status](https://github.com/LIHPC-Computational-Geometry/honeycomb/actions/workflows/build.yml/badge.svg)](https://github.com/LIHPC-Computational-Geometry/honeycomb/actions/workflows/build.yml)
[![codecov](https://codecov.io/github/LIHPC-Computational-Geometry/honeycomb/graph/badge.svg?token=QSN0TWFXO1)](https://codecov.io/github/LIHPC-Computational-Geometry/honeycomb)

Honeycomb aims to provide a safe, efficient and scalable implementation of
combinatorial maps for meshing applications. More specifically, the goal is
Expand Down

0 comments on commit 0ac8458

Please sign in to comment.