---
version: '3'

tasks:
  ci:
    deps:
      - :install:python:pytest
      - :install:python:pytest-cov
      - :install:software:poetry
    log:
      error: Error encountered while running `pytest` and generating reports
      start: Running `pytest` and generating reports
      success: Finished running `pytest` and generating reports
    cmds:
      - poetry config virtualenvs.create false
      - |
        export "CFLAGS=-I/usr/local/include -L/usr/local/lib"
        poetry install --no-dev
      - |
        {{.PYTHON_HANDLE}}pytest --junitxml=report.xml --cov=src/
      - |
        {{.PYTHON_HANDLE}}coverage report
      - |
        {{.PYTHON_HANDLE}}coverage xml

  mypy:
    deps:
      - :install:pipx:mypy
    log:
      error: Encountered error while static type checking with `mypy`
      start: Running `mypy` for static type checking
      success: Successfully passed type checking with `mypy`
    cmds:
      - |
        PATH="$PATH:$HOME/.local/bin"
        {{.PYTHON_HANDLE}}mypy

  pytest:
    deps:
      - :install:pipx:pytest
      - :install:python:requirements
    log:
      error: '`pytest` encountered errors while running tests'
      start: Running `pytest`
      success: '`pytest` finished running without any errors to report'
    cmds:
      - |
        PATH="$PATH:$HOME/.local/bin"
        {{.PYTHON_HANDLE}}pytest
