-
Notifications
You must be signed in to change notification settings - Fork 7
367 lines (327 loc) · 14.6 KB
/
build.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
name: Build/Test/Release
on: [push]
env:
EMULATOR_REPOSITORY: cartesi/machine-emulator
EMULATOR_TAG: 0.16.1
KERNEL_VERSION: v0.19.1
LINUX_VERSION: 6.5.9-ctsi-1-v0.19.1
TOOLS_VERSION: v0.14.0
CARTESI_IMAGES_PATH: /usr/share/cartesi-machine/images
HOST_IMAGES_PATH: /tmp/cartesi-machine-images/
permissions:
id-token: write
packages: write
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Checkout server-manager source code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build Debian based docker image
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ github.repository_owner }}/server-manager:devel
push: false
load: true
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
build-args: |
RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }}
EMULATOR_REPOSITORY=${{ env.EMULATOR_REPOSITORY }}
EMULATOR_TAG=${{ env.EMULATOR_TAG }}
project: ${{ vars.DEPOT_PROJECT }}
test-ioctl-echo-loop:
strategy:
matrix:
include:
- arch: "amd64"
fast: false
- arch: "arm64"
fast: true
name: Test with ioctl-echo-loop (${{ matrix.arch }})
needs: build
runs-on: ubuntu-22.04
steps:
- name: Checkout server-manager source code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build Debian based docker image
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
platforms: linux/${{ matrix.arch }}
tags: ${{ github.repository_owner }}/server-manager:devel
push: false
load: true
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
build-args: |
RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }}
EMULATOR_REPOSITORY=${{ env.EMULATOR_REPOSITORY }}
EMULATOR_TAG=${{ env.EMULATOR_TAG }}
project: ${{ vars.DEPOT_PROJECT }}
- name: Build installer stage docker image
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
target: installer
platforms: linux/${{ matrix.arch }}
tags: ${{ github.repository_owner }}/server-manager:installer
push: false
load: true
cache-from: type=gha,scope=debian-installer
cache-to: type=gha,mode=max,scope=debian-installer
build-args: |
RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }}
EMULATOR_REPOSITORY=${{ env.EMULATOR_REPOSITORY }}
EMULATOR_TAG=${{ env.EMULATOR_TAG }}
project: ${{ vars.DEPOT_PROJECT }}
- name: Download [rootfs.ext2]
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/machine-emulator-tools
tag: ${{ env.TOOLS_VERSION }}
file: rootfs-tools-${{ env.TOOLS_VERSION }}.ext2
- name: Download [kernel.bin]
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/image-kernel
tag: ${{ env.KERNEL_VERSION }}
file: linux-${{ env.LINUX_VERSION }}.bin
- name: Move images to cartesi images folder
run: |
mkdir -m 755 -p /tmp/cartesi-machine-images
mv linux-*.bin rootfs-*.ext2 ${{ env.HOST_IMAGES_PATH }}
cd ${{ env.HOST_IMAGES_PATH }} && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin
cd ${{ env.HOST_IMAGES_PATH }} && ln -s rootfs-tools-${{ env.TOOLS_VERSION }}.ext2 rootfs.ext2
- name: Run test suite inside the docker image (Linux/${{ matrix.arch }})
run: |
docker volume create --name server-manager-root
docker network create mynetwork
docker run --platform linux/${{ matrix.arch }} --rm -v server-manager-root:/tmp/server-manager-root ${{ github.repository_owner }}/server-manager:installer chown -R cartesi:cartesi /tmp/server-manager-root
docker run --platform linux/${{ matrix.arch }} --rm -u cartesi:cartesi -v /tmp/cartesi-machine-images:${{ env.CARTESI_IMAGES_PATH }} -v server-manager-root:/tmp/server-manager-root ${{ github.repository_owner }}/server-manager:installer make create-machines
docker run --platform linux/${{ matrix.arch }} --rm -p 5001:5001 -h server-manager-container --name server-manager-container --network mynetwork -v server-manager-root:/tmp/server-manager-root ${{ github.repository_owner }}/server-manager:devel &
timeout 20 bash -c 'while ! nc -q0 127.0.0.1 5001 < /dev/null > /dev/null 2>&1; do sleep 1; done'
docker run --platform linux/${{ matrix.arch }} --rm -u cartesi:cartesi -h test-container --name test-container --network mynetwork -v /tmp/cartesi-machine-images:${{ env.CARTESI_IMAGES_PATH }} -v server-manager-root:/tmp/server-manager-root ${{ github.repository_owner }}/server-manager:installer make run-test-server-manager FAST_TEST=${{ matrix.fast }} MANAGER_ADDRESS=server-manager-container:5001
docker kill server-manager-container
test-echo-dapp:
strategy:
matrix:
include:
- arch: "amd64"
fast: false
- arch: "arm64"
fast: true
name: Test with rollup-init echo-dapp (${{ matrix.arch }})
needs: build
runs-on: ubuntu-22.04
steps:
- name: Checkout server-manager source code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build Debian based docker image
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
platforms: linux/${{ matrix.arch }}
tags: ${{ github.repository_owner }}/server-manager:devel
push: false
load: true
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
build-args: |
RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }}
EMULATOR_REPOSITORY=${{ env.EMULATOR_REPOSITORY }}
EMULATOR_TAG=${{ env.EMULATOR_TAG }}
project: ${{ vars.DEPOT_PROJECT }}
- name: Build installer stage docker image
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
target: installer
platforms: linux/${{ matrix.arch }}
tags: ${{ github.repository_owner }}/server-manager:installer
push: false
load: true
cache-from: type=gha,scope=debian-installer
cache-to: type=gha,mode=max,scope=debian-installer
build-args: |
RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }}
EMULATOR_REPOSITORY=${{ env.EMULATOR_REPOSITORY }}
EMULATOR_TAG=${{ env.EMULATOR_TAG }}
project: ${{ vars.DEPOT_PROJECT }}
- name: Download [rootfs.ext2]
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/machine-emulator-tools
tag: ${{ env.TOOLS_VERSION }}
file: rootfs-tools-${{ env.TOOLS_VERSION }}.ext2
- name: Download [kernel.bin]
uses: Legion2/[email protected]
with:
repository: ${{ github.repository_owner }}/image-kernel
tag: ${{ env.KERNEL_VERSION }}
file: linux-${{ env.LINUX_VERSION }}.bin
- name: Move images to cartesi images folder
run: |
mkdir -m 755 -p /tmp/cartesi-machine-images
mv linux-*.bin rootfs-*.ext2 ${{ env.HOST_IMAGES_PATH }}
cd ${{ env.HOST_IMAGES_PATH }} && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin
cd ${{ env.HOST_IMAGES_PATH }} && ln -s rootfs-tools-${{ env.TOOLS_VERSION }}.ext2 rootfs.ext2
- name: Run test suite inside the docker image (Linux/${{ matrix.arch }})
run: |
docker volume create --name server-manager-root
docker network create mynetwork
docker run --platform linux/${{ matrix.arch }} --rm -v server-manager-root:/tmp/server-manager-root ${{ github.repository_owner }}/server-manager:installer chown -R cartesi:cartesi /tmp/server-manager-root
docker run --platform linux/${{ matrix.arch }} --rm -u cartesi:cartesi -v /tmp/cartesi-machine-images:${{ env.CARTESI_IMAGES_PATH }} -v server-manager-root:/tmp/server-manager-root ${{ github.repository_owner }}/server-manager:installer make create-machines rollup_init=yes
docker run --platform linux/${{ matrix.arch }} --rm -p 5001:5001 -h server-manager-container --name server-manager-container --network mynetwork -v server-manager-root:/tmp/server-manager-root ${{ github.repository_owner }}/server-manager:devel &
timeout 20 bash -c 'while ! nc -q0 127.0.0.1 5001 < /dev/null > /dev/null 2>&1; do sleep 1; done'
docker run --platform linux/${{ matrix.arch }} --rm -u cartesi:cartesi -h test-container --name test-container --network mynetwork -v /tmp/cartesi-machine-images:${{ env.CARTESI_IMAGES_PATH }} -v server-manager-root:/tmp/server-manager-root ${{ github.repository_owner }}/server-manager:installer make run-test-server-manager FAST_TEST=${{ matrix.fast }} MANAGER_ADDRESS=server-manager-container:5001
docker kill server-manager-container
static-analysis:
name: Static Analysis
needs: build
runs-on: ubuntu-22.04
steps:
- name: Checkout server-manager source code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build Debian based docker image
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
target: installer
platforms: linux/amd64
tags: ${{ github.repository_owner }}/server-manager:installer
push: false
load: true
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
build-args: |
RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }}
EMULATOR_REPOSITORY=${{ env.EMULATOR_REPOSITORY }}
EMULATOR_TAG=${{ env.EMULATOR_TAG }}
project: ${{ vars.DEPOT_PROJECT }}
- name: Check format
run: docker run --rm ${{ github.repository_owner }}/server-manager:installer make check-format
- name: Lint
run: docker run --rm ${{ github.repository_owner }}/server-manager:installer make lint -j$(nproc)
release:
name: Publish Docker image
needs: [build, test-ioctl-echo-loop, test-echo-dapp, static-analysis]
runs-on: ubuntu-22.04
steps:
- name: Checkout server-manager source code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup debian docker image tags
id: debian_docker_image_tags
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository_owner }}/server-manager
docker.io/${{ github.repository_owner }}/server-manager,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/tags/v') }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}},enable=${{startsWith(github.ref, 'refs/tags/v')}}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build Debian based docker image
uses: depot/build-push-action@v1
with:
file: Dockerfile
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.debian_docker_image_tags.outputs.tags }}
push: true
load: false
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
build-args: |
RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }}
EMULATOR_REPOSITORY=${{ env.EMULATOR_REPOSITORY }}
EMULATOR_TAG=${{ env.EMULATOR_TAG }}
project: ${{ vars.DEPOT_PROJECT }}