name: Build Test

on: [push, pull_request]

jobs:
  build-test:
    name: Build & Test
    runs-on: ubuntu-latest

    strategy:
      matrix:
        include:
          - distro: debian
            backend: apt
          - distro: fedora
            backend: dnf
          - distro: fedora
            backend: alpm
          - distro: fedora
            backend: zypp
          - distro: solus
            backend: eopkg
      fail-fast: false

    steps:
      - name: Get this version
        uses: actions/checkout@v6

      - name: Get version from last ABI break
        uses: actions/checkout@v6
        with:
          ref: ${{ env.LAST_ABI_BREAK }}
          path: original-version
        if: ${{ matrix.distro == 'debian' }}

      - name: Create Build Environment
        run: podman build -t packagekit-${{ matrix.distro }} -f tests/ci/Dockerfile-${{ matrix.distro }} .

      - name: Build & Test
        run: podman run -t -v `pwd`:/build packagekit-${{ matrix.distro }}
             ./tests/ci/build-and-test.sh -Dpackaging_backend=${{ matrix.backend }}
