Skip to content

Commit b54c3a5

Browse files
authored
feat: adds coverage badge workflow (#2)
* feat: adds coverage badge workflow
1 parent 0b5a28a commit b54c3a5

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

.github/workflows/go-coverage.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
coverage:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v5
15+
with:
16+
fetch-depth: '0'
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v6
20+
with:
21+
go-version: 1.24
22+
cache: 'true'
23+
24+
- name: Build
25+
run: go install
26+
27+
- name: Test
28+
run: |
29+
go test -v -cover ./... -coverprofile coverage.out -coverpkg ./...
30+
go tool cover -func coverage.out -o coverage.out # Replaces coverage.out with the analysis of coverage.out
31+
32+
- name: Go Coverage Badge
33+
uses: tj-actions/coverage-badge-go@v3
34+
with:
35+
green: 80
36+
filename: coverage.out
37+
38+
- uses: stefanzweifel/git-auto-commit-action@v6
39+
id: auto-commit-action
40+
with:
41+
commit_message: Apply Code Coverage Badge
42+
file_pattern: ./README.md

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# envconfig
2-
A small,
3-
dependency-free Go library for loading configuration from environment variables directly into your structs.
42

53
[![Go Reference](https://pkg.go.dev/badge/github.com/struct0x/envconfig.svg)](https://pkg.go.dev/github.com/struct0x/envconfig)
64
[![Go Report Card](https://goreportcard.com/badge/github.com/struct0x/envconfig)](https://goreportcard.com/report/github.com/struct0x/envconfig)
5+
![Coverage](https://img.shields.io/badge/Coverage-87.6%25-brightgreen)
6+
7+
A small,
8+
dependency-free Go library for loading configuration from environment variables directly into your structs.
79

810
It supports nested structs, prefixes, defaults, required fields,
911
slices, maps, arrays, pointers, durations, and custom (un)marshalers.

0 commit comments

Comments
 (0)