name: Integration Test

on:
  workflow_call:

jobs:
  snapd_integration_test:
    strategy:
      matrix:
        os: ["ubuntu-22.04", "ubuntu-20.04"]
    runs-on: ${{ matrix.os }}
    steps:
        # Access to the snapd socket requires root privileges, so these
        # tests need to be run as root.
      - uses: actions/checkout@v4
      - name: install python dependencies
        run: |
          sudo apt update
          sudo apt install -y python3-pip
          sudo pip install poetry==1.7
          sudo poetry install
      - name: snapd setup
        run: |
          sudo apt install -y snapd
          sudo systemctl start snapd.service
      - name: build test_snap
        run: |
          sudo snap install snapcraft --classic
          cd tests/integration/test_snap
          snapcraft --destructive-mode
          snap download hello-world --basename=hello-world
          cd $GITHUB_WORKSPACE
      - name: integration test
        run: sudo poetry run pytest tests/integration
