diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 6297e17..94c45fc 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -31,3 +31,22 @@ jobs: - name: Display coverage run: go tool cover -func=coverage.out + + - name: Extract coverage percentage + id: coverage + run: | + COVERAGE=$(go tool cover -func=coverage.out | grep ^total | awk '{print $3}' | tr -d '%') + echo "pct=$COVERAGE" >> $GITHUB_OUTPUT + + - name: Update coverage badge + uses: schneegans/dynamic-badges-action@v1.7.0 + with: + auth: ${{ secrets.GIST_SECRET }} + gistID: 3e707bdf3f06ecb4575166ce598051c3 + filename: beacon-coverage.json + label: coverage + message: ${{ steps.coverage.outputs.pct }}% + valColorRange: ${{ steps.coverage.outputs.pct }} + maxColorRange: 100 + minColorRange: 0 + if: github.ref == 'refs/heads/main' diff --git a/README.md b/README.md index 2d17f2e..c1149a0 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,9 @@ MeshCore Beacon is a MeshCore network observation backend. It connects to one or more MeshCore MQTT brokers, ingests LoRa packet traffic in real time, stores it in PostgreSQL, and streams live events to WebSocket clients. -[![CodeQL](https://github.com/MeshCore-Beacon/beacon-server/actions/workflows/codeql.yml/badge.svg)](https://github.com/MeshCore-Beacon/beacon-server/actions/workflows/codeql.yml) [![CI](https://github.com/MeshCore-Beacon/beacon-server/actions/workflows/ci.yml/badge.svg)](https://github.com/MeshCore-Beacon/beacon-server/actions/workflows/ci.yml) +[![CodeQL](https://github.com/MeshCore-Beacon/beacon-server/actions/workflows/codeql.yml/badge.svg)](https://github.com/MeshCore-Beacon/beacon-server/actions/workflows/codeql.yml) +![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/ded/3e707bdf3f06ecb4575166ce598051c3/raw/beacon-coverage.json) [![Docker](https://github.com/MeshCore-Beacon/beacon-server/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/MeshCore-Beacon/beacon-server/actions/workflows/docker-publish.yml) ## What it does