name: Django CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.7", "3.8", "3.9", "3.10"]
        django-version: ["2.2", "3.2", "4.0"]
        exclude:
          - python-version: 3.9
            django-version: 2.2
          - python-version: 3.10
            django-version: 2.2
          - python-version: 3.7
            django-version: 4.0

    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install Dependencies
      run: |
        python -m pip install --upgrade pip
        pip install "Django==${{ matrix.django-version }}.*"
        pip install -r tests/requirements.txt
        python setup.py install
    - name: Test with pytest
      run: |
        python -m pytest tests
