Merge pull request #182 from BitcreditProtocol/try-to-add-kcov #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
push: | |
branches: [ "*" ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
toolchain: | |
- stable | |
steps: | |
- name: Check out repository | |
uses: actions/[email protected] | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
components: llvm-tools-preview | |
- name: Install Protoc | |
run: sudo apt-get install -y protobuf-compiler | |
- name: Activate cache | |
uses: Swatinem/[email protected] | |
- name: Install grcov | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: grcov | |
- name: Build crate | |
run: cargo build --verbose --all-targets | |
env: | |
RUSTFLAGS: "-Cinstrument-coverage" | |
- name: Test crate | |
run: cargo test --verbose | |
env: | |
LLVM_PROFILE_FILE: "target/coverage/prof/%p-%m.profraw" | |
RUSTFLAGS: "-Cinstrument-coverage" | |
- name: Create coverage report | |
run: | | |
grcov \ | |
--source-dir . \ | |
--binary-path target/debug \ | |
--branch \ | |
--excl-start 'mod tests \{' \ | |
--ignore 'tests/*' \ | |
-t lcov \ | |
-o lcov.info \ | |
target/coverage/prof | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
with: | |
files: lcov.info | |
fail_ci_if_error: false |