diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7cf6abf..ad64a04 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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/dynamic-badges-action@v1.7.0 + 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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 675ba39..ab8fd38 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/README.md b/README.md index ad2fa91..042b94d 100644 --- a/README.md +++ b/README.md @@ -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.