Skip to content

Commit

Permalink
ci: Use justfile command to run coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
spencewenski committed Nov 16, 2024
1 parent cf030f7 commit aa47bb9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Test coverage

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches:
- main
Expand All @@ -28,14 +28,16 @@ jobs:
- uses: actions/checkout@v4
- uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
- name: Install zsh
run: sudo apt install -y zsh
- uses: taiki-e/install-action@just
- uses: taiki-e/install-action@nextest
- uses: taiki-e/install-action@cargo-llvm-cov

- name: Collect coverage data
# Generate coverage report using nextest.
run: |
cargo llvm-cov --no-report nextest --all-features
cargo llvm-cov --no-report --doc --all-features
just coverage-tests
cargo llvm-cov report --doctests --lcov --output-path lcov.info
- name: Upload coverage data to codecov
uses: codecov/codecov-action@v4
Expand Down
9 changes: 7 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,21 @@ coverage-clean:
cargo +nightly llvm-cov clean

# Run tests with coverage.
coverage: coverage-clean
coverage-tests: coverage-clean
cargo +nightly llvm-cov --no-report nextest --all-features
cargo +nightly llvm-cov --no-report --doc --all-features

# Run tests with coverage and generate an html report.
coverage: coverage-tests
# Generate and open an HTML coverage report
cargo +nightly llvm-cov report --lcov --output-path ./target/llvm-cov-target/debug/lcov.info
genhtml -o ./target/llvm-cov-target/debug/coverage/ --show-details --highlight --ignore-errors source --legend ./target/llvm-cov-target/debug/lcov.info

open_cmd := if os() == "macos" { "open" } else { "xdg-open" }

# Run tests with coverage and open the generated HTML report.
coverage-open: coverage
open target/llvm-cov-target/debug/coverage/index.html
{{ open_cmd }} target/llvm-cov-target/debug/coverage/index.html

alias fmt := format
# Format the project
Expand Down

0 comments on commit aa47bb9

Please sign in to comment.