---
version: 2.1

executors:
  python:
    docker:
      - image: cimg/python:3.9

jobs:
  flake8_lint:
    executor: python
    steps:
      - checkout
      - run: pip install tox
      - run: tox -e flake8
  isort_lint:
    executor: python
    steps:
      - checkout
      - run: pip install tox
      - run: tox -e isort
  mypy_lint:
    executor: python
    steps:
      - checkout
      - run: pip install tox
      - run: tox -e mypy
  test:
    parameters:
      python:
        type: string
    docker:
      - image: cimg/python:<< parameters.python >>
    environment:
      TOXENV: "py<< parameters.python >>"
    steps:
      - checkout
      - run: echo 'export PATH=$HOME/.local/bin:$PATH' >> $BASH_ENV
      - run: pip install --user tox "virtualenv<20.22.0"
      - run: tox
  test_nooptionals:
    parameters:
      python:
        type: string
    docker:
      - image: cimg/python:<< parameters.python >>
    environment:
      TOXENV: "py<< parameters.python >>-nooptionals"
    steps:
      - checkout
      - run: pip install tox
      - run: tox
  test_pypy:
    parameters:
      python:
        type: string
    docker:
      - image: pypy:<< parameters.python >>
    environment:
      TOXENV: "pypy<< parameters.python >>"
    steps:
      - checkout
      - run: pip install tox
      - run: tox
   

workflows:
  version: 2
  client_python:
    jobs:
      - flake8_lint
      - isort_lint
      - mypy_lint
      - test:
          matrix:
            parameters:
               python:
                 - "3.8.18"
                 - "3.9.18"
                 - "3.10"
                 - "3.11"
                 - "3.12"
      - test_nooptionals:
          matrix:
            parameters:
               python:
                 - "3.9"
      - test_pypy:
          matrix:
            parameters:
               python:
                 - "3.8"
