-
Notifications
You must be signed in to change notification settings - Fork 48
290 lines (250 loc) · 9.07 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
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:
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"
cache-on-failure: "true"
save-if: ${{ github.ref == 'refs/heads/main' && matrix.test_suites == 'test-ci-rest' }}
- uses: taiki-e/install-action@just
- uses: taiki-e/install-action@nextest
- name: Unit and integration tests for all crates in workspace
run: |
just ${{ matrix.test_suites }}
timeout-minutes: 60
env:
RUST_BACKTRACE: full
test-examples:
strategy:
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"
cache-on-failure: "true"
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: taiki-e/install-action@just
- name: Test examples
run: |
just example all-push-cdn -- --config_file ./crates/orchestrator/run-config.toml
timeout-minutes: 20
build-release:
strategy:
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"
cache-on-failure: "true"
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: taiki-e/install-action@just
- name: Build examples in release mode
run: just build_release --examples --package hotshot-examples --no-default-features
- name: Upload Binaries
uses: actions/upload-artifact@v4
with:
name: binaries-amd64
path: |
target/release/examples/counter
target/release/examples/multi-validator-libp2p
target/release/examples/validator-libp2p
target/release/examples/validator-combined
target/release/examples/validator-push-cdn
target/release/examples/orchestrator
target/release/examples/cdn-broker
target/release/examples/cdn-marshal
build-arm-release:
strategy:
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"
cache-on-failure: "true"
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build examples in release mode
run: just build_release --examples --package hotshot-examples --no-default-features
- name: Upload Binaries
uses: actions/upload-artifact@v4
with:
name: binaries-aarch64
path: |
target/release/examples/counter
target/release/examples/multi-validator-libp2p
target/release/examples/validator-libp2p
target/release/examples/validator-combined
target/release/examples/validator-push-cdn
target/release/examples/orchestrator
target/release/examples/cdn-broker
target/release/examples/cdn-marshal
build-dockers:
strategy:
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
path: target/amd64/release/examples
- name: Download ARM executables
uses: actions/download-artifact@v4
with:
name: binaries-aarch64
path: target/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
- name: Generate validator-combined docker metadata
uses: docker/metadata-action@v5
id: validator-combined
with:
images: ghcr.io/espressosystems/hotshot/validator-combined
- 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
- name: Generate orchestrator docker metadata
uses: docker/metadata-action@v5
id: orchestrator
with:
images: ghcr.io/espressosystems/hotshot/orchestrator
- name: Generate cdn-broker docker metadata
uses: docker/metadata-action@v5
id: cdn-broker
with:
images: ghcr.io/espressosystems/hotshot/cdn-broker
- name: Generate cdn-marshal docker metadata
uses: docker/metadata-action@v5
id: cdn-marshal
with:
images: ghcr.io/espressosystems/hotshot/cdn-marshal
- 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
- 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
- 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
- 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
- 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
- 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