name: CI
on:
  push:
  pull_request:
  schedule:
    - cron: 0 4 * * MON,FRI

jobs:
  fedora:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    container: registry.fedoraproject.org/fedora:latest
    steps:
      - name: Clone repository
        uses: actions/checkout@v3

      - name: Install runtime and test dependencies
        run: dnf install -y openssh-clients python3-asyncssh python3-pytest-cov python3-pytest-asyncio

      - name: Run unit tests
        run: python3 -m pytest --color=yes --cov

  c8s:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    container: quay.io/centos/centos:stream8
    steps:
      - name: Clone repository
        uses: actions/checkout@v3

      - name: Install distro runtime and test dependencies
        run: |
          dnf install -y openssh-clients python3-pip python3-cryptography

      # C8S does have python3-pytest, but it's too old for us
      - name: Install pip test dependencies
        # 2.14.0 and up need a too new python3-cryptography which we can't build in C8S
        run: pip3 install pytest pytest-asyncio asyncssh==2.13.2

      - name: Run unit tests
        run: PYTHONPATH=src python3 -m pytest --color=yes

  debian:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    container: docker.io/debian:unstable
    steps:
      - name: Clone repository
        uses: actions/checkout@v3

      - name: Install runtime and test dependencies
        run: |
          apt-get update
          apt-get install -y python3-pytest-asyncio python3-pip openssh-client
          pip3 install --break-system-packages asyncssh==2.13.2

      - name: Run unit tests
        # FIXME: test_cancel_askpass hangs forever
        run: python3 -m pytest -k 'not test_cancel_askpass'
