-
Notifications
You must be signed in to change notification settings - Fork 2
43 lines (37 loc) · 1.5 KB
/
go.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
name: Go Test Coverage
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.23.4"
- name: Run Tests and Generate Coverage Report
run: go test -race -timeout 60s -coverpkg=./... -coverprofile=coverage.raw.txt -covermode atomic ./... && cat coverage.raw.txt | grep -Ev "internal/" > coverage.txt
- name: Generate Coverage Badge
uses: vladopajic/go-test-coverage@v2
with:
profile: coverage.txt
local-prefix: github.com/leonhwangprojects/bice
threshold-total: 90
badge-file-name: coverage.svg
## in this case token should be from other repository that will host badges.
## this token is provided via secret `BADGES_GITHUB_TOKEN`.
git-token: ${{ github.ref_name == 'main' && secrets.BADGES_GITHUB_TOKEN || '' }}
git-branch: badges
## repository should match other repository where badges are hosted.
## format should be `{owner}/{repository}`
git-repository: leonhwangprojects/badges
## use custom file name that will have repository name as prefix.
## this could be useful if you want to create badges for multiple repositories.
git-file-name: .badges/${{ github.repository }}/${{ github.ref_name }}/coverage.svg