From 641b107a2892dcbcc89bdc7bdc015fed7f59b257 Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Wed, 24 Apr 2024 19:25:48 -0600 Subject: [PATCH] Add alpine unittests to ci (#5121) test: Add alpine to ci 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 --- .github/workflows/alpine-unittests.yml | 59 ++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/alpine-unittests.yml diff --git a/.github/workflows/alpine-unittests.yml b/.github/workflows/alpine-unittests.yml new file mode 100644 index 00000000000..0bc50c93e7a --- /dev/null +++ b/.github/workflows/alpine-unittests.yml @@ -0,0 +1,59 @@ + +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: Setup LXD + uses: canonical/setup-lxd@v0.1.1 + with: + channel: latest/candidate + + - name: Create alpine container + # the current shell doesn't have lxd as one of the groups + # so switch groups to run lxd commands + run: lxc launch images:alpine/edge alpine + + - name: Check networking (for debugging) + run: | + lxc exec alpine -- ping -c 1 google.com || true + lxc exec alpine -- ping -c 1 dl-cdn.alpinelinux.org || true + lxc exec alpine -- nslookup www.google.com || true + lxc exec alpine -- ping -c 1 dl-cdn.alpinelinux.org || true + + - name: Install dependencies + run: lxc exec alpine -- apk add py3-tox git + + - name: Mount source into container directory + run: lxc config device add alpine gitdir disk source=$(pwd) path=/root/cloud-init-ro + + - name: Create a r/w directory to run tests in + # without this, tox fails during package install + run: lxc exec alpine -- git clone cloud-init-ro/ cloud-init-rw + + - name: Run unittests + run: lxc exec alpine --cwd /root/cloud-init-rw -- sh -c "tox -e py3"