forked from payjoin/rust-payjoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code coverage to CI with Coveralls integration (payjoin#385)
This brings the github actions up-to-date with latest versions and adds more descriptive names to the workflow steps. It also swaps the ordering of `rust-cache` and the rust toolchain installation steps so that cache actually works. Finally, a new CI step adds code coverage measurements using `cargo-llvm` and uploads the results to Coveralls.
- Loading branch information
Showing
3 changed files
with
50 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
name: Test and Build | ||
name: Continuous integration | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
|
||
test: | ||
Test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
|
@@ -13,43 +12,62 @@ jobs: | |
- 1.63.0 # MSRV | ||
- stable | ||
- nightly | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: Swatinem/[email protected] | ||
- uses: actions-rs/toolchain@v1 | ||
- name: "Checkout repo" | ||
uses: actions/checkout@v4 | ||
- name: "Install ${{ matrix.rust }} toolchain" | ||
# https://github.com/dtolnay/rust-toolchain?tab=readme-ov-file#inputs | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
override: true | ||
- name: "Use cache" | ||
uses: Swatinem/rust-cache@v2 | ||
- name: Run tests | ||
run: RUST_LOG=debug bash contrib/test.sh | ||
|
||
rustfmt: | ||
Format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: Swatinem/[email protected] | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
override: true | ||
- name: "Checkout repo" | ||
uses: actions/checkout@v4 | ||
- name: "Install nightly toolchain" | ||
uses: dtolnay/rust-toolchain@nightly | ||
- name: "Use cache" | ||
uses: Swatinem/rust-cache@v2 | ||
- run: rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu | ||
- name: fmt check | ||
- name: "Run formatting check" | ||
run: cargo fmt --all -- --check | ||
|
||
clippy: | ||
Lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout repo" | ||
uses: actions/checkout@v4 | ||
- name: "Use caching" | ||
uses: Swatinem/[email protected] | ||
- name: "Install nightly toolchain" | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
override: true | ||
uses: dtolnay/rust-toolchain@nightly | ||
- name: "Use cache" | ||
uses: Swatinem/rust-cache@v2 | ||
- name: "Install clippy" | ||
run: rustup component add clippy --toolchain nightly-x86_64-unknown-linux-gnu | ||
- name: "Run linting" | ||
run: bash contrib/lint.sh | ||
|
||
Coverage: | ||
name: Code coverage | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- name: "Checkout repo" | ||
uses: actions/checkout@v4 | ||
- name: "Install toolchain" | ||
# https://github.com/dtolnay/rust-toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
- name: "Use cache" | ||
uses: Swatinem/rust-cache@v2 | ||
- name: "Install cargo-llvm-cov" | ||
uses: taiki-e/install-action@cargo-llvm-cov | ||
- name: "Generate code coverage for tests" | ||
run: bash contrib/coverage.sh | ||
- name: "Upload report to coveralls" | ||
uses: coverallsapp/github-action@v2 |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# https://github.com/taiki-e/cargo-llvm-cov?tab=readme-ov-file#merge-coverages-generated-under-different-test-conditions | ||
cargo llvm-cov clean --workspace # remove artifacts that may affect the coverage results | ||
cargo llvm-cov --no-report --features=send,receive | ||
cargo llvm-cov --no-report --features=v2,danger-local-https,io | ||
cargo llvm-cov report --lcov --output-path lcov.info # generate report without tests |