forked from berty/berty
-
Notifications
You must be signed in to change notification settings - Fork 0
264 lines (257 loc) · 8.25 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
name: Go
on:
push:
tags:
- v*
branches:
- master
paths:
- "go/**"
- "!go/**.md"
- ".goreleaser"
- "go.*"
- "**.go"
- ".github/workflows/go.yml"
pull_request:
paths:
- "go/**"
- "!go/**.md"
- ".goreleaser"
- "go.*"
- "**.go"
- ".github/workflows/go.yml"
jobs:
goreleaser-dryrun:
name: "GoReleaser (dry-run)"
runs-on: ubuntu-latest
needs: golangci-lint
strategy:
matrix:
golang: ['1.16.x']
steps:
- name: Checkout
uses: actions/[email protected]
- name: Install libgl
run: |
sudo apt update
sudo apt install -f
sudo apt install -f -y libgl1-mesa-glx libgl1-mesa-dev xorg-dev
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.golang }}
- name: Cache Go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.golang }}-v1-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ matrix.golang }}-v1-
- name: Run GoReleaser (Dry Run)
uses: goreleaser/[email protected]
with:
version: latest
args: release --rm-dist --snapshot --skip-publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
golangci-lint:
name: "GolangCI-lint"
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.31
working-directory: go
args: --timeout=10m
# only-new-issues: true
# this is unusual to have a job that checks the unstable tests.
#
# reason: some tests are unstable, they works, but not always;
# this job checks that they are working sometimes.
# if this job fails, then a tests switched from "unstable" to "broken".
#
# summary: this job checks that "unstable tests" do not become "broken tests".
#
# we hope we can remove this job because all the tests are stable 100% of the time :)
unstable-tests:
name: "Unstable tests"
runs-on: ubuntu-latest
strategy:
matrix:
golang: ['1.16.x']
env:
OS: ubuntu-latest
GOLANG: ${{ matrix.golang }}
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.golang }}
- name: Cache Go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.golang }}-v1-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ matrix.golang }}-v1-
- name: Avoid triggering make generate
run: touch go/gen.sum
- name: Fetch dependencies
run: go mod download
- name: Compile the testing binaries
run: |
pushd ./go/pkg/bertyprotocol && go test -c -o ./tests.bin . && popd
pushd ./go/pkg/bertymessenger && go test -tags fts5 -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 unstable tests
working-directory: go
env:
TEST_SPEED: fast
TEST_STABILITY: unstable
run: make go.unstable-tests
# FIXME: coverage
go-tests-on-linux:
name: "Stable tests (linux)"
runs-on: ubuntu-latest
strategy:
matrix:
golang:
- 1.15.x
- 1.16.x
#- tip
env:
OS: ubuntu-latest
GOLANG: ${{ matrix.golang }}
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.golang }}
- name: Cache Go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.golang }}-v1-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ matrix.golang }}-v1-
- 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
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
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 -coverprofile=coverage.txt -covermode=atomic
run: make go.unittest
- name: Upload coverage to Codecov
uses: codecov/[email protected]
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
strategy:
matrix:
golang: ['1.16.x']
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.golang }}
- name: Cache Go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.golang }}-v1-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ matrix.golang }}-v1-
- 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 -buildmode=exe -timeout=600s -count=5
- name: Run all tests
working-directory: go
env:
TEST_SPEED: any
run: go.exe test ./... -tags fts5 -buildmode=exe -timeout=600s -count=1
# broken
#- name: Run all tests with race flag and generate coverage
# working-directory: go
# env:
# TEST_SPEED: any
# run: go.exe test ./... -buildmode=exe -v -timeout=1200s -count=1 -tags fts5 -race -cover -coverprofile=coverage.txt -covermode=atomic
#- name: Upload coverage to Codecov
# uses: codecov/[email protected]
# with:
# file: ./coverage.txt
# flags: unittests
# env_vars: OS,GOLANG
# name: codecov-umbrella
# fail_ci_if_error: false
go-install-on-darwin:
name: "make install (darwin)"
runs-on: macos-latest
strategy:
matrix:
golang: ['1.16.x']
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.golang }}
- name: Cache Go modules
uses: actions/[email protected]
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.golang }}-v1-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-${{ matrix.golang }}-v1-
- name: Install the project on Darwin
run: cd go && make 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
# TODO: consider adding various GOARCH check per OS.
# i.e., to validate that we build on 32/64bit.