Skip to content

Commit 36b4128

Browse files
authored
prepare v2.1.0 (#10)
1 parent d6e4b38 commit 36b4128

File tree

3 files changed

+61
-8
lines changed

3 files changed

+61
-8
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
go-version-file: go.mod
1616
- name: test
1717
run: go test -timeout=30s -race -count=10 -failfast ./...
18-
- name: generate coverage
18+
- name: generate test coverage
1919
run: go test ./... -coverprofile=./cover.out -covermode=atomic
2020
- name: check test coverage
2121
id: coverage
@@ -27,8 +27,8 @@ jobs:
2727
if: contains(github.ref, 'main')
2828
with:
2929
label: coverage
30-
message: ${{ steps.coverage.outputs.total_coverage }}%
31-
message-color: blue
30+
message: ${{ steps.coverage.outputs.badge-text }}
31+
message-color: ${{ steps.coverage.outputs.badge-color }}
3232
file-name: coverage.svg
3333
badge-branch: badges
3434
github-token: "${{ secrets.GITHUB_TOKEN }}"

README.md

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
`go-test-coverage` is tool which reports issues when test coverage of a file or package is below set threshold.
1212

13-
### Usage
13+
## Usage
1414

1515
```yml
1616
name: Go test coverage check
@@ -19,7 +19,7 @@ steps:
1919
- uses: actions/checkout@v3
2020
- uses: actions/setup-go@v3
2121

22-
- name: test (generate coverage)
22+
- name: generate test coverage
2323
run: go test ./... -coverprofile=./cover.out
2424

2525
- name: check test coverage
@@ -37,8 +37,8 @@ steps:
3737
threshold-total: 95
3838
```
3939
40-
### Config
41-
Example of [.testcoverage.yml](./.testcoverage.example.yml) config file.
40+
## Config
41+
Example of [.testcoverage.yml](./.testcoverage.example.yml) config file:
4242
4343
```yml
4444
# (mandatory)
@@ -68,6 +68,59 @@ threshold:
6868
total: 95
6969
```
7070
71+
## Badge
72+
73+
Generate self hosted coverage badge with `go-test-coverage` and `action-badges/core`.
74+
75+
Example:
76+
77+
```yml
78+
name: Go test coverage check
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v3
82+
- uses: actions/setup-go@v3
83+
84+
- name: generate test generate coverage
85+
run: go test ./... -coverprofile=./cover.out
86+
87+
- name: check test coverage
88+
id: coverage
89+
uses: vladopajic/go-test-coverage@v2
90+
with:
91+
profile: cover.out
92+
local-prefix: github.com/org/project
93+
threshold-file: 80
94+
threshold-package: 80
95+
threshold-total: 95
96+
97+
- name: make coverage badge
98+
uses: action-badges/core@0.2.2
99+
if: contains(github.ref, 'main')
100+
with:
101+
label: coverage
102+
message: ${{ steps.coverage.outputs.badge-text }}
103+
message-color: ${{ steps.coverage.outputs.badge-color }}
104+
file-name: coverage.svg
105+
badge-branch: badges ## orphan branch where badge will be committed
106+
github-token: "${{ secrets.GITHUB_TOKEN }}"
107+
```
108+
109+
Orphan branch needs to be created prior to running workflow, to create an orphan branch manually:
110+
111+
```
112+
git checkout --orphan badges
113+
git rm -rf .
114+
rm -f .gitignore
115+
echo '# Badges' > README.md
116+
git add README.md
117+
git commit -m 'init'
118+
git push origin badges
119+
```
120+
121+
Lastly, check output of 'make coverage badge' step to see markdown snippet which can be added to README.md.
122+
123+
71124
## Contribution
72125

73126
All contributions are useful, whether it is a simple typo, a more complex change, or just pointing out an issue. We welcome any contribution so feel free to open PR or issue.

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ outputs:
4141
description: Holds badge color value.
4242
runs:
4343
using: docker
44-
image: docker://ghcr.io/vladopajic/go-test-coverage:v2.0.0
44+
image: docker://ghcr.io/vladopajic/go-test-coverage:v2.1.0
4545
args:
4646
- -config=${{ inputs.config }}
4747
- -profile=${{ inputs.profile }}

0 commit comments

Comments
 (0)