name: Lint code and run unit tests
on:
  workflow_dispatch:
jobs:
  qa-checks:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: ['ubuntu-latest']
        python: ['3.9', '3.10', '3.11', '3.12', '3.13']
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python }}
      - name: Install core dependencies
        run: |
          pip install -r requirements.txt
      - name: Lint with flake8
        run: |
          pip install flake8
          # Stop the build if there are Python syntax errors or undefined names.
          flake8 . --select=E9,F63,F7,F82 --show-source
          # Exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide.
          flake8 . --exit-zero --max-complexity=10 --max-line-length=127
      - name: Run Python unit tests
        run: |
          python -m unittest discover -v tests/
        env:
          AUTOMX2_CONF: 'tests/unittest.conf'
          PYTHONPATH: src
          # Skip LDAP-based tests for GitHub CI
          RUN_LDAP_TESTS: 0
