---
name: Continuous Integration

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  test:
    name: Code Coverage (Python ${{ matrix.python-version }} on ${{ matrix.os }})
    runs-on: ${{ matrix.os }}-latest
    strategy:
      matrix:
        os: [ubuntu]
        python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
    steps:
      - name: Checking out code from GitHub
        uses: actions/checkout@v5.0.0
      - name: Set up Python ${{ matrix.python }}
        uses: actions/setup-python@v6.0.0
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -e ".[test]"
          pip list
      - name: Pytest with coverage reporting
        run: pytest --cov=sharkiq --cov-report=xml
      - name: Upload coverage to Codecov
        if: matrix.python-version == 3.13 && matrix.os == 'ubuntu'
        uses: codecov/codecov-action@v5.5.1
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: ./coverage.xml
          flags: unittests
          name: codecov-umbrella
  docs:
    name: Generate and Upload Documentation
    runs-on: ubuntu-latest
    needs: [test]
    steps:
    - name: Checking out code from GitHub
      uses: actions/checkout@v5.0.0
    - name: Set up Python 3.13
      uses: actions/setup-python@v6.0.0
      with:
        python-version: 3.13
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip pdoc3
        pip install -e .
        pip list
    - name: Generate documentation
      run: pdoc --html sharkiq
    - name: Deploy Documentation
      if: github.event_name == 'push'
      uses: JamesIves/github-pages-deploy-action@v4.7.3
      with:
        branch: docs
        folder: html/sharkiq
