Skip to content

Commit a61c74a

Browse files
clairevnextclaude
andcommitted
ci: wire gist-hosted coverage badge
Add schneegans/dynamic-badges-action step to the test workflow, gated on push-to-main from ubuntu-latest only. Extracts total coverage from coverage.out and writes it to gist 7f1197011c2f419e7192c2ba4d530195. README gains a 4th badge pointing at the gist endpoint. Requires the GIST_TOKEN repo secret (gist scope only). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 194386d commit a61c74a

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

.github/workflows/test.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,28 @@ jobs:
5454

5555
- name: Run benchmarks
5656
run: go test -bench=. -benchmem ./...
57+
58+
# Coverage badge: on a successful push to main from ubuntu-latest only,
59+
# extract the total coverage percent from coverage.out and write it to
60+
# the repo's public gist via schneegans/dynamic-badges-action. shields.io
61+
# reads the gist via endpoint= mode. Requires GIST_TOKEN repo secret
62+
# (gist scope only). PRs and Windows/macOS runs skip this step.
63+
- name: Extract coverage percent
64+
id: coverage
65+
if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' && github.ref == 'refs/heads/main'
66+
run: |
67+
pct=$(go tool cover -func=coverage.out | awk '/^total:/ {gsub("%",""); print $3}')
68+
echo "pct=$pct" >> "$GITHUB_OUTPUT"
69+
70+
- name: Update coverage badge gist
71+
if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' && github.ref == 'refs/heads/main'
72+
uses: schneegans/dynamic-badges-action@v1.7.0
73+
with:
74+
auth: ${{ secrets.GIST_TOKEN }}
75+
gistID: 7f1197011c2f419e7192c2ba4d530195
76+
filename: coverage.json
77+
label: coverage
78+
message: ${{ steps.coverage.outputs.pct }}%
79+
valColorRange: ${{ steps.coverage.outputs.pct }}
80+
minColorRange: 50
81+
maxColorRange: 95

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![Go Reference](https://pkg.go.dev/badge/github.com/bold-minds/each.svg)](https://pkg.go.dev/github.com/bold-minds/each)
44
[![Build](https://img.shields.io/github/actions/workflow/status/bold-minds/each/test.yaml?branch=main&label=tests)](https://github.com/bold-minds/each/actions/workflows/test.yaml)
55
[![Go Version](https://img.shields.io/github/go-mod/go-version/bold-minds/each)](go.mod)
6+
[![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/clairevnext/7f1197011c2f419e7192c2ba4d530195/raw/coverage.json)](https://github.com/bold-minds/each/actions/workflows/test.yaml)
67

78
**Find, filter, group — slice operations Go stdlib skipped.**
89

0 commit comments

Comments
 (0)