name: CI Tests

on:
  push:
    branches:
      - 'main'
  pull_request:

jobs:
  tests:
    name: Tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      # Set up all supported Python versions for tox.
      - uses: actions/setup-python@v3
        with:
          python-version: '3.7'
      - uses: actions/setup-python@v3
        with:
          python-version: '3.8'
      - uses: actions/setup-python@v3
        with:
          python-version: '3.9'
      - uses: actions/setup-python@v3
        with:
          python-version: '3.10'

      - name: Update pip
        run: python -mpip install --upgrade pip
      - name: Install tox
        run: python -mpip install tox
      - name: Run tests
        run: tox

  lint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v3
        with:
          python-version: '3.9'
      - name: Update pip
        run: python -mpip install --upgrade pip
      - name: Install tox
        run: python -mpip install tox
      - name: Style and lint
        run: tox -e lint

  docs:
    name: Docs
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v3
        with:
          python-version: '3.9'
      - name: Update pip
        run: python -mpip install --upgrade pip
      - name: Install tox
        run: python -mpip install tox
      - name: Build documentation
        run: tox -e docs
