Skip to content

Add E2E testing infrastructure using mkosi #7

Add E2E testing infrastructure using mkosi

Add E2E testing infrastructure using mkosi #7

Workflow file for this run

name: E2E Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
e2e-tests:
name: E2E Tests with mkosi (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14', '3.14t']
env:
PYTHON_VERSION: ${{ matrix.python-version }}
UNIT_NAME: pystemd-e2e-py${{ matrix.python-version }}.service
MACHINE_NAME: pystemd-test-py${{ matrix.python-version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: setup-mkosi
uses: systemd/mkosi@v26
- name: Install systemd-container
run: |
sudo apt-get update
sudo apt-get install -y systemd-container
- name: Generate mkosi keys
run: |
sudo mkosi genkey
- name: Build mkosi test image
run: |
sudo mkosi build
- name: Boot container
run: |
sudo systemd-run --unit "$UNIT_NAME" --same-dir mkosi boot --machine="$MACHINE_NAME"
# Wait for container to be ready
for i in {1..30}; do
if sudo systemd-run --machine="$MACHINE_NAME" --wait --pipe /bin/true 2>/dev/null; then
echo "Container is ready"
break
fi
echo "Waiting for container to start... ($i/30)"
sleep 1
done
sudo journalctl -u "$UNIT_NAME"
sleep 1
sudo systemd-run --machine="$MACHINE_NAME" --wait --pipe /bin/echo 'hello world' || exit 1
- name: Run E2E tests
run: |
sudo systemd-run --machine="$MACHINE_NAME" --wait --pipe /opt/pystemd/venv/bin/pytest /opt/pystemd/e2e/ -v
- name: Stop container
if: always()
run: |
sudo machinectl terminate "$MACHINE_NAME" || true