name: Python

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  test:
    strategy:
      matrix:
        os: [ubuntu-22.04]
        compiler: [gcc-11]
        python-version: ['3.x']

    runs-on: ${{ matrix.os }}

    steps:
    - name: Environment setup
      uses: actions/checkout@v3
    - name: Python setup
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}
    - name: Python dependencies
      run: |
        pip install -r requirements.txt
        pip install -r requirements-test.txt
    - name: Python test
      env:
        CC: ${{ matrix.compiler }}
        FC: gfortran-11
      run: |
        make info
        make -j2
        export CEED_DIR=$PWD
        pip install .
        cd python/tests
        PYTHON=python3 make test TEST_OPTS="--ceed /cpu/self/ref/serial -vv"
        cd ../..
    - name: Python style
      env:
        CC: ${{ matrix.compiler }}
        FC: gfortran-11
      run: |
        make format-py && git diff --exit-code
    - name: Python version
      env:
        CC: ${{ matrix.compiler }}
        FC: gfortran-11
      run: |
        make vermin
