forked from berty/berty
-
Notifications
You must be signed in to change notification settings - Fork 0
302 lines (256 loc) · 9.28 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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
name: Go
on:
push:
tags:
- v*
branches:
- master
paths:
- "go/**"
- "!go/**.md"
- "go.*"
- "**.go"
- ".github/workflows/go.yml"
pull_request:
paths:
- "go/**"
- "!go/**.md"
- "go.*"
- "**.go"
- ".github/workflows/go.yml"
jobs:
golangci-lint:
name: Golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- 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
working-directory: go
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 go/gen.sum
- name: Fetch go modules
run: go mod download
- name: Compile the testing binaries
run: |
pushd ./go/pkg/bertymessenger && go test -tags "fts5 sqlite sqlite_unlock_notify" -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
working-directory: go
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: Compile the project on Unix-like operating systems
working-directory: go
run: |
touch gen.sum # avoid triggering make generate
make go.install
- 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
working-directory: go
env:
TEST_SPEED: fast
GO_TEST_OPTS: -test.timeout=600s -count 1 -tags "fts5 sqlite sqlite_unlock_notify"
run: set -o pipefail; make go.unittest | tee test_log.txt
- name: Run all tests
working-directory: go
env:
TEST_SPEED: any
GO_TEST_OPTS: -test.timeout=600s -count 1 -tags "fts5 sqlite sqlite_unlock_notify"
run: make go.unittest
- name: Run all tests with race flag and generate coverage
working-directory: go
env:
TEST_SPEED: any
GO_TEST_OPTS: -test.timeout=1200s -count=1 -race -cover -tags "fts5 sqlite sqlite_unlock_notify" -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: Compile the project on Windows
run: go.exe install -buildmode=exe ./go/cmd/...
- 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
working-directory: go
env:
TEST_SPEED: fast
run: go.exe test ./... -tags "fts5 sqlite sqlite_unlock_notify" -buildmode=exe -timeout=600s -count=5
- name: Run all tests
working-directory: go
env:
TEST_SPEED: any
run: go.exe test ./... -tags "fts5 sqlite sqlite_unlock_notify" -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: Compile the project on Unix-like operating systems
working-directory: go
run: |
touch gen.sum # avoid triggering make generate
make go.install
- 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
working-directory: go
env:
TEST_SPEED: fast
GO_TEST_OPTS: -test.timeout=600s -count 1 -tags "fts5 sqlite sqlite_unlock_notify"
run: set -o pipefail; make go.unittest | tee test_log.txt
- name: Run all tests
working-directory: go
env:
TEST_SPEED: any
GO_TEST_OPTS: -test.timeout=600s -count 1 -tags "fts5 sqlite sqlite_unlock_notify"
run: make go.unittest
- name: Run all tests with race flag and generate coverage
working-directory: go
env:
TEST_SPEED: any
GO_TEST_OPTS: -test.timeout=1200s -count=1 -race -cover -tags "fts5 sqlite sqlite_unlock_notify" -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.