name: Python package

on:
  workflow_dispatch:
  pull_request:

jobs:
  lint:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: 3.x
      - name: Install dependencies
        run: python -m pip install pre-commit
      - name: Run pre-commit
        run: pre-commit run --all-files

  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.9"]
        os: [ubuntu-latest, macOS-latest, windows-latest]

    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 wheel
          pip install --upgrade --upgrade-strategy only-if-needed pytest
          pip install .
      - name: Test with pytest
        run: |
          pytest
