---
name: CI

on: 
  push:
  pull_request:
  schedule:
    # every Monday
    - cron: '30 4 * * 1'
  workflow_dispatch:

permissions:
  contents: read

jobs:
  distros:
    name: "Ubuntu with Python ${{ matrix.python-version }}"
    runs-on: "${{ matrix.image }}"
    strategy:
      fail-fast: false
      matrix:
        python-version:
          - "3.8"
          - "3.9"
          - "3.10"
          - "3.11"
          - "3.12"
          - "3.13"
          - "pypy3.9"
          - "pypy3.10"
        image: 
          - "ubuntu-22.04"
    steps:
      - name: Checkout
        uses: "actions/checkout@v4"
      - name: Install apt dependencies
        run: |
          set -ex
          sudo apt update
          sudo apt install -y ldap-utils slapd enchant-2 libldap2-dev libsasl2-dev apparmor-utils
      - name: Disable AppArmor
        run: sudo aa-disable /usr/sbin/slapd
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          allow-prereleases: true
      - name: "Install Python dependencies"
        run: |
          set -xe
          python -V
          python -m pip install --upgrade pip setuptools
          python -m pip install --upgrade tox tox-gh-actions
      - name: "Test tox with Python ${{ matrix.python-version }}"
        run: "python -m tox"
