diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0470a4f..7d9beec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,44 @@ jobs: - name: Run tests run: cargo test --package nora-registry + + coverage: + name: Coverage + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + permissions: + contents: read + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + + - name: Install Rust + uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable + + - name: Cache cargo + uses: Swatinem/rust-cache@42dc69e1aa15d09112580998cf2ef0119e2e91ae # v2 + + - name: Install tarpaulin + run: cargo install cargo-tarpaulin --locked + + - name: Run coverage + run: | + cargo tarpaulin --package nora-registry --out json --output-dir coverage/ 2>&1 | tee /tmp/tarpaulin.log + COVERAGE=$(python3 -c "import json; d=json.load(open('coverage/tarpaulin-report.json')); print(f\"{d['coverage']:.1f}\")") + echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV + echo "Coverage: $COVERAGE%" + + - name: Update coverage badge + uses: schneegans/dynamic-badges-action@e9a478b16159b4d31420099ba146cdc50f134483 # v1.7.0 + with: + auth: ${{ secrets.GIST_TOKEN }} + gistID: ${{ vars.COVERAGE_GIST_ID }} + filename: nora-coverage.json + label: coverage + message: ${{ env.COVERAGE }}% + valColorRange: ${{ env.COVERAGE }} + minColorRange: 0 + maxColorRange: 100 + security: name: Security runs-on: ubuntu-latest diff --git a/README.md b/README.md index be8bfac..40642ff 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) [![Release](https://img.shields.io/github/v/release/getnora-io/nora)](https://github.com/getnora-io/nora/releases) [![CI](https://img.shields.io/github/actions/workflow/status/getnora-io/nora/ci.yml?label=CI)](https://github.com/getnora-io/nora/actions) +[![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/devitway/0f0538f1ed16d5d9951e4f2d3f79b699/raw/nora-coverage.json)](https://github.com/getnora-io/nora/actions/workflows/ci.yml) [![GHCR](https://img.shields.io/badge/ghcr.io-nora-blue?logo=github)](https://github.com/getnora-io/nora/pkgs/container/nora) [![GitHub Stars](https://img.shields.io/github/stars/getnora-io/nora?style=flat&logo=github)](https://github.com/getnora-io/nora/stargazers) [![Rust](https://img.shields.io/badge/rust-%23000000.svg?logo=rust&logoColor=white)](https://www.rust-lang.org/)