-
Notifications
You must be signed in to change notification settings - Fork 2
48 lines (41 loc) · 1.27 KB
/
ci.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
44
45
46
47
48
name: Generate coverage badges
on:
push:
branches: [v2]
permissions:
contents: write
jobs:
generate-badges:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# setup go environment
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: coverage
id: coverage
run: |
go test -coverpkg=./... -coverprofile=profile.cov ./...
sed -i '/cmd/d' profile.cov # remove cmd package from coverage
total=$(go tool cover -func profile.cov | grep '^total:' | awk '{print $3}' | sed "s/%//")
rm profile.cov
echo "COVERAGE_VALUE=${total}" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
repository: sgaunet/gh-action-badge
path: gh-action-badge
ref: main
fetch-depth: 1
- name: Generate coverage badge
id: coverage-badge
uses: ./gh-action-badge/.github/actions/gh-action-coverage
with:
limit-coverage: "70"
badge-label: "coverage"
badge-filename: "coverage-badge.svg"
badge-value: "${COVERAGE_VALUE}"
- name: Print url of badge
run: |
echo "Badge URL: ${{ steps.coverage-badge.outputs.badge-url }}"