-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (103 loc) · 2.75 KB
/
test.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Test
on:
push:
paths:
- '**.go'
- '**.gotmpl'
- 'go.*'
- '.golangci.yml'
- '.github/workflows/test.yml'
pull_request:
paths:
- '**.go'
- '**.gotmpl'
- 'go.*'
- '.golangci.yml'
- '.github/workflows/test.yml'
env:
GO111MODULE: on
jobs:
Pre-Commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/Library/Caches/go-build
~/AppData/Local/go-build
~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
restore-keys: go-mod
- name: Setup mdtoc
run: go install sigs.k8s.io/mdtoc@latest
- uses: pre-commit/[email protected]
env:
SKIP: golangci-lint,go-build,go-unit-tests
GolangCI-Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- id: versions
run: |
golangci="$(yq '.repos[] | select(.repo | contains("golangci-lint")) | .rev' .pre-commit-config.yaml)"
echo "golangci=$golangci" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/Library/Caches/go-build
~/AppData/Local/go-build
~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
restore-keys: go-mod
- name: Run linters
uses: golangci/golangci-lint-action@v3
with:
version: ${{ steps.versions.outputs.golangci }}
Vet:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/Library/Caches/go-build
~/AppData/Local/go-build
~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
restore-keys: go-mod
- name: Run vet
run: go vet
Test:
runs-on: ubuntu-latest
name: Go Tests
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/Library/Caches/go-build
~/AppData/Local/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
restore-keys: go-mod
- name: Run tests
shell: bash
run: go test -v -cover -race