-
Notifications
You must be signed in to change notification settings - Fork 109
82 lines (74 loc) · 1.98 KB
/
tests.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
72
73
74
75
76
77
78
79
80
81
82
on:
push:
branches:
- master
- main
# Only run if there are changes to Go code or related configurations
paths:
- "**.go"
- "go.mod"
- "go.sum"
- "codecov.yml"
pull_request:
# Only run if there are changes to Go code or related configurations
paths:
- "**.go"
- "go.mod"
- "go.sum"
- "codecov.yml"
name: Tests
jobs:
test-cache:
name: "Run unit tests"
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.16.x, 1.x]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: WillAbides/setup-go-faster@v1
with:
go-version: ${{ matrix.go-version }}
- uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test with race and coverage
run: |
go test -race -coverprofile=coverage.out -covermode=atomic
go tool cover -func=coverage.out
- uses: codecov/codecov-action@v2
with:
files: ./coverage.out
lint:
name: "Run static analysis"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: WillAbides/setup-go-faster@v1
with:
go-version: "1.x"
- run: "GO111MODULE=on go get honnef.co/go/tools/cmd/staticcheck"
- uses: actions/cache@v2
with:
path: ~/.cache/staticcheck
key: staticcheck-${{ github.sha }}
restore-keys: |
staticcheck-
- run: "go vet ./..."
- run: "$(go env GOPATH)/bin/staticcheck ./..."