271 lines (225 loc) · 9.75 KB
/
build-test-image-docker.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
name: Build test images with Docker
on:
workflow_dispatch:
workflow_call:
jobs:
Distro:
strategy:
fail-fast: false
matrix:
board: [uefi-x86]
target: ["debian:bullseye:10","debian:sid:12","ubuntu:jammy:12"]
outputs:
desktop: ${{steps.list_dirs.outputs.desktop}}
#runs-on: ubuntu-latest
runs-on: small
name: "Build"
steps:
- name: Read values
run: |
DISTRO=$(echo ${{ matrix.target }} | cut -d":" -f1)
RELEASE=$(echo ${{ matrix.target }} | cut -d":" -f2)
COMPILER=$(echo ${{ matrix.target }} | cut -d":" -f3)
DOCKER_DISTRO=$DISTRO
DOCKER_RELEASE=$RELEASE
DOCKER_COMPILER=$COMPILER
BOARD=${{ matrix.board }}
# Bullseye can't build even itself
if [[ "$RELEASE" == "bullseye" ]]; then
DOCKER_DISTRO="ubuntu"
DOCKER_RELEASE="jammy"
DOCKER_COMPILER="12"
fi
# export to environment
echo "RELEASE=$RELEASE" >> $GITHUB_ENV
echo "BOARD=$BOARD" >> $GITHUB_ENV
echo "COMPILER=$COMPILER" >> $GITHUB_ENV
echo "DOCKER_DISTRO=$DOCKER_DISTRO" >> $GITHUB_ENV
echo "DOCKER_RELEASE=$DOCKER_RELEASE" >> $GITHUB_ENV
echo "DOCKER_COMPILER=$DOCKER_COMPILER" >> $GITHUB_ENV
- name: Checkout Armbian build script
uses: actions/checkout@v3
with:
repository: armbian/build
path: build
fetch-depth: '100'
clean: false
- name: Checkout support scripts
uses: actions/checkout@v2
with:
fetch-depth: 1
repository: armbian/scripts
path: scripts
clean: true
- name: Sync
run: |
mkdir -p build/userpatches
sudo cp scripts/configs/lib.config build/userpatches/
sudo cp scripts/configs/config-default.conf build/userpatches/
- name: Pull Docker image
run: |
#sudo docker pull ghcr.io/armbian/build:$(cat build/VERSION | cut -d"." -f1-2)"-${{ env.DOCKER_RELEASE }}-$(dpkg --print-architecture)"
sudo docker pull ghcr.io/armbian/build:latest"-${{ env.DOCKER_RELEASE }}-$(dpkg --print-architecture)"
- name: Build test image
run: |
cd build
sudo rm -rf output/images/*
# framework init
./compile.sh \
JUST_INIT="yes" \
OFFLINE_WORK="yes" \
BRANCH=current \
RELEASE=focal \
BUILD_MINIMAL=yes \
BUILD_DESKTOP=no \
KERNEL_ONLY=no \
KERNEL_CONFIGURE=no \
BOARD="zeropi" \
NO_HOST_RELEASE_CHECK="yes"
# change template
sudo sed -i "s/^#DOCKER_FLAGS+=(--privileged)/DOCKER_FLAGS+=(--privileged)/" userpatches/config-docker.conf
sudo sed -i "s/^ARM_GCC_COMPILER=.*/ARM_GCC_COMPILER=g++-${{ env.DOCKER_COMPILER }}-arm-linux-gnueabihf/" userpatches/config-docker.conf
sudo sed -i "s/^BASE_IMAGE=.*/BASE_IMAGE=${{ env.DOCKER_DISTRO }}:${{ env.DOCKER_RELEASE }}/" userpatches/config-docker.conf
sudo sed -i "s/^VERSION=.*/VERSION=\$(cat \$SRC\/VERSION | cut -d\".\" -f1-2)\"-\$(echo \${BASE_IMAGE} \| cut -d\":\" -f2)-\$(dpkg --print-architecture)\"/" userpatches/config-docker.conf
sudo sed -i 's/armbian:/ghcr.io\/armbian\/build:/g' userpatches/config-docker.conf
sudo sed -i "s/ -it/ -i/" userpatches/config-docker.conf
sed -i "s/COMPRESS_OUTPUTIMAGE=.*/COMPRESS_OUTPUTIMAGE=\"no\"/" userpatches/lib.config
export TERM=dumb
touch .ignore_changes
./compile.sh docker \
JUST_INIT="no" \
OFFLINE_WORK="no" \
BETA=yes \
NO_APT_CACHER="yes" \
EXPERT=yes \
BOARD=${{ matrix.board }} \
BRANCH=edge \
RELEASE=${{ env.RELEASE }} \
BUILD_MINIMAL=no \
BUILD_DESKTOP=no \
KERNEL_ONLY=no \
KERNEL_CONFIGURE=prebuilt \
COMPRESS_OUTPUTIMAGE=no \
IGNORE_UPDATES=yes \
REPOSITORY_INSTALL="u-boot,kernel" \
DESKTOP_ENVIRONMENT_CONFIG_NAME="" \
DESKTOP_ENVIRONMENT="" \
SKIP_EXTERNAL_TOOLCHAINS=yes \
- name: Upload artefacts
uses: actions/upload-artifact@v3
with:
name: "${{ matrix.board }}-${{ env.RELEASE }}"
path: build/output/images/*
if-no-files-found: error
retention-days: 7
- name: Read
id: list_dirs
run: |
RELEASE=$(echo ${{ matrix.target }} | cut -d":" -f2)
echo ${{ matrix.target }}
echo ${RELEASE}
echo "RELEASE=$RELEASE" >> $GITHUB_ENV
MATRIX=$(
set +e
releases=($(find build/config/distributions -mindepth 1 -maxdepth 1 -type d | sed 's/.*\///' ))
#
releases=("bullseye" "sid" "jammy")
for i in ${releases[@]}
do
environments=($([[ -d build/config/desktop/${i}/environments ]] && ls -1 build/config/desktop/${i}/environments))
#
#environments=(xfce)
for j in ${environments[@]}
do
echo "$i:$j"
done
done)
echo ::set-output name=desktop::$(for x in $(echo "${MATRIX}"); do echo $x; done|jq -cnR '[inputs | select(length>0)]' | jq)
Desktop:
needs: [ Distro ]
name: "Install"
runs-on: [qemu,igor]
timeout-minutes: 480
strategy:
max-parallel: 16
fail-fast: false
matrix:
node: ${{fromJson(needs.Distro.outputs.desktop)}}
steps:
- name: Prepare
run: |
sudo apt-get -y install qemu-kvm libvirt-daemon-system libvirt-clients virtinst cpu-checker libguestfs-tools libosinfo-bin dnsmasq gir1.2-spiceclientgtk-3.0 virt-viewer sshpass nmap
- name: Read
run: |
RELEASE=$(echo ${{ matrix.node }} | cut -d":" -f1)
DESKTOP=$(echo ${{ matrix.node }} | cut -d":" -f2)
echo "RELEASE=$RELEASE" >> $GITHUB_ENV
echo "DESKTOP=$DESKTOP" >> $GITHUB_ENV
# remove old
rm -rf "uefi-x86-${RELEASE}"
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: "uefi-x86-${{ env.RELEASE }}"
path: "uefi-x86-${{ env.RELEASE }}"
- name: Remove previous if any
run: |
sudo virsh destroy Armbian || true
sudo virsh undefine Armbian || true
- name: Convert to QEMU and resize
run: |
IMAGE=$(ls -1 "uefi-x86-${{ env.RELEASE }}"/*.img)
sudo qemu-img convert -f raw -O qcow2 ${IMAGE} /var/lib/libvirt/images/image.qcow2
sudo qemu-img resize /var/lib/libvirt/images/image.qcow2 +10G
- name: Boot it up and wait 1 minute
run: |
sudo virt-install --name Armbian --memory 2048 --vcpus 4 --disk \
/var/lib/libvirt/images/image.qcow2,bus=sata --import --os-variant ubuntu22.04 --network bridge=br0 --noautoconsole
sleep 1m
- name: Find and login
run: |
export TERM=vt100
# get ip
MAC=$(sudo virsh domiflist Armbian | tail -2 | head -1 | awk '{print $NF}')
USER_HOST=$(sudo nmap -sP 10.0.40.0/24 | grep -i "$MAC" -B 2 | head -1 | awk '{print $NF}')
# login credentials
USER_ROOT=root
PASS_ROOT=testpassword
USER_NORMAL=guest
PASS_NORMAL=testpassword
expect -c "
spawn sshpass -p 1234 ssh -o "StrictHostKeyChecking=accept-new" ${USER_ROOT}@${USER_HOST}
set timeout 120
expect \"Create root password: \"
send \"${PASS_ROOT}\r\"
expect \"Repeat root password: \"
send \"${PASS_ROOT}\r\"
expect \"zsh\"
send \"2\r\"
expect \"*to abort\"
send \"${USER_NORMAL}\r\"
expect \"Create*password:\"
send \"${PASS_NORMAL}\r\"
expect \"Repeat*password:\"
send \"${PASS_NORMAL}\r\"
expect \"Please provide your real name: \"
send \"${NAME_NORMAL}\r\"
expect \"*language based on your location*\"
send \"y\r\"
expect \"*#\"
send \"exit\r\"
"
sshpass -p ${PASS_ROOT} ssh -o "StrictHostKeyChecking=accept-new" ${USER_ROOT}@${USER_HOST} "apt-get -y update"
sshpass -p ${PASS_ROOT} ssh -o "StrictHostKeyChecking=accept-new" ${USER_ROOT}@${USER_HOST} "apt-get -y install maim"
sshpass -p ${PASS_ROOT} ssh -o "StrictHostKeyChecking=accept-new" ${USER_ROOT}@${USER_HOST} "apt-get -y upgrade"
sshpass -p ${PASS_ROOT} ssh -o "StrictHostKeyChecking=accept-new" ${USER_ROOT}@${USER_HOST} "git clone https://github.com/armbian/configng -b desktop"
sshpass -p ${PASS_ROOT} ssh -o "StrictHostKeyChecking=accept-new" ${USER_ROOT}@${USER_HOST} "cd configng/test; ./desktop_test.sh"
sleep 10
sshpass -p ${PASS_NORMAL} ssh -o "StrictHostKeyChecking=accept-new" ${USER_NORMAL}@${USER_HOST} "export DISPLAY=:0;maim" > "${{ env.RELEASE }}-${{ env.DESKTOP }}.png"
- name: Upload artefacts
uses: actions/upload-artifact@v3
with:
name: "${{ env.RELEASE }}-${{ env.DESKTOP }}.png"
path: ${{ env.RELEASE }}-${{ env.DESKTOP }}.png
if-no-files-found: error
retention-days: 7