mirror of
https://github.com/getnora-io/nora.git
synced 2026-04-12 19:40:31 +00:00
ci: add test coverage with tarpaulin and dynamic badge via gist
This commit is contained in:
38
.github/workflows/ci.yml
vendored
38
.github/workflows/ci.yml
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user