forked from berty/weshnet
-
Notifications
You must be signed in to change notification settings - Fork 5
278 lines (234 loc) · 8.08 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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
name: Go
on:
push:
tags:
- v*
branches:
- main
paths:
- "**"
- "!**.md"
- "go.*"
- "**.go"
- ".github/workflows/go.yml"
pull_request:
paths:
- "**"
- "!**.md"
- "go.*"
- "**.go"
- ".github/workflows/go.yml"
jobs:
golangci-lint:
name: Golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup asdf
uses: asdf-vm/actions/setup@v1
- name: Setup golang
run: |
asdf plugin add golang
asdf install golang
- name: Setup golangci-lint
run: |
asdf plugin add golangci-lint
asdf install golangci-lint
- name: Run golangci-lint
run: make lint
# this is not very common to have a job that checks the flappy tests.
#
# reason: some tests are flappy, they works, but not always;
# this job checks that they are working sometimes.
# if this job fails, then a test is "broken", not "flappy".
#
# summary: this job checks that "flappy tests" do not become "broken tests".
#
# we hope we can remove this job because all the tests are stable 100% of the time
flappy-tests:
name: Flappy tests (Linux)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Load variables from file
uses: antifree/[email protected]
with:
filename: .github/workflows/utils/variables.json
- name: Setup asdf
uses: asdf-vm/actions/setup@v1
- name: Setup go
run: |
asdf plugin add golang
asdf install golang
echo "go_version=$(asdf current golang | xargs | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Cache go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-
- name: Avoid triggering make generate
run: touch gen.sum
- name: Fetch go modules
run: go mod download
- name: Compile the testing binaries
run: |
pushd . && go test -c -o ./tests.bin . && popd
- name: Check go.mod and go.sum
run: |
go mod tidy -v
git --no-pager diff go.mod go.sum
git --no-pager diff --quiet go.mod go.sum
- name: Run fast flappy tests
env:
TEST_SPEED: fast
TEST_STABILITY: flappy
run: make go.flappy-tests
go-tests-on-linux:
name: Stable tests (Linux)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Load variables from file
uses: antifree/[email protected]
with:
filename: .github/workflows/utils/variables.json
- name: Setup asdf
uses: asdf-vm/actions/setup@v1
- name: Setup go
run: |
asdf plugin add golang
asdf install golang
echo "go_version=$(asdf current golang | xargs | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Cache go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-
- name: Check go.mod and go.sum
run: |
go mod tidy -v
git --no-pager diff go.mod go.sum
git --no-pager diff --quiet go.mod go.sum
- name: Run fast tests multiple times
env:
TEST_SPEED: fast
GO_TEST_OPTS: -test.timeout=600s -count 1
run: set -o pipefail; make go.unittest | tee test_log.txt
- name: Run all tests
env:
TEST_SPEED: any
GO_TEST_OPTS: -test.timeout=600s -count 1
run: make go.unittest
- name: Run all tests with race flag and generate coverage
env:
TEST_SPEED: any
GO_TEST_OPTS: -test.timeout=1200s -count=1 -race -cover -coverprofile=coverage.txt -covermode=atomic
run: make go.unittest
- name: Upload coverage to Codecov
uses: codecov/[email protected]
env:
OS: ${{ runner.os }}
GOLANG: ${{ env.go_version }}
with:
file: ./go/coverage.txt
flags: go.unittests
env_vars: OS,GOLANG
name: codecov-umbrella
fail_ci_if_error: false
go-tests-on-windows:
name: Stable tests (Windows)
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Load variables from file
uses: antifree/[email protected]
with:
filename: .github/workflows/utils/variables.json
- name: Get go version
shell: bash
run: echo "go_version=$(cat .tool-versions | grep '^golang [0-9]\+\.[0-9]\+\.[0-9]\+.*$' | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: ${{ env.go_version }}
- name: Cache go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-
- name: Check go.mod and go.sum
run: |
go mod tidy -v
git --no-pager diff go.mod go.sum
git --no-pager diff --quiet go.mod go.sum
- name: Run fast tests multiple times
env:
TEST_SPEED: fast
run: go.exe test ./... -buildmode=exe -timeout=600s -count=5
- name: Run all tests
env:
TEST_SPEED: any
run: go.exe test ./... -buildmode=exe -timeout=600s -count=1
go-tests-on-macos:
name: Stable tests (macOS)
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Load variables from file
uses: antifree/[email protected]
with:
filename: .github/workflows/utils/variables.json
- name: Setup asdf
uses: asdf-vm/actions/setup@v1
- name: Setup go
run: |
asdf plugin add golang
asdf install golang
echo "go_version=$(asdf current golang | xargs | cut -d ' ' -f 2)" >> $GITHUB_ENV
- name: Cache go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ env.go_version }}-${{ env.json_cache-versions_go }}-
- name: Check go.mod and go.sum
run: |
go mod tidy -v
git --no-pager diff go.mod go.sum
git --no-pager diff --quiet go.mod go.sum
- name: Run fast tests multiple times
env:
TEST_SPEED: fast
GO_TEST_OPTS: -test.timeout=600s -count 1
run: set -o pipefail; make go.unittest | tee test_log.txt
- name: Run all tests
env:
TEST_SPEED: any
GO_TEST_OPTS: -test.timeout=600s -count 1
run: make go.unittest
- name: Run all tests with race flag and generate coverage
env:
TEST_SPEED: any
GO_TEST_OPTS: -test.timeout=1200s -count=1 -race -cover -coverprofile=coverage.txt -covermode=atomic
run: make go.unittest
- name: Upload coverage to Codecov
uses: codecov/[email protected]
env:
OS: ${{ runner.os }}
GOLANG: ${{ env.go_version }}
with:
file: ./go/coverage.txt
flags: go.unittests
env_vars: OS,GOLANG
name: codecov-umbrella
fail_ci_if_error: false
# TODO: consider adding various GOARCH check per OS.
# i.e., to validate that we build on 32/64bit.