Skip to content

Commit

Permalink
Add experimental Alpine tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
ecdye committed Jun 24, 2024
1 parent 65c0116 commit 18f2292
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 8 deletions.
39 changes: 38 additions & 1 deletion .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
- '.github/workflows/test-action.yml'

jobs:
test:
raspios-test:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
Expand Down Expand Up @@ -53,3 +53,40 @@ jobs:
with:
name: logs.tar
path: logs.tar
alpine-test:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup environment
id: setup
run: |
sudo -E bash -c set
sudo add-apt-repository ppa:canonical-server/server-backports
sudo apt-get update
sudo apt-get install --yes gnupg xz-utils expect systemd-container qemu-user-static qemu-utils qemu-system-arm libfdt-dev
echo "imagegz=alpine-rpi-3.20.1-armhf.img.gz" >> $GITHUB_OUTPUT
echo "image=alpine-rpi-3.20.1-armhf.img" >> $GITHUB_OUTPUT
- name: Cache Raspberry Pi OS 32bit image
uses: actions/cache@v4
with:
path: ${{ steps.setup.outputs.image }}
key: ${{ steps.setup.outputs.image }}
- name: Build image
run: sudo -E ./tests/image.bash "setup" "${{ steps.setup.outputs.imagegz }}" "${{ steps.setup.outputs.image }}"
shell: bash
- name: Run tests
run: |
cp "${{ steps.setup.outputs.image }}" raspios.img
sudo expect ./tests/run.exp
shell: bash
- name: Copy logs
if: always()
run: sudo ./tests/image.bash "copy-logs" "raspios.img"
- name: Upload logs
if: always()
uses: actions/upload-artifact@v4
with:
name: logs.tar
path: logs.tar
22 changes: 15 additions & 7 deletions tests/image.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,25 @@ imageFile() {

if [[ $1 == "setup" ]]; then
if ! [[ -f $3 ]]; then
curl -s -L "https://downloads.raspberrypi.org/raspios_lite_armhf_latest" -o "$2"
curl -s "$(curl "https://downloads.raspberrypi.org/raspios_lite_armhf_latest" -s -L -I -o /dev/null -w '%{url_effective}')".sig -o "${2}.sig"
gpg -q --keyserver keyserver.ubuntu.com --recv-key 0x8738CD6B956F460C
gpg -q --trust-model always --verify "${2}.sig" "$2"
xz "$2" -d
if [[ "$3" == "alpine-rpi-3.20.1-armhf.img" ]]; then
curl -s -L "https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/armhf/alpine-rpi-3.20.1-armhf.img.gz" -o "$2"
curl -s https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf/alpine-rpi-3.20.1-armhf.img.gz.asc -o "${2}.asc"
gpg -q --keyserver keyserver.ubuntu.com --recv-key 0x0482D84022F52DF1C4E7CD43293ACD0907D9495A
gpg -q --trust-model always --verify "${2}.asc" "$2"
gzip "$2" -d
else
curl -s -L "https://downloads.raspberrypi.org/raspios_lite_armhf_latest" -o "$2"
curl -s "$(curl "https://downloads.raspberrypi.org/raspios_lite_armhf_latest" -s -L -I -o /dev/null -w '%{url_effective}')".sig -o "${2}.sig"
gpg -q --keyserver keyserver.ubuntu.com --recv-key 0x8738CD6B956F460C
gpg -q --trust-model always --verify "${2}.sig" "$2"
xz "$2" -d
fi
fi
qemu-img resize -f raw "$3" 4G
echo ", +" | sfdisk -N 2 "$3"
imageFile "mount" "$3"
rsync -avr --exclude="*.img" --exclude="*.sig" --exclude="tests/fs" --exclude="tests/dtb" --exclude="tests/kernel" ./ tests/fs/opt/zram
systemd-nspawn --directory="tests/fs" /opt/zram/tests/install-packages.bash
rsync -avr --exclude="*.img" --exclude="*.sig" --exclude="*.asc" --exclude="tests/fs" --exclude="tests/dtb" --exclude="tests/kernel" ./ tests/fs/opt/zram
[[ "$3" == "alpine-rpi-3.20.1-armhf.img" ]] || systemd-nspawn --directory="tests/fs" /opt/zram/tests/install-packages.bash
echo "set enable-bracketed-paste off" >> tests/fs/etc/inputrc # Prevents weird character output
cp tests/fs/boot/kernel* tests/kernel
# Compile a customized DTB
Expand Down

0 comments on commit 18f2292

Please sign in to comment.