Skip to content

Commit a150fee

Browse files
committed
ci: Make copy of logic for new aws runner
Based on a copy of the current logic Signed-off-by: Andy Doan <[email protected]>
1 parent 24f3168 commit a150fee

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Build debos recipe
2+
3+
on:
4+
# run on pull requests to the main branch
5+
pull_request:
6+
branches: [main]
7+
# run on pushes to the main branch
8+
push:
9+
branches: [main]
10+
# run daily at 8:30am
11+
schedule:
12+
- cron: '30 8 * * *'
13+
# allow manual runs
14+
workflow_dispatch:
15+
16+
# only need permission to read repository; implicitely set all other
17+
# permissions to none
18+
permissions:
19+
contents: read
20+
21+
defaults:
22+
# run all commands from the debos-recipes directory
23+
run:
24+
working-directory: debos-recipes
25+
26+
env:
27+
INCUS_IMAGE: images:debian/trixie/arm64
28+
INCUS_NAME: debos
29+
FILESERVER_DIR: /srv/gh-runners/quic-yocto/builds
30+
FILESERVER_URL: https://quic-yocto-fileserver-1029608027416.us-central1.run.app
31+
32+
# cancel in progress builds for this workflow triggered by the same ref
33+
concurrency:
34+
group: ${{ github.workflow }}-${{ github.ref }}
35+
cancel-in-progress: true
36+
37+
jobs:
38+
build-debos:
39+
runs-on: [self-hosted, arm64, debbuilder]
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
fetch-depth: 0
44+
45+
# make sure we have latest packages first, to get latest fixes and to
46+
# avoid an automated update while we're building
47+
- name: Update OS packages
48+
run: |
49+
set -x
50+
sudo apt update
51+
sudo apt -y upgrade
52+
sudo apt -y full-upgrade
53+
54+
# this is the default in our self-hosted runners
55+
- name: Make sure Incus is setup
56+
run: |
57+
set -x
58+
sudo apt -y install incus
59+
sudo incus admin init --auto
60+
61+
# create a fresh container build environment to decouple the build
62+
# operating system from the github runner one; install debos
63+
- name: Setup build environment
64+
run: |
65+
set -x
66+
# privileged container as debos will use mounts
67+
sudo incus init "${INCUS_IMAGE}" "${INCUS_NAME}" \
68+
-c security.privileged=true -c security.nesting=true
69+
sudo incus start "${INCUS_NAME}"
70+
# wait for network to be up (prior to running apt)
71+
sudo incus exec "${INCUS_NAME}" \
72+
/usr/lib/systemd/systemd-networkd-wait-online
73+
(
74+
# these commands are run inside the container
75+
cat <<EOF
76+
apt update
77+
apt -y upgrade
78+
apt -y full-upgrade
79+
apt -y install debos
80+
EOF
81+
) | sudo incus exec "${INCUS_NAME}" -- sh
82+
83+
- name: Build debos recipe
84+
run: |
85+
set -x
86+
# mount current directory under /build
87+
sudo incus config device add "${INCUS_NAME}" build-dir \
88+
disk "source=${PWD}" path=/build shift=true
89+
(
90+
# these commands are run inside the container
91+
cat <<EOF
92+
cd /build
93+
# debos tries KVM and UML as backends, and falls back to building
94+
# directly on the host, but that requires loop devices; use
95+
# qemu backend explicitly even if it's slower
96+
# qemu backend also requires to set scratchsize, otherwise
97+
# the whole build is done from memory and the out of memory
98+
# killer gets triggered
99+
debos -b qemu --scratchsize 4GiB qualcomm-linux-debian.yaml
100+
EOF
101+
) | sudo incus exec "${INCUS_NAME}" -- sh
102+
103+
- name: Upload artifacts to fileserver
104+
run: |
105+
set -x
106+
# curl will be used to talk to fileserver; should be installed by
107+
# default
108+
sudo apt -y install curl
109+
# github runs are only unique per repository and may also be re-run;
110+
# create an unique id with repository, run id, and run attempt
111+
id="${GITHUB_REPOSITORY}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
112+
# create a directory for the current run
113+
dir="${FILESERVER_DIR}/${id}"
114+
mkdir -vp "${dir}"
115+
# copy output files
116+
cp -v disk.img "${dir}"
117+
# instruct fileserver to publish this directory
118+
url="${FILESERVER_URL}/${id}/"
119+
curl -X POST -H 'Accept: text/event-stream' "${url}"
120+

0 commit comments

Comments
 (0)