Skip to content

Commit

Permalink
chore: add test coverage to CI GHA (+badge)
Browse files Browse the repository at this point in the history
  • Loading branch information
marccarre committed Nov 11, 2023
1 parent 5959d03 commit 690a061
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 7 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ jobs:
toolchain: stable
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: clippy
- id: clippy
name: clippy
run: cargo clippy --all --all-targets
- name: format
- id: format
name: format
run: cargo fmt --all -- --check
test: # ----------------------------------------------------------------------
strategy:
Expand All @@ -34,7 +36,15 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: test
run: cargo test --all
- id: build
name: build
uses: actions-rs/cargo@v1
with:
command: build # required for end-to-end tests in main.rs
- id: test
name: test
uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast
50 changes: 50 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
on:
push:
branches:
- main
jobs:
coverage: # ------------------------------------------------------------------
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- id: install-llvm-tools-preview-and-grcov
name: install llvm-tools-preview and grcov
run: |
rustup component add llvm-tools-preview
cargo install grcov
- uses: Swatinem/rust-cache@v2
- id: build
name: build
uses: actions-rs/cargo@v1
with:
command: build # required for end-to-end tests in main.rs
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: -Cinstrument-coverage
RUSTDOCFLAGS: -Cinstrument-coverage
LLVM_PROFILE_FILE: cargo-test-%p-%m.profraw
- id: test
name: test
uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: -Cinstrument-coverage
RUSTDOCFLAGS: -Cinstrument-coverage
LLVM_PROFILE_FILE: cargo-test-%p-%m.profraw
- id: coverage
name: coverage
run: |
mkdir -p target/coverage/
grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/tests.lcov
- id: coverage-report
name: coverage-report
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: target/coverage/tests.lcov
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<!-- markdownlint-disable MD013 MD033 MD041 -->
<div>
<a href="https://github.com/marccarre/ssh-to-ansible/actions">
<img src="https://github.com/marccarre/ssh-to-ansible/actions/workflows/ci.yaml/badge.svg" alt="build status">
<img src="https://github.com/marccarre/ssh-to-ansible/actions/workflows/ci.yaml/badge.svg" alt="build status" />
</a>
<a href="https://github.com/marccarre/ssh-to-ansible/releases">
<img src="https://img.shields.io/github/downloads/marccarre/ssh-to-ansible/total.svg" alt="downloads">
<img src="https://img.shields.io/github/downloads/marccarre/ssh-to-ansible/total.svg" alt="downloads" />
</a>
<a href='https://coveralls.io/github/marccarre/ssh-to-ansible?branch=main'>
<img src='https://coveralls.io/repos/github/marccarre/ssh-to-ansible/badge.svg?branch=main' alt='Coverage Status' />
</a>
</div>
<!-- markdownlint-enable MD013 MD033 MD041 -->
Expand Down

0 comments on commit 690a061

Please sign in to comment.