Skip to content

Commit

Permalink
test: Add alpine to ci
Browse files Browse the repository at this point in the history
Cloud-init has Alpine Linux support, yet does not regularly test it.

Alpine is an attractive addition to the test matrix since it is easily
available to run in lxc, and it has several alternative components to test
against:

- busybox: non-GNU posix-compliant tools
- musl: libc alternative to glibc
- openrc: init system alternative to systemd
  • Loading branch information
holmanb committed Apr 1, 2024
1 parent 83b1ba5 commit c44fc43
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/alpine-unittests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

name: Alpine Unittests

on:
pull_request:
branches-ignore:
- 'ubuntu/**'
push:
branches:
- main

concurrency:
group: 'ci-${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: true

defaults:
run:
shell: sh -ex {0}

jobs:
build:
runs-on: ubuntu-latest
steps:

- name: "Checkout"
uses: actions/checkout@v4
with:
# Fetch all tags for tools/read-version
fetch-depth: 0

- name: Collect debugging info
run: |
set
- name: Install incus
run: |
curl https://pkgs.zabbly.com/get/incus-stable | sudo sh -x
- name: Reset the firewall
run: |
sudo iptables -I DOCKER-USER -j ACCEPT
- name: Init incus
run: |
sudo incus admin init --auto
sudo ip link set incusbr0 up
- name: Create alpine container
run: sudo sg incus-admin -c 'incus launch images:alpine/edge alpine'

- name: Check networking (for debugging)
run: |
sudo sg incus-admin -c 'incus exec alpine -- ping -c 1 google.com || true'
sudo sg incus-admin -c 'incus exec alpine -- ping -c 1 dl-cdn.alpinelinux.org || true'
sudo sg incus-admin -c 'incus exec alpine -- nslookup www.google.com || true'
sudo sg incus-admin -c 'incus exec alpine -- ping -c 1 dl-cdn.alpinelinux.org || true'
- name: Install dependencies
run: sudo sg incus-admin -c 'incus exec alpine -- apk add py3-tox git'

- name: Mount source into container directory
run: sudo sg incus-admin -c 'incus config device add alpine gitdir disk source=$(pwd) path=/root/cloud-init-ro'

- name: Create a r/w directory to run tests in
run: |
sudo sg incus-admin -c 'incus exec alpine -- git clone cloud-init-ro/ cloud-init-rw'
- name: Did the code work?
run: |
sudo sg incus-admin -c 'incus exec alpine -- ls -la /root/'
sudo sg incus-admin -c 'incus exec alpine -- ls -la /root/cloud-init-ro'
sudo sg incus-admin -c 'incus exec alpine -- ls -la /root/cloud-init-rw'
sudo sg incus-admin -c 'incus exec alpine -- sh -c "cd /root/cloud-init-rw && tox -e py3"'
# - name: Git the code
# run: |
# sudo sg incus-admin -c "incus exec alpine -- git clone https://github.com/${GITHUB_REPOSITORY}.git"
# sudo sg incus-admin -c 'incus exec alpine --cwd /root/cloud-init/ -- git fetch origin +refs/pull/*:refs/remotes/origin/pr/*'
# sudo sg incus-admin -c "incus exec alpine --cwd /root/cloud-init/ -- git checkout origin/pr/${GITHUB_REF_NAME}"

0 comments on commit c44fc43

Please sign in to comment.