name: CI

on:
  pull_request:
  push:
    branches:
      - main

jobs:
  prepare:
    runs-on: ubuntu-latest
    steps:
      - name: Create matrix
        id: create_matrix
        uses: fabiocaccamo/create-matrix-action@v5
        with:
          matrix: |
            python-version {3.9}, django-version {4.2}
            python-version {3.10}, django-version {4.2,5.0,5.1,5.2}
            python-version {3.11}, django-version {4.2,5.0,5.1,5.2}
            python-version {3.12}, django-version {4.2,5.0,5.1,5.2}
            python-version {3.13}, django-version {5.1,5.2}
    outputs:
      matrix: ${{ steps.create_matrix.outputs.matrix }}

  test:
    needs: prepare
    strategy:
      fail-fast: false
      matrix:
        include: ${{ fromJson(needs.prepare.outputs.matrix) }}
    name: "Python ${{ matrix.python-version }} + Django ${{ matrix.django-version }}"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      - run: pip install -e '.[dev]'
      - run: pip install "Django==${{ matrix.django-version }}.*"
      - run: make test

  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.13"
      - run: pip install -e '.[dev]'
      - run: make lint
