name: build

on:
  push:
    branches: [ develop ]
  pull_request:
    branches: [ develop ]

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
        docutils-version: ['']
        pip-pybtex: ['pybtex']
        include:
          - python-version: '3.11'
            docutils-version: ''
            pip-pybtex: 'git+https://bitbucket.org/pybtex-devs/pybtex.git'
          - python-version: '3.7'
            docutils-version: '==0.14'
            pip-pybtex: 'pybtex'
          - python-version: '3.10'
            docutils-version: '==0.18'
            pip-pybtex: 'pybtex'
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        python -m pip install docutils${{ matrix.docutils-version }}
        python -m pip install flake8 check-manifest pytest codecov coverage mypy types-setuptools types-docutils
        pip install ${{ matrix.pip-pybtex }}
        pip install .
    - name: Check manifest
      run: |
        check-manifest
    - name: Lint with flake8 and mypy
      run: |
        flake8 . --count --select=E9,F63,F7,F82 --show-source
        flake8 . --count --exit-zero --max-complexity=10
        mypy
    - name: Test with pytest
      run: |
        coverage run -m pytest
        codecov
