-
Notifications
You must be signed in to change notification settings - Fork 33
362 lines (348 loc) · 11.3 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
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ '*' ]
# NOTE: these paths should be the same as the ones in ci_skipped.yml
paths-ignore:
- 'docs/**'
- '.all-contributorsrc'
- 'README.md'
- 'LICENSE'
- 'metrics/**'
# Cancel old runs on the same branch (except on main)
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
MIX_ENV: test
RUST_WORKSPACES: |
native/snappy -> target
native/ssz_nif -> target
permissions:
contents: read
jobs:
compile-native:
name: Build native libraries
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
# NOTE: this is needed for the NIF header files
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: .tool-versions
hexpm-mirrors: |
https://builds.hex.pm
https://repo.hex.pm
- name: Set up Go
# NOTE: this action comes with caching by default
uses: actions/setup-go@v5
with:
go-version: "1.21"
cache-dependency-path: |
native/libp2p_nif/go.sum
native/libp2p_port/go.sum
- name: Cache output artifacts
id: output-cache
uses: actions/cache@v4
with:
path: priv/native/*
key: ${{ runner.os }}-native-${{ hashFiles('native/**') }}
- name: Install dependencies
if: steps.output-cache.outputs.cache-hit != 'true'
run: |
sudo apt-get install -y protobuf-compiler
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
protoc --go_out=./native/libp2p_port proto/libp2p.proto
- name: Compile native code
if: steps.output-cache.outputs.cache-hit != 'true'
run: make compile-port compile-native
download-beacon-node-oapi:
name: Download Beacon Node OAPI
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Cache Beacon Node OAPI
id: output-cache
uses: actions/cache@v4
with:
path: ./beacon-node-oapi.json
key: ${{ runner.os }}-beacon-node-oapi-${{ hashFiles('.oapi_version') }}
lookup-only: true
- name: Download Beacon Node OAPI
if: steps.output-cache.outputs.cache-hit != 'true'
run: make download-beacon-node-oapi
build:
name: Build project
needs: [compile-native, download-beacon-node-oapi]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
id: setup-beam
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: .tool-versions
hexpm-mirrors: |
https://builds.hex.pm
https://repo.hex.pm
- name: Fetch native libraries
id: output-cache
uses: actions/cache/restore@v4
with:
path: priv/native/*
key: ${{ runner.os }}-native-${{ hashFiles('native/**') }}
fail-on-cache-miss: true
- name: Restore dependencies cache
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Fetch beacon node oapi file
uses: actions/cache/restore@v4
with:
path: ./beacon-node-oapi.json
key: ${{ runner.os }}-beacon-node-oapi-${{ hashFiles('.oapi_version') }}
fail-on-cache-miss: true
- name: Install dependencies
run: |
sudo apt-get install -y protobuf-compiler
echo $(protoc --version)
mix escript.install --force hex protobuf
protoc --elixir_out=./lib proto/libp2p.proto
mix deps.get
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ env.RUST_WORKSPACES }}
- name: Compile Elixir (Warnings as errors)
run: mix compile --warnings-as-errors
- name: Retrieve PLT Cache
uses: actions/cache@v4
id: plt-cache
with:
path: priv/plts
key: ${{ runner.os }}-plts-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('mix.lock') }}
- name: Create PLTs
if: steps.plt-cache.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts
mix dialyzer --plt
- name: Run dialyzer
run: mix dialyzer --no-check
smoke:
name: Start and stop the node
needs: [compile-native, download-beacon-node-oapi]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: .tool-versions
hexpm-mirrors: |
https://builds.hex.pm
https://repo.hex.pm
- name: Fetch native libraries
id: output-cache
uses: actions/cache/restore@v4
with:
path: priv/native/*
key: ${{ runner.os }}-native-${{ hashFiles('native/**') }}
fail-on-cache-miss: true
- name: Restore dependencies cache
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Fetch beacon node oapi file
uses: actions/cache/restore@v4
with:
path: ./beacon-node-oapi.json
key: ${{ runner.os }}-beacon-node-oapi-${{ hashFiles('.oapi_version') }}
fail-on-cache-miss: true
- name: Install dependencies
run: |
sudo apt-get install -y protobuf-compiler
echo $(protoc --version)
mix escript.install --force hex protobuf
protoc --elixir_out=./lib proto/libp2p.proto
mix deps.get
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ env.RUST_WORKSPACES }}
- name: Compile Elixir (Warnings as errors)
run: mix compile --warnings-as-errors
- name: Run the node
# NOTE: this starts and then stops the application. It should catch simple runtime errors
run: mix run -- --checkpoint-sync-url https://mainnet-checkpoint-sync.stakely.io/
test:
name: Test
needs: [compile-native, download-beacon-node-oapi]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: .tool-versions
hexpm-mirrors: |
https://builds.hex.pm
https://repo.hex.pm
- name: Fetch native libraries
id: output-cache
uses: actions/cache/restore@v4
with:
path: priv/native/*
key: ${{ runner.os }}-native-${{ hashFiles('native/**') }}
fail-on-cache-miss: true
- name: Restore dependencies cache
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Fetch beacon node oapi file
uses: actions/cache/restore@v4
with:
path: ./beacon-node-oapi.json
key: ${{ runner.os }}-beacon-node-oapi-${{ hashFiles('.oapi_version') }}
fail-on-cache-miss: true
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ env.RUST_WORKSPACES }}
- name: Install dependencies
run: |
sudo apt-get install -y protobuf-compiler
mix escript.install --force hex protobuf
protoc --elixir_out=./lib proto/libp2p.proto
mix deps.get
- name: Run tests
run: mix test --no-start --warnings-as-errors --trace --exclude spectest
lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: .tool-versions
hexpm-mirrors: |
https://builds.hex.pm
https://repo.hex.pm
- name: Restore dependencies cache
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get
- name: Check format
run: |
make fmt
git diff --exit-code
- name: Run credo
run: mix credo --strict
download-spectests:
name: Download spectests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Cache compressed spectests
id: output-cache
uses: actions/cache@v4
with:
path: ./test/spec/vectors/*.tar.gz
key: ${{ runner.os }}-spectest-${{ hashFiles('.spectest_version') }}
lookup-only: true
- name: Download spectests
if: steps.output-cache.outputs.cache-hit != 'true'
run: make download-vectors
spectests-matrix:
name: Run spec-tests
needs: [compile-native, download-spectests, download-beacon-node-oapi]
strategy:
fail-fast: false
matrix:
fork: ["deneb"]
config: ["minimal", "general", "mainnet"]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
version-type: strict
version-file: .tool-versions
- name: Fetch native libraries
uses: actions/cache/restore@v4
with:
path: priv/native/*
key: ${{ runner.os }}-native-${{ hashFiles('native/**') }}
fail-on-cache-miss: true
- name: Fetch spectest vectors
uses: actions/cache/restore@v4
with:
path: ./test/spec/vectors/*.tar.gz
key: ${{ runner.os }}-spectest-${{ hashFiles('.spectest_version') }}
fail-on-cache-miss: true
- name: Restore dependencies cache
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Fetch beacon node oapi file
uses: actions/cache/restore@v4
with:
path: ./beacon-node-oapi.json
key: ${{ runner.os }}-beacon-node-oapi-${{ hashFiles('.oapi_version') }}
fail-on-cache-miss: true
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ env.RUST_WORKSPACES }}
- name: Install dependencies
run: |
sudo apt-get install -y protobuf-compiler
mix escript.install --force hex protobuf
protoc --elixir_out=./lib proto/libp2p.proto
mix deps.get
- name: Update fork version
run: echo ${{ matrix.fork }} > .fork_version
- name: Uncompress vectors
run: make test/spec/vectors/tests/${{ matrix.config }}
- name: Generate tests
run: make gen-spec
- name: Run tests
run: |
if [[ "${{ matrix.config }}" == "general" ]] ; then
mix test --no-start test/generated/general/*/*
else
mix test --no-start test/generated/${{ matrix.config }}/${{ matrix.fork }}/*
fi
spectests-success:
name: All spec-tests passed
needs: spectests-matrix
runs-on: ubuntu-22.04
if: always()
steps:
- if: needs.spectests-matrix.result == 'success'
name: All spectests passed
run: exit 0
- if: needs.spectests-matrix.result != 'success'
name: Some spectests failed
run: exit 1