Skip to content

Commit

Permalink
Track test coverage (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
SRv6d authored Oct 3, 2024
1 parent 509059e commit 624cc64
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
pull_request:
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
cargo-test:
runs-on: ${{ matrix.os }}
Expand All @@ -19,7 +23,19 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_version }}
components: llvm-tools-preview
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- uses: extractions/setup-just@v2

- run: just test

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
name: Rust ${{ matrix.rust_version }} (${{ matrix.os }})
files: lcov.info
use_oidc: true
fail_ci_if_error: true
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<a href="https://github.com/srv6d/hanko/actions">
<img src="https://github.com/srv6d/hanko/workflows/CI/badge.svg" alt="CI status">
</a>
<a href="https://codecov.io/github/SRv6d/hanko">
<img src="https://codecov.io/github/SRv6d/hanko/graph/badge.svg?token=PIRC5DZL9C">
</a>
<a href="https://codspeed.io/SRv6d/hanko">
<img src="https://img.shields.io/endpoint?url=https://codspeed.io/badge.json" alt="CodSpeed Badge">
</a>
Expand Down
16 changes: 14 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export CI := env("CI", "false")

default: check-lockfile lint test

# Check if the lockfile is up to date
Expand All @@ -12,9 +14,11 @@ lint: lint-justfile
lint-justfile:
just --check --fmt --unstable

cov_output := if CI == "true" { "--lcov --output-path lcov.info" } else { "--summary-only" }

# Run tests
test:
cargo test --all-features
test $COV=CI: (_install_llvm_cov COV)
{{ if COV == "true" { "cargo llvm-cov --all-features" + " " + cov_output } else { "cargo test --all-features" } }}

# Bump our version
bump-version $VERSION: (_validate_semver VERSION)
Expand Down Expand Up @@ -53,3 +57,11 @@ _validate_semver version:
echo Invalid SemVer {{ version }}
exit 1
fi
_install_llvm_cov $run:
#!/usr/bin/env bash
set -euxo pipefail
if [ $run == true ] && [ $CI = false ]; then
cargo install cargo-llvm-cov --locked
fi

0 comments on commit 624cc64

Please sign in to comment.