Skip to content

Commit

Permalink
Add code coverage instrumentation to CI pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Notgnoshi committed Dec 25, 2024
1 parent 189b8c4 commit caf85fc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,39 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy
components: clippy,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
tool: cargo-nextest,cargo-llvm-cov
- name: Build
run: cargo build --release --all-targets --all-features
- name: Clippy
run: cargo clippy --no-deps --release --all-targets --all-features
- name: Test
run: |
git fetch
cargo nextest run --release --all-targets --all-features
cargo llvm-cov --no-report nextest --release --all-targets --all-features
cargo llvm-cov report --cobertura --output-path coverage.xml
RATE="$(grep -o -m 1 -P '(?<=line-rate=").*?(?=")' coverage.xml)"
PERCENT="$(echo "$RATE * 100)/1" | bc)"
echo "$COVERAGE_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
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
# https://github.com/Notgnoshi/herostratus/settings/secrets/actions
# https://github.com/settings/personal-access-tokens
token: ${{ secrets.HEROSTRATUS_RELEASE_TOKEN }}
- name: Validate SemVer Version
shell: bash # Explicitly setting the shell sets errexit and pipefail flags
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

![lint workflow](https://github.com/Notgnoshi/herostratus/actions/workflows/lint.yml/badge.svg?event=push)
![release workflow](https://github.com/Notgnoshi/herostratus/actions/workflows/release.yml/badge.svg?event=push)
![code coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Notgnoshi/b20aa388c90ca92aba6aa37ec55a7f12/raw/herostratus-coverage.json)

**Herostratus** _n._ **1.** An [ancient Greek](https://en.wikipedia.org/wiki/Herostratus) known for
seeking fame through crime and destruction. **2.** A Git repository achievements engine.
Expand Down

0 comments on commit caf85fc

Please sign in to comment.