From aa47bb953e2350203013ab432f795219c10a6eac Mon Sep 17 00:00:00 2001 From: Spencer Ferris <3319370+spencewenski@users.noreply.github.com> Date: Fri, 15 Nov 2024 17:43:31 -0800 Subject: [PATCH] ci: Use justfile command to run coverage --- .github/workflows/coverage.yml | 8 +++++--- justfile | 9 +++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3307017..a6229a6 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -2,7 +2,7 @@ name: Test coverage on: push: - branches: [ main ] + branches: [main] pull_request: branches: - main @@ -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 diff --git a/justfile b/justfile index 124744f..f54ef71 100644 --- a/justfile +++ b/justfile @@ -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