version: 2.1

orbs:
  python: circleci/python@0.2.1
  codecov: codecov/codecov@3.2.5

jobs:
  hatch:
    parameters:
      hatch_env:
        description: "Name of Hatch environment to run"
        default: "py3.11-dj4.2"
        type: string
      python_version:
        description: "Python version string"
        default: "3.11"
        type: string
    description: "Reusable job for invoking hatch"
    docker:
      - image: cimg/python:<<parameters.python_version>>
    steps:
      - checkout
      - run: pip install coverage[toml] hatch libsass
      - run: python -m hatch --env test.<<parameters.hatch_env>> run all
      - codecov/upload

  lint:
    description: "Simple job for linting the pushed code"
    docker:
      - image: cimg/python:3.11
    steps:
      - checkout
      - run: pip install hatch libsass && python -m hatch --env test.py3.11-dj4.2 run lint


workflows:
  test:
    jobs:
      - hatch:
          name: "Python 3.9, Django 4.0"
          hatch_env: "py3.9-dj4.0"
          python_version: "3.9"
      - hatch:
          name: "Python 3.9, Django 4.1"
          hatch_env: "py3.9-dj4.1"
          python_version: "3.9"
      - hatch:
          name: "Python 3.9, Django 4.2"
          hatch_env: "py3.9-dj4.2"
          python_version: "3.9"
      - hatch:
          name: "Python 3.10, Django 4.0"
          hatch_env: "py3.10-dj4.0"
          python_version: "3.10"
      - hatch:
          name: "Python 3.10, Django 4.1"
          hatch_env: "py3.10-dj4.1"
          python_version: "3.10"
      - hatch:
          name: "Python 3.10, Django 4.2"
          hatch_env: "py3.10-dj4.2"
          python_version: "3.10"
      - hatch:
          name: "Python 3.10, Django 5.0"
          hatch_env: "py3.10-dj5.0"
          python_version: "3.10"
      - hatch:
          name: "Python 3.10, Django 5.1"
          hatch_env: "py3.10-dj5.1"
          python_version: "3.10"
      - hatch:
          name: "Python 3.10, Django 5.2"
          hatch_env: "py3.10-dj5.2"
          python_version: "3.10"
      - hatch:
          name: "Python 3.11, Django 4.1"
          hatch_env: "py3.11-dj4.1"
          python_version: "3.11"
      - hatch:
          name: "Python 3.11, Django 4.2"
          hatch_env: "py3.11-dj4.2"
          python_version: "3.11"
      - hatch:
          name: "Python 3.11, Django 5.0"
          hatch_env: "py3.11-dj5.0"
          python_version: "3.11"
      - hatch:
          name: "Python 3.11, Django 5.1"
          hatch_env: "py3.11-dj5.1"
          python_version: "3.11"
      - hatch:
          name: "Python 3.11, Django 5.2"
          hatch_env: "py3.11-dj5.2"
          python_version: "3.11"
      - hatch:
          name: "Python 3.12, Django 5.0"
          hatch_env: "py3.12-dj5.0"
          python_version: "3.12"
      - hatch:
          name: "Python 3.12, Django 5.1"
          hatch_env: "py3.12-dj5.1"
          python_version: "3.12"
      - hatch:
          name: "Python 3.12, Django 5.2"
          hatch_env: "py3.12-dj5.2"
          python_version: "3.12"
      - hatch:
          name: "Python 3.13, Django 5.0"
          hatch_env: "py3.13-dj5.0"
          python_version: "3.13"
      - hatch:
          name: "Python 3.13, Django 5.1"
          hatch_env: "py3.13-dj5.1"
          python_version: "3.13"
      - hatch:
          name: "Python 3.13, Django 5.2"
          hatch_env: "py3.13-dj5.2"
          python_version: "3.13"
      - lint
