-
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 instrumentation to CI pipeline
Additionally, split apart build and test CI jobs. Originally, the tests required the binary produced by 'cargo build', but now that that's fixed, and the tests require code coverage instrumentation (forcing a rebuild anyways), it's better to do the build and test in parallel.
- Loading branch information
Showing
3 changed files
with
44 additions
and
6 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 |
---|---|---|
|
@@ -54,15 +54,50 @@ jobs: | |
components: clippy | ||
- name: Setup Rust cache | ||
uses: swatinem/rust-cache@v2 | ||
- name: Build | ||
run: cargo build --all-targets --all-features | ||
- name: Clippy | ||
run: cargo clippy --no-deps --all-targets --all-features | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Rust toolchain | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: stable | ||
components: llvm-tools-preview | ||
- name: Setup Rust cache | ||
uses: swatinem/rust-cache@v2 | ||
- name: Setup nextest | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: cargo-nextest | ||
- name: Build | ||
run: cargo build --release --all-targets --all-features | ||
- name: Clippy | ||
run: cargo clippy --no-deps --release --all-targets --all-features | ||
tool: cargo-nextest,cargo-llvm-cov | ||
- name: Test | ||
run: | | ||
git fetch | ||
cargo nextest run --release --all-targets --all-features | ||
cargo llvm-cov --no-report nextest --all-targets --all-features | ||
cargo llvm-cov report --cobertura --output-path coverage.xml | ||
head coverage.xml | ||
RATE="$(grep -o -m 1 -P '(?<=line-rate=").*?(?=")' coverage.xml | head -1)" | ||
echo "RATE=$RATE" | ||
PERCENT="$(echo "($RATE * 100)/1" | bc)" | ||
echo "PERCENT=$PERCENT" | ||
echo "COVERAGE_PERCENT=$PERCENT" >> $GITHUB_ENV | ||
- name: Update coverage badge | ||
uses: schneegans/[email protected] | ||
if: github.ref_name == github.event.repository.default_branch | ||
with: | ||
# https://github.com/Notgnoshi/herostratus/settings/secrets/actions | ||
# https://github.com/settings/personal-access-tokens | ||
# https://gist.github.com/Notgnoshi/b20aa388c90ca92aba6aa37ec55a7f12 | ||
# https://github.com/marketplace/actions/dynamic-badges | ||
auth: ${{ secrets.HEROSTRATUS_COVERAGE_GIST_TOKEN }} | ||
gistID: b20aa388c90ca92aba6aa37ec55a7f12 | ||
filename: herostratus-coverage.json | ||
label: Code Coverage | ||
message: "${{ env.COVERAGE_PERCENT }}%" | ||
valColorRange: ${{ env.COVERAGE_PERCENT }} | ||
minColorRange: 60 | ||
maxColorRange: 95 |
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