Skip to content

Add alpine unittests to ci #23

Add alpine unittests to ci

Add alpine unittests to ci #23

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 code
uses: actions/checkout@v4
- 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: |
env
set
sudo sg incus-admin -c 'incus launch images:alpine/edge alpine'
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: 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 -- cd cloud-init && git fetch origin +refs/pull/*:refs/remotes/origin/pr/*'
sudo sg incus-admin -c "incus exec alpine -- cd cloud-init && git checkout origin/pr/${GITHUB_REF_NAME}"
- name: Did the code work?
run: |
sudo sg incus-admin -c 'incus exec alpine -- tox -e py3 --root ~/cloud-init'