-
Notifications
You must be signed in to change notification settings - Fork 40
50 lines (50 loc) · 1.63 KB
/
test-coverage.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
49
50
name: code-coverage
on:
push:
tags:
- v*
branches:
- master
pull_request:
permissions:
contents: write
jobs:
test:
name: coverage
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v4
with:
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- name: go-test
run: |
go test -v ./... -covermode=count -coverprofile=coverage.out.temp
grep -Ev '(/example|_deprecated.go)' coverage.out.temp > coverage.out
rm coverage.out.temp
go tool cover -func=coverage.out -o=coverage.out
- name: go-coverage-badge # Pass the `coverage.out` output to this action
uses: tj-actions/coverage-badge-go@v2
with:
filename: coverage.out
- name: verify-changed
uses: tj-actions/verify-changed-files@v17
id: verify-changed-files
with:
files: README.md
- name: commit-changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add README.md
git commit -m "chore: Updated coverage badge."
git fetch origin && git rebase origin/master
- name: push-changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ github.token }}
branch: ${{ github.head_ref }}