name: Tests

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go-version: [1.21.x, 1.22.x]

    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Set up Go
      uses: actions/setup-go@v4
      with:
        go-version: ${{ matrix.go-version }}
        cache: true

    - name: Install test dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y podman qemu-utils ostree

    - name: Run Go unit tests
      working-directory: ./bib
      run: go test -v ./...

    - name: Build binary
      working-directory: ./
      run: ./build.sh

    - name: Run integration tests
      run: |
        # Install Python test dependencies
        pip install pytest
        # Run integration tests
        pytest -v test/
