forked from libos-nuse/rumprun-packages
-
Notifications
You must be signed in to change notification settings - Fork 3
445 lines (407 loc) · 16 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
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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
name: CI
on:
push:
branches:
- '**'
pull_request:
branches:
- master
- 'release/**'
release:
types:
- created
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
jobs:
#
# setup/build/package
#
build:
name: ${{ matrix.package }} (${{ matrix.os }}/${{ matrix.arch }})
runs-on: ${{ matrix.runs_on }}
strategy:
fail-fast: false
matrix:
os: [macos, linux]
arch: [amd64, arm32, arm64]
package: [python3, nodejs, named, netperf, nginx, redis, sqlite-bench, zlib]
exclude:
- os: macos
arch: arm32
- os: macos
arch: arm64
- os: linux
arch: arm32
package: nodejs
- os: linux
arch: arm64
package: nodejs
include:
- displayTargetName: linux-amd64
os: linux
arch: amd64
os_alias: linux
arch_alias: amd64
runs_on: ubuntu-24.04
cc: clang
cxx: clang++
rumprun_tuple: x86_64-rumprun-linux
- displayTargetName: macOS-amd64
os: macos
arch: amd64
os_alias: osx
arch_alias: amd64
runs_on: macos-12
cc: clang
cxx: clang++
rumprun_tuple: x86_64-rumprun-linux
- displayTargetName: linux-arm32
os: linux
arch: arm32
os_alias: linux
arch_alias: armhf
runs_on: ubuntu-24.04
cc: arm-linux-gnueabihf-gcc
cxx: g++
rumprun_tuple: arm-rumprun-linux
- displayTargetName: linux-arm64
os: linux
arch: arm64
os_alias: linux
arch_alias: arm64
runs_on: ubuntu-24.04
cc: aarch64-linux-gnu-gcc
cxx: g++
rumprun_tuple: aarch64-rumprun-linux
- package: named
package_alias: named
- package: netperf
package_alias: netperf
- package: nginx
package_alias: nginx
- package: nodejs
package_alias: node
- package: python3
package_alias: python
- package: redis
package_alias: redis-server
- package: sqlite-bench
package_alias: sqlite-bench
timeout-minutes: 100
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
USE_CCACHE: 1
working-directory: src/rumprun-packages
ARCH: ${{ matrix.arch }}
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
RUMPRUN_TOOLCHAIN_TUPLE: ${{ matrix.rumprun_tuple }}
C_INCLUDE_PATH: /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/Headers
CPLUS_INCLUDE_PATH: /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/Headers
defaults:
run:
working-directory: src/rumprun-packages
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: src/rumprun-packages
submodules: true
- name: Install frankenlibc
env:
URL: "https://github.com/ukontainer/frankenlibc/releases/download/latest/frankenlibc-${{ matrix.arch }}-${{ matrix.os_alias }}.tar.gz"
TINY_URL: "https://github.com/ukontainer/frankenlibc/releases/download/latest/frankenlibc-tiny-${{ matrix.arch }}-${{ matrix.os_alias }}.tar.gz"
run: |
curl -L ${{ env.URL }} -o /tmp/frankenlibc.tar.gz
sudo mkdir -p /opt/rump && sudo chown $USER /opt/rump
tar xfz /tmp/frankenlibc.tar.gz -C /
curl -L ${{ env.TINY_URL }} -o /tmp/frankenlibc-tiny.tar.gz
sudo mkdir -p /opt/rump-tiny && sudo chown $USER /opt/rump-tiny
tar xfz /tmp/frankenlibc-tiny.tar.gz -C /
echo RUMPRUN_TOOLCHAIN_TUPLE=${{ env.RUMPRUN_TOOLCHAIN_TUPLE }} >config.mk
- name: Set env
shell: bash
run: |
echo "/usr/lib/ccache/bin:/usr/lib/ccache:/usr/local/opt/ccache/libexec:$HOME/.local/bin:/opt/rump/bin:${{ github.workspace }}/bin" >> $GITHUB_PATH
echo "export PATH=/usr/lib/ccache/bin:/usr/lib/ccache:/usr/local/opt/ccache/libexec:$HOME/.local/bin:/opt/rump/bin:${{ github.workspace }}/bin:$PATH" >> $HOME/.bashrc
- uses: actions/cache@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ runner.os }}-${{ matrix.arch }}-${{ matrix.package }}-ccache-build-${{ github.sha }}
restore-keys: ${{ runner.os }}-${{ matrix.arch }}-${{ matrix.package }}-ccache-build-
- name: pkg dependency
run: |
pip install yamlish --break-system-packages
- name: pkg dependency (linux)
if: runner.os == 'linux'
run: |
sudo apt update -y
sudo apt install -y ccache makefs genisoimage
sudo ln -sf /usr/bin/ccache /usr/lib/ccache/clang
sudo ln -sf /usr/bin/ccache /usr/lib/ccache/clang++
- name: pkg dependency (linux-cross)
if: runner.os == 'linux' && ( matrix.arch == 'arm32' || matrix.arch == 'arm64')
run: |
sudo apt-get update -y
sudo apt-get install -y crossbuild-essential-${{ matrix.arch_alias }}
- name: pkg dependency (macOS)
if: runner.os == 'macos'
run: |
mkdir -p ~/.local/bin
brew install gnu-sed ccache e2fsprogs
brew install binutils coreutils automake
ln -sf /usr/local/bin/gsed ~/.local/bin/sed
ln -sf /usr/local/bin/gdate ~/.local/bin/date
ln -sf /usr/local/opt/e2fsprogs/sbin/mkfs.ext4 ~/.local/bin/
ln -sf /usr/local/opt/e2fsprogs/sbin/mkfs.ext2 ~/.local/bin/
# we didn't use gcp as CoW of coreutil 9.0 breaks somehow
#ln -sf /usr/local/opt/coreutils/bin/gcp ~/.local/bin/cp
ln -sf /usr/local/opt/binutils/bin/objcopy ~/.local/bin/objcopy
- name: ccache counter reset
run: ccache -z
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: matrix.package == 'python3'
#if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
with:
detached: true
- name: build
run: |
make -j4 -C ${{ matrix.package }}
- name: upload artifact
if: matrix.package != 'zlib'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.package_alias }}-${{ matrix.os_alias }}-${{ matrix.arch }}
path: |
src/rumprun-packages/${{ matrix.package }}/bin/${{ matrix.package_alias }}
- name: upload artifact (nginx)
if: matrix.package == 'nginx'
uses: actions/upload-artifact@v4
with:
name: data-${{ matrix.os_alias }}-${{ matrix.arch }}.iso
path: |
src/rumprun-packages/${{ matrix.package }}/images/data.iso
- name: upload artifact (python3)
if: matrix.package == 'python3'
uses: actions/upload-artifact@v4
with:
name: python-${{ matrix.os_alias }}-${{ matrix.arch }}.iso
path: |
src/rumprun-packages/${{ matrix.package }}/images/python.iso
- name: upload artifact (python3/linux)
if: matrix.package == 'python3' && runner.os == 'linux' && matrix.arch == 'amd64'
uses: actions/upload-artifact@v4
with:
name: python-${{ matrix.os_alias }}-${{ matrix.arch }}.img
path: |
src/rumprun-packages/${{ matrix.package }}/images/python.img
- name: upload artifact (netperf)
if: matrix.package == 'netperf'
uses: actions/upload-artifact@v4
with:
name: netserver-${{ matrix.os_alias }}-${{ matrix.arch }}
path: |
src/rumprun-packages/${{ matrix.package }}/bin/netserver
- name: upload artifact (named)
if: matrix.package == 'named' && runner.os == 'linux'
uses: actions/upload-artifact@v4
with:
name: named-${{ matrix.os_alias }}-${{ matrix.arch }}.img
path: |
src/rumprun-packages/${{ matrix.package }}/images/named.img
- name: build (tiny)
run: |
make distclean -C ${{ matrix.package }}
PATH=/opt/rump-tiny/bin:$PATH make -j4 -C ${{ matrix.package }}
# XXX: TODO use cross tools
strip ${{ matrix.package }}/bin/${{ matrix.package_alias }} || true
- name: upload artifact (tiny)'
if: matrix.package != 'zlib'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.package_alias }}-${{ matrix.os_alias }}-${{ matrix.arch }}-slim
path: |
src/rumprun-packages/${{ matrix.package }}/bin/${{ matrix.package_alias }}
- name: upload artifact (netperf) (tiny)
if: matrix.package == 'netperf'
uses: actions/upload-artifact@v4
with:
name: netserver-${{ matrix.os_alias }}-${{ matrix.arch }}-slim
path: |
src/rumprun-packages/${{ matrix.package }}/bin/netserver
- name: ccache stat
if: always()
run: |
ccache --show-stats
- name: Annotate
uses: yuzutech/annotations-action@v0.5.0
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
input: "${{env.working-directory}}/annotations.json"
title: "dmesg (${{ matrix.runs_on }})"
docker-image:
needs: build
runs-on: ubuntu-24.04
name: image
if: ${{ github.event_name == 'release' }}
strategy:
fail-fast: false
matrix:
package: [named, netperf, nginx, node, python, sqlite-bench, base]
image_type: ["", "-slim"]
permissions:
contents: read
packages: write
services:
registry:
image: registry:2
ports:
- 5000:5000
env:
registry: ghcr.io/
#registry: localhost:5050/
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v2
with:
path: artifacts
- name: Display structure of downloaded files
run: ls -lR
working-directory: artifacts
- name: build rootfs
run: |
#set -x
mkdir -p rootfs
cd rootfs
for target in darwin/amd64 linux/amd64 linux/arm/v7 linux/arm64
do
mkdir -p imgs $target/bin $target/sbin
SUFFIX=""
RSUFFIX=""
if [ "$target" == "darwin/amd64" ] ; then
SUFFIX="osx-amd64"
RSUFFIX="amd64-osx"
elif [ "$target" == "linux/amd64" ] ; then
SUFFIX="linux-amd64"
RSUFFIX="amd64-linux"
elif [ "$target" == "linux/arm/v7" ] ; then
SUFFIX="linux-arm32"
RSUFFIX="arm32-linux"
elif [ "$target" == "linux/arm64" ] ; then
SUFFIX="linux-arm64"
RSUFFIX="arm64-linux"
fi
if [ "${{ matrix.image_type }}" == "-slim" ] ; then
SUFFIX=$SUFFIX"-slim"
RSUFFIX="tiny-"$RSUFFIX
fi
if [ ${{ matrix.package }} != "base" ] ; then
if [ -f ../artifacts/${{ matrix.package }}-$SUFFIX/${{ matrix.package }} ] ; then
cp ../artifacts/${{ matrix.package }}-$SUFFIX/${{ matrix.package }} $target/bin
fi
fi
if [ ${{ matrix.package }} == "python" ] ; then
mkdir -p $target/usr/lib/
7z x -o$target/usr/lib ../artifacts/python-${SUFFIX//-slim/}.iso/python.iso
find ./$target/usr/lib -name __pycache__ | xargs rm -rf
elif [ ${{ matrix.package }} == "nginx" ] ; then
cp ../artifacts/data-${SUFFIX//-slim/}.iso/data.iso ./imgs/
elif [ ${{ matrix.package }} == "netperf" ] ; then
cp ../artifacts/netserver-$SUFFIX/netserver $target/bin
elif [ ${{ matrix.package }} == "named" ] ; then
mkdir -p ./etc/bind/
cp ../named/named.conf ./etc/bind/
cp ../named/*.zone ./etc/bind/
elif [ ${{ matrix.package }} == "base" ] ; then
cp ../artifacts/nginx-$SUFFIX/nginx $target/bin
cp ../artifacts/python-$SUFFIX/python $target/bin
cp ../artifacts/netperf-$SUFFIX/netperf $target/bin
cp ../artifacts/netserver-$SUFFIX/netserver $target/bin
cp ../artifacts/named-$SUFFIX/named $target/bin
cp ../artifacts/sqlite-bench-$SUFFIX/sqlite-bench $target/bin
cp ../artifacts/python-$SUFFIX/python $target/bin
cp ../artifacts/data-${SUFFIX//-slim/}.iso/data.iso ./imgs/
cp ../artifacts/python-${SUFFIX//-slim/}.iso/python.iso ./imgs/
cp ../artifacts/named-linux-amd64.img/named.img ./imgs/
cp ../artifacts/python-linux-amd64.img/python.img ./imgs/
curl -L \
https://github.com/ukontainer/frankenlibc/releases/download/latest/frankenlibc-${RSUFFIX//tiny-}.tar.gz \
-o /tmp/frankenlibc.tar.gz
tar xfz /tmp/frankenlibc.tar.gz -C /tmp/
cp -f /tmp/opt/rump/bin/hello $target/bin
cp -f /tmp/opt/rump/bin/ping $target/bin
cp -f /tmp/opt/rump/bin/ping6 $target/bin
cp -f /tmp/opt/rump/bin/rexec $target/sbin
chmod +x $target/sbin/*
fi
chmod +x $target/bin/* || true
done
cp ../utils/* ./
if [ ${{ matrix.package }} == "python" ] ; then
cp ../python3/Dockerfile ./
elif [ ${{ matrix.package }} == "named" ] ; then
cp ../named/Dockerfile ./
fi
tree -hp .
cd ..
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: Log in to docker.io
uses: docker/login-action@v1.10.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to the ghcr.io
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set environment variables for branch name
run: |
# Short name for current branch. For PRs, use target branch (base ref)
GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/*/}}
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: rootfs
platforms: linux/amd64,linux/arm64,linux/arm,darwin/amd64
push: true
tags: |
ghcr.io/ukontainer/runu-${{ matrix.package }}:${{ env.GIT_BRANCH }}${{ matrix.image_type }}
docker.io/ukontainer/runu-${{ matrix.package }}:${{ env.GIT_BRANCH }}${{ matrix.image_type }}
- name: Inspect
run: |
docker buildx imagetools inspect \
ghcr.io/ukontainer/runu-${{ matrix.package }}:${{ env.GIT_BRANCH }}${{ matrix.image_type }}
docker buildx imagetools inspect \
docker.io/ukontainer/runu-${{ matrix.package }}:${{ env.GIT_BRANCH }}${{ matrix.image_type }}
trigger:
needs: docker-image
runs-on: ubuntu-24.04
name: downstream
if: ${{ github.event_name == 'release' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set environment variables for image name
run: |
IMAGE_VERSION=`git describe --tags --abbrev=0 | sed "s/^v//"`
echo "IMAGE_VERSION=$IMAGE_VERSION" >> $GITHUB_ENV
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: ukontainer/runu
event-type: trigger-test
client-payload: '{"img_version": "${{ env.IMAGE_VERSION }}", "repository": "$GITHUB_REPOSITORY"}'