forked from onflow/flow-go
-
Notifications
You must be signed in to change notification settings - Fork 1
260 lines (248 loc) · 8.27 KB
/
ci.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
name: CI
on:
push:
branches:
- 'auto-cadence-upgrade/**'
- staging
- trying
- 'feature/**'
- 'v[0-9]+.[0-9]+'
pull_request:
branches:
- master*
- 'auto-cadence-upgrade/**'
- 'feature/**'
- 'v[0-9]+.[0-9]+'
env:
GO_VERSION: 1.19
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
jobs:
golangci:
strategy:
fail-fast: false
matrix:
dir: [./, ./integration/, ./crypto/, ./insecure/]
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Build relic
run: make crypto_setup_gopath
- name: Run go generate
run: go generate
working-directory: ${{ matrix.dir }}
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.49
args: -v --build-tags relic
working-directory: ${{ matrix.dir }}
# https://github.com/golangci/golangci-lint-action/issues/244
skip-cache: true
tidy:
name: Tidy
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Run tidy
run: make tidy
- name: Emulator no relic check
run: make emulator-norelic-check
shell-check:
name: ShellCheck
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@203a3fd018dfe73f8ae7e3aa8da2c149a5f41c33
with:
scandir: './crypto'
ignore: 'relic'
create-dynamic-test-matrix:
name: Create Dynamic Test Matrix
runs-on: ubuntu-latest
outputs:
dynamic-matrix: ${{ steps.set-test-matrix.outputs.dynamicMatrix }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Set Test Matrix
id: set-test-matrix
run: go run utils/test_matrix/test_matrix.go access admin cmd consensus engine fvm ledger module network utils
unit-test:
name: Unit Tests (${{ matrix.targets.name }})
needs: create-dynamic-test-matrix
strategy:
fail-fast: false
matrix:
targets: ${{ fromJSON(needs.create-dynamic-test-matrix.outputs.dynamic-matrix)}}
# need to set image explicitly due to GitHub logging issue as described in https://github.com/onflow/flow-go/pull/3087#issuecomment-1234383202
runs-on: ubuntu-20.04
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Setup tests (${{ matrix.targets.name }}
run: VERBOSE=1 make -e GO_TEST_PACKAGES="${{ matrix.targets.packages }}" install-tools
- name: Run tests (${{ matrix.targets.name }})
uses: nick-fields/retry@v2
with:
timeout_minutes: 25
max_attempts: 3
command: VERBOSE=1 make -e GO_TEST_PACKAGES="${{ matrix.targets.packages }}" test
# TODO(rbtz): re-enable when we fix exisiting races.
#env:
# RACE_DETECTOR: 1
- name: Upload coverage report
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
flags: unittests
name: codecov-umbrella
unit-test-modules:
name: Unit Tests (Modules)
strategy:
fail-fast: false
matrix:
include:
- name: crypto
make1: -C crypto setup
make2: unittest
retries: 1
race: 1
- name: insecure
make1: install-tools
make2: test
retries: 3
race: 1
- name: integration
make1: install-tools
make2: test
retries: 3
race: 0
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Setup tests (${{ matrix.name }})
run: make ${{ matrix.make1 }}
- name: Run tests (${{ matrix.name }})
env:
RACE_DETECTOR: ${{ matrix.race }}
uses: nick-fields/retry@v2
with:
timeout_minutes: 25
max_attempts: ${{ matrix.retries }}
# run `make2` target inside each module's root
command: VERBOSE=1 make -C ${{ matrix.name }} ${{ matrix.make2 }}
- name: Upload coverage report
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
flags: unittests
name: codecov-umbrella
integration-test:
name: Integration Tests
strategy:
fail-fast: false
matrix:
make:
- make -C integration access-tests
- make -C integration bft-tests
- make -C integration collection-tests
- make -C integration consensus-tests
- make -C integration epochs-tests
- make -C integration execution-tests
- make -C integration ghost-tests
- make -C integration mvp-tests
- make -C integration network-tests
- make -C integration verification-tests
- make -C integration upgrades-tests
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Build relic
run: make crypto_setup_gopath
- name: Docker build
run: make docker-build-flow docker-build-flow-corrupt
- name: Run tests
# TODO(rbtz): re-enable when we fix exisiting races.
#env:
# RACE_DETECTOR: 1
uses: nick-fields/retry@v2
with:
timeout_minutes: 25
max_attempts: 3
command: VERBOSE=1 ${{ matrix.make }}
localnet-test:
name: Localnet Compatibility Tests With Flow-CLI Client and Observer
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Build relic and other tools
run: make install-tools
- name: Install Flow Client In Docker
# This proved to be more reliable than installing it locally.
run: cd integration/localnet && sh client/client.sh
- name: Set up Localnet
run: bash -c 'cd integration/localnet/ && make -e OBSERVER=2 bootstrap && make start-flow'
- name: Ensure Observer is started
run: docker ps -f name=localnet_observer_1_1 | grep localnet_observer
- name: Get Client Version ensuring the client is provisioned
run: docker run --network host localnet-client /go/flow -f /go/flow-localnet.json -n observer version
- name: Wait for a default waiting period until a clean state
# This will not cause flakiness.
# The waiting time is a reasonable time to expect an observer to be responsive
run: sleep 10
- name: Get Status ensuring the access endpoint is online
run: docker run --network host localnet-client /go/flow -f /go/flow-localnet.json -n access status
- name: Wait for finalized blocks and check them
run: docker run --network host localnet-client /go/flow -f /go/flow-localnet.json -n observer blocks get latest
- name: Wait for finalized blocks and check them with Observer
run: sleep 5 && docker run --network host localnet-client /go/flow -f /go/flow-localnet.json -n access blocks get latest && docker run --network host localnet-client /go/flow -f /go/flow-localnet.json -n observer blocks get latest
- name: Stop localnet
run: bash -c 'cd integration/localnet/ && make stop'