Skip to content

Commit f887df9

Browse files
authored
Add coverage badge (#2)
1 parent 9bce287 commit f887df9

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

.github/workflows/ci.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ jobs:
88

99
steps:
1010
- uses: actions/checkout@v4
11+
with:
12+
ref: ${{ github.head_ref }}
1113
- name: Setup Go
1214
uses: actions/setup-go@v5
1315
with:
@@ -17,5 +19,24 @@ jobs:
1719
- name: Build
1820
run: go build -v ./...
1921
- name: Test with the Go CLI
20-
run: go test
22+
run: |
23+
go test -v ./... -covermode=count -coverprofile=coverage.out
24+
go tool cover -func=coverage.out -o=coverage.out
25+
- name: Go Coverage Badge # Pass the `coverage.out` output to this action
26+
uses: tj-actions/coverage-badge-go@v2
27+
with:
28+
filename: coverage.out
29+
- name: Verify Changed files
30+
uses: tj-actions/verify-changed-files@v16
31+
id: verify-changed-files
32+
with:
33+
files: README.md
34+
- name: Commit and push changes
35+
if: steps.verify-changed-files.outputs.files_changed == 'true'
36+
run: |
37+
git config --local user.email "action@github.com"
38+
git config --local user.name "GitHub Action"
39+
git add README.md
40+
git commit -m "chore: Updated coverage badge."
41+
git push
2142

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# RingChan
22

33
[![CI](https://github.com/floatdrop/ringchan/actions/workflows/ci.yaml/badge.svg)](https://github.com/floatdrop/ringchan/actions/workflows/ci.yaml)
4+
![Coverage](https://img.shields.io/badge/Coverage-90.9%25-brightgreen)
45
[![Go Report Card](https://goreportcard.com/badge/github.com/floatdrop/ringchan)](https://goreportcard.com/report/github.com/floatdrop/ringchan)
56
[![Go Reference](https://pkg.go.dev/badge/github.com/floatdrop/ringchan.svg)](https://pkg.go.dev/github.com/floatdrop/ringchan)
67
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

0 commit comments

Comments
 (0)