Skip to content

Add alpine unittests to ci #36

Add alpine unittests to ci

Add alpine unittests to ci #36

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: Reset the firewall
run: |
sudo iptables -I DOCKER-USER -j ACCEPT
- name: Make sure the latest version is installed
run: |
sudo snap refresh lxd --channel latest/stable
- name: Init lxd
run: |
sudo lxd init --auto
# we shouldn't have to do this, but the link is down and we need it up
sudo ip link set lxdbr0 up
- name: Create alpine container
# the current shell doesn't have lxd as one of the groups
# so switch groups to run lxd commands
run: sudo sg lxd -c 'lxc launch images:alpine/edge alpine'
- name: Check networking (for debugging)
run: |
sudo sg lxd -c 'lxc exec alpine -- ping -c 1 google.com || true'
sudo sg lxd -c 'lxc exec alpine -- ping -c 1 dl-cdn.alpinelinux.org || true'
sudo sg lxd -c 'lxc exec alpine -- nslookup www.google.com || true'
sudo sg lxd -c 'lxc exec alpine -- ping -c 1 dl-cdn.alpinelinux.org || true'
- name: Install dependencies
run: sudo sg lxd -c 'lxc exec alpine -- apk add py3-tox git'
- name: Mount source into container directory
run: sudo sg lxd -c '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: sudo sg lxd -c 'lxc exec alpine -- git clone cloud-init-ro/ cloud-init-rw'
- name: Run unittests
run: sudo sg lxd -c 'lxc exec alpine --cwd /root/cloud-init-rw -- sh -c "tox -e py3"'