Switch to cargo-llvm-cov for code coverage #640
This file contains hidden or 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: Code Coverage | |
| # Generates code coverage reports using cargo-llvm-cov and uploads results to Codecov. | |
| # Runs on every push and pull request to track test coverage metrics. | |
| # Uploads coverage data to Codecov for tracking and produces an HTML report artifact for download. | |
| on: [push, pull_request] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| Coverage: | |
| name: Code Coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: nightly | |
| components: llvm-tools-preview | |
| cache: true | |
| - name: Install cargo-llvm-cov | |
| run: cargo install cargo-llvm-cov | |
| - name: Generate coverage data | |
| run: cargo llvm-cov --all-features --branch --quiet --lcov --output-path lcov.info | |
| env: | |
| RUSTFLAGS: "--cfg coverage_nightly" | |
| - name: Generate HTML coverage report | |
| run: cargo llvm-cov --all-features --branch --quiet --html | |
| env: | |
| RUSTFLAGS: "--cfg coverage_nightly" | |
| - name: Codecov upload | |
| uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 | |
| with: | |
| files: ./lcov.info | |
| flags: rust | |
| name: codecov-bdk-wallet | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: false | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: coverage-report | |
| path: target/llvm-cov/html |