-
Notifications
You must be signed in to change notification settings - Fork 48
387 lines (342 loc) · 13 KB
/
build-and-test.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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
name: Build and Test
on:
push:
branches:
- "develop"
- "main"
pull_request:
schedule:
- cron: "0 0 * * 1"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ (github.ref == 'refs/heads/main' && github.run_number) || github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
matrix:
just_variants:
- async-std
- tokio
test_suites:
- test-ci-1
- test-ci-2
- test-ci-3
- test-ci-4
- test-ci-5
- test-ci-rest
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout Repository
- name: Install Rust
uses: mkroening/rust-toolchain-toml@main
- uses: Swatinem/rust-cache@v2
name: Enable Rust Caching
with:
shared-key: "test"
prefix-key: ${{ matrix.just_variants }}
cache-on-failure: "true"
save-if: ${{ github.ref == 'refs/heads/main' && matrix.test_suites == 'test-ci-rest' }}
- name: Install Just
run: |
wget https://github.com/casey/just/releases/download/1.14.0/just-1.14.0-x86_64-unknown-linux-musl.tar.gz
tar -vxf just-1.14.0-x86_64-unknown-linux-musl.tar.gz just
sudo cp just /usr/bin/just
- uses: taiki-e/install-action@nextest
- name: Unit and integration tests for all crates in workspace
run: |
just ${{ matrix.just_variants }} ${{ matrix.test_suites }}
timeout-minutes: 60
env:
RUST_BACKTRACE: full
test-dependency-tasks:
strategy:
matrix:
just_variants:
- async-std
- tokio
test_suites:
- test-ci-1
- test-ci-2
- test-ci-3
- test-ci-4
- test-ci-5
- test-ci-rest
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout Repository
- name: Install Rust
uses: mkroening/rust-toolchain-toml@main
- uses: Swatinem/rust-cache@v2
name: Enable Rust Caching
with:
shared-key: "test"
prefix-key: ${{ matrix.just_variants }}
cache-on-failure: "true"
save-if: "false"
- name: Install Just
run: |
wget https://github.com/casey/just/releases/download/1.14.0/just-1.14.0-x86_64-unknown-linux-musl.tar.gz
tar -vxf just-1.14.0-x86_64-unknown-linux-musl.tar.gz just
sudo cp just /usr/bin/just
- uses: taiki-e/install-action@nextest
- name: Unit and integration tests for all crates in workspace
run: |
just ${{ matrix.just_variants }} ${{ matrix.test_suites }} --features dependency-tasks
timeout-minutes: 60
env:
RUST_BACKTRACE: full
test-examples:
strategy:
matrix:
just_variants:
- async-std
- tokio
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout Repository
- name: Install Rust
uses: mkroening/rust-toolchain-toml@main
- uses: Swatinem/rust-cache@v2
name: Enable Rust Caching
with:
shared-key: "examples"
prefix-key: ${{ matrix.just_variants }}
cache-on-failure: "true"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install Just
run: |
wget https://github.com/casey/just/releases/download/1.14.0/just-1.14.0-x86_64-unknown-linux-musl.tar.gz
tar -vxf just-1.14.0-x86_64-unknown-linux-musl.tar.gz just
sudo cp just /usr/bin/just
- name: Test examples
run: |
just ${{ matrix.just_variants }} example all-push-cdn -- --config_file ./crates/orchestrator/run-config.toml
timeout-minutes: 20
build-release:
strategy:
matrix:
just_variants:
- async-std
- tokio
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout Repository
- name: Install Rust
uses: mkroening/rust-toolchain-toml@main
- uses: Swatinem/rust-cache@v2
name: Enable Rust Caching
with:
shared-key: "build-release"
prefix-key: ${{ matrix.just_variants }}
cache-on-failure: "true"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install Just
run: |
wget https://github.com/casey/just/releases/download/1.14.0/just-1.14.0-x86_64-unknown-linux-musl.tar.gz
tar -vxf just-1.14.0-x86_64-unknown-linux-musl.tar.gz just
sudo cp just /usr/bin/just
- name: Build examples in release mode
run: just ${{ matrix.just_variants }} build_release --examples --package hotshot-examples --no-default-features
- name: Upload Binaries
uses: actions/upload-artifact@v4
with:
name: binaries-amd64-${{ matrix.just_variants }}
path: |
target/${{ matrix.just_variants }}/release/examples/counter
target/${{ matrix.just_variants }}/release/examples/multi-validator-libp2p
target/${{ matrix.just_variants }}/release/examples/validator-libp2p
target/${{ matrix.just_variants }}/release/examples/validator-combined
target/${{ matrix.just_variants }}/release/examples/validator-push-cdn
target/${{ matrix.just_variants }}/release/examples/orchestrator
target/${{ matrix.just_variants }}/release/examples/cdn-broker
target/${{ matrix.just_variants }}/release/examples/cdn-marshal
build-arm-release:
strategy:
matrix:
just_variants:
- async-std
- tokio
fail-fast: false
runs-on: buildjet-4vcpu-ubuntu-2204-arm
if: ${{ github.ref == 'refs/heads/main' }}
container: ghcr.io/espressosystems/devops-rust:stable
steps:
- uses: actions/checkout@v4
name: Checkout Repository
- uses: Swatinem/rust-cache@v2
name: Enable Rust Caching
with:
shared-key: "build-arm-release"
prefix-key: ${{ matrix.just_variants }}
cache-on-failure: "true"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build examples in release mode
run: just ${{ matrix.just_variants }} build_release --examples --package hotshot-examples --no-default-features
- name: Upload Binaries
uses: actions/upload-artifact@v4
with:
name: binaries-aarch64-${{ matrix.just_variants }}
path: |
target/${{ matrix.just_variants }}/release/examples/counter
target/${{ matrix.just_variants }}/release/examples/multi-validator-libp2p
target/${{ matrix.just_variants }}/release/examples/validator-libp2p
target/${{ matrix.just_variants }}/release/examples/validator-combined
target/${{ matrix.just_variants }}/release/examples/validator-push-cdn
target/${{ matrix.just_variants }}/release/examples/orchestrator
target/${{ matrix.just_variants }}/release/examples/cdn-broker
target/${{ matrix.just_variants }}/release/examples/cdn-marshal
build-dockers:
strategy:
matrix:
just_variants:
- async-std
- tokio
fail-fast: false
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
needs: [build-release, build-arm-release, test]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Docker BuildKit (buildx)
uses: docker/setup-buildx-action@v3
- name: Login to Github Container Repo
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download AMD executables
uses: actions/download-artifact@v4
with:
name: binaries-amd64-${{ matrix.just_variants }}
path: target/${{ matrix.just_variants }}/amd64/release/examples
- name: Download ARM executables
uses: actions/download-artifact@v4
with:
name: binaries-aarch64-${{ matrix.just_variants }}
path: target/${{ matrix.just_variants }}/arm64/release/examples
- name: Generate validator-libp2p docker metadata
uses: docker/metadata-action@v5
id: validator-libp2p
with:
images: ghcr.io/espressosystems/hotshot/validator-libp2p
flavor: suffix=-${{ matrix.just_variants }}
- name: Generate validator-combined docker metadata
uses: docker/metadata-action@v5
id: validator-combined
with:
images: ghcr.io/espressosystems/hotshot/validator-combined
flavor: suffix=-${{ matrix.just_variants }}
- name: Generate validator-push-cdn docker metadata
uses: docker/metadata-action@v5
id: validator-push-cdn
with:
images: ghcr.io/espressosystems/hotshot/validator-push-cdn
flavor: suffix=-${{ matrix.just_variants }}
- name: Generate orchestrator docker metadata
uses: docker/metadata-action@v5
id: orchestrator
with:
images: ghcr.io/espressosystems/hotshot/orchestrator
flavor: suffix=-${{ matrix.just_variants }}
- name: Generate cdn-broker docker metadata
uses: docker/metadata-action@v5
id: cdn-broker
with:
images: ghcr.io/espressosystems/hotshot/cdn-broker
flavor: suffix=-${{ matrix.just_variants }}
- name: Generate cdn-marshal docker metadata
uses: docker/metadata-action@v5
id: cdn-marshal
with:
images: ghcr.io/espressosystems/hotshot/cdn-marshal
flavor: suffix=-${{ matrix.just_variants }}
- name: Build and push validator-libp2p docker
uses: docker/build-push-action@v6
with:
context: ./
file: ./docker/validator-libp2p.Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.validator-libp2p.outputs.tags }}
labels: ${{ steps.validator-libp2p.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
ASYNC_EXECUTOR=${{ matrix.just_variants }}
- name: Build and push validator-combined docker
uses: docker/build-push-action@v6
with:
context: ./
file: ./docker/validator-combined.Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.validator-combined.outputs.tags }}
labels: ${{ steps.validator-combined.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
ASYNC_EXECUTOR=${{ matrix.just_variants }}
- name: Build and push validator-push-cdn docker
uses: docker/build-push-action@v6
with:
context: ./
file: ./docker/validator-cdn.Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.validator-push-cdn.outputs.tags }}
labels: ${{ steps.validator-push-cdn.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
ASYNC_EXECUTOR=${{ matrix.just_variants }}
- name: Build and push orchestrator docker
uses: docker/build-push-action@v6
with:
context: ./
file: ./docker/orchestrator.Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.orchestrator.outputs.tags }}
labels: ${{ steps.orchestrator.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
ASYNC_EXECUTOR=${{ matrix.just_variants }}
- name: Build and push cdn-broker docker
uses: docker/build-push-action@v6
with:
context: ./
file: ./docker/cdn-broker.Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.cdn-broker.outputs.tags }}
labels: ${{ steps.cdn-broker.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
ASYNC_EXECUTOR=${{ matrix.just_variants }}
- name: Build and push cdn-marshal docker
uses: docker/build-push-action@v6
with:
context: ./
file: ./docker/cdn-marshal.Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.cdn-marshal.outputs.tags }}
labels: ${{ steps.cdn-marshal.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
ASYNC_EXECUTOR=${{ matrix.just_variants }}