generated from mrz1836/go-template
-
Notifications
You must be signed in to change notification settings - Fork 15
163 lines (146 loc) · 4.46 KB
/
run-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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# See more at: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
name: run-go-tests
env:
GO111MODULE: on
LINT_VERSION: 'latest'
on:
pull_request:
branches:
- "*"
push:
branches:
- "*"
jobs:
yamllint:
name: Run yaml linter
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run yaml linter
uses: ibiqlik/action-yamllint@v3.1
asknancy:
name: Ask Nancy (check dependencies)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# GH Actions runner uses go1.20 by default, so we need to install our own version.
# https://github.com/github/codeql-action/issues/1842#issuecomment-1704398087
- name: Install Go from go.mod
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Write go list
run: go list -json -m all > go.list
- name: Ask Nancy
uses: sonatype-nexus-community/nancy-github-action@v1.0.3
continue-on-error: true
error-lint:
name: Lint for errors
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: ${{ env.LINT_VERSION }}
args: --config=./.golangci-lint.yml
style-lint:
name: Lint for style lint errors
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: golangci-style-lint
uses: golangci/golangci-lint-action@v6
with:
version: ${{ env.LINT_VERSION }}
args: --config=./.golangci-style.yml
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Start Redis
uses: supercharge/redis-github-action@1.8.0
with:
redis-version: 6
- name: Cache code
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod # Module download cache
~/.cache/go-build # Build cache (Linux)
~/Library/Caches/go-build # Build cache (Mac)
'%LocalAppData%\go-build' # Build cache (Windows)
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
- name: Run tests
run: make test-all-db-ci
- name: Update code coverage
uses: codecov/codecov-action@v5.1.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
models-error-lint:
name: '[models] Lint for errors'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: ${{ env.LINT_VERSION }}
working-directory: './models'
args: --config=../.golangci-lint.yml
models-style-lint:
name: '[models] Lint for style lint errors'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: golangci-style-lint
uses: golangci/golangci-lint-action@v6
with:
version: ${{ env.LINT_VERSION }}
working-directory: './models'
args: --config=../.golangci-style.yml
models-test:
runs-on: ubuntu-latest
name: '[models] Test'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version-file: models/go.mod
cache-dependency-path: models/go.sum
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
- name: Run tests
run: |
set -euo pipefail
go test -json -v ./... 2>&1 | tee gotest.log | gotestfmt
working-directory: models