-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (68 loc) · 2 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
test:
runs-on: ubuntu-latest
name: "Test & Lint"
steps:
- name: "Setup go"
uses: actions/setup-go@v3
with:
go-version: '>=1.17.3'
check-latest: true
- name: "Checkout"
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: "Checking go mod tidy"
run: |
set -e
go mod tidy
git diff --quiet && exit 0
cat <<EOF
Please run `go mod tidy` and update your branch.
EOF
- name: "Run tests"
run: |
go test -race ./... -covermode=atomic -coverprofile=coverage.out
go tool cover -func=coverage.out -o=coverage.out
- name: Go Coverage Badge
uses: tj-actions/[email protected]
with:
filename: coverage.out
- name: "Linting"
run: go vet ./...
- name: "staticcheck"
uses: dominikh/[email protected]
with:
version: "2022.1"
install-go: false
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v9
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."
- 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 }}