Add GitHub Actions test

This commit is contained in:
Johan Gunnarsson 2021-08-05 20:01:46 +02:00
parent f8a73ebf8e
commit 5b0c3fcbfa
2 changed files with 167 additions and 0 deletions

78
.github/workflows/qemu.yml vendored Normal file
View File

@ -0,0 +1,78 @@
name: sd-card-images CI
on:
push:
branches: "*"
schedule:
- cron: "00 03 * * 0"
env:
MAKEFLAGS: -j2
jobs:
bullseye-x86:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
timeout-minutes: 5
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get --assume-yes \
--no-install-recommends \
install bc \
bison \
bzip2 \
ca-certificates \
debian-archive-keyring \
debootstrap \
device-tree-compiler \
dosfstools \
e2fsprogs \
flex \
gcc \
gcc-arm-none-eabi \
gcc-i686-linux-gnu \
git \
libssl-dev \
make \
mtools \
parted \
pwgen \
python2-dev \
python3-dev \
python3-pkg-resources \
qemu-system-x86 \
ssh \
sshpass \
swig
- name: Checkout
uses: actions/checkout@v2
- name: Build qemu_x86_virt
timeout-minutes: 5
run: |
env PATH=$GITHUB_WORKSPACE/scripts:$PATH \
ARTIFACTS_DIR=$RUNNER_TEMP \
build-boot qemu_x86_virt \
qemu-x86 \
qemu-x86_defconfig \
i686-linux-gnu
- name: Build bullseye i386
timeout-minutes: 5
run: |
sudo env PATH=$GITHUB_WORKSPACE/scripts:$PATH \
ARTIFACTS_DIR=$RUNNER_TEMP \
build-debian debian \
i386 \
bullseye
- name: Test qemu_x86_virt + bullseye i386
timeout-minutes: 5
run: |
./test/qemu.sh $RUNNER_TEMP/boot-qemu_x86_virt.bin.gz \
$RUNNER_TEMP/debian-bullseye-i386-*.bin.gz

89
test/qemu.sh Executable file
View File

@ -0,0 +1,89 @@
#!/bin/bash
# Boot up and shutdown
BOOT="${1:-boot-qemu_aarch64_virt.bin.gz}"
DEBIAN="${2:-debian-bullseye-arm64-XXXXXX.bin.gz}"
set -ex
# Parse out stuff
IFS="-." read -a PARTS1 <<< `basename "${BOOT}"`
BOARD="${PARTS1[1]}"
echo "Using board ${BOARD}"
# Parse out stuff
IFS="-." read -a PARTS2 <<< `basename "${DEBIAN}"`
ARCH="${PARTS2[2]}"
SSHPASS="${PARTS2[3]}"
echo "Using password ${SSHPASS}"
# Build image
zcat "${BOOT}" "${DEBIAN}" > image.bin
# Extract U-Boot (u-boot.rom in x86 case)
dd if=image.bin of=bios.bin count=2048 skip=16
case "${BOARD}" in
qemu*)
;;
*)
echo "Unsupported \$BOARD: ${BOARD}"
exit 1
;;
esac
case "${ARCH}" in
amd64)
QEMU_ARCH="x86_64"
QEMU_MACHINE="pc"
QEMU_CPU="qemu64"
;;
i386)
QEMU_ARCH="i386"
QEMU_MACHINE="pc"
QEMU_CPU="qemu32"
;;
arm64)
QEMU_ARCH="aarch64"
QEMU_MACHINE="virt"
QEMU_CPU="cortex-a53"
;;
armhf)
QEMU_ARCH="arm"
QEMU_MACHINE="virt"
QEMU_CPU="cortex-a9"
;;
*)
echo "Unknown \$ARCH: ${ARCH}"
exit 1
;;
esac
# Launch QEMU with U-Boot and image
qemu-system-${QEMU_ARCH} -machine ${QEMU_MACHINE} \
-cpu ${QEMU_CPU} \
-m 512 \
-bios bios.bin \
-serial stdio \
-no-reboot \
-display none \
-drive file=image.bin,format=raw,media=disk \
-nic user,hostfwd=tcp:127.0.0.1:5555-:22 &
sleep 15
# Pass password to sshpass
export SSHPASS
# SSH into QEMU and shut it down
until sshpass -e ssh -o "ConnectTimeout=5" \
-o "StrictHostKeyChecking=no" \
-o "UserKnownHostsFile=/dev/null" \
-p 5555 \
-q \
root@localhost "sleep 5 && poweroff"; do
sleep 1
done
# Wait for QEMU to exit
wait