version: "3"

vars:
  RUNNER:
    sh: 'echo {{ .RUNNER | default "uv run " }}'
  SOURCES: .
  SOURCES_ROOT: .

tasks:
  default:
    cmd:
      task: all

  lint:
    desc: Lint python source files
    cmds:
      - "{{.RUNNER}} ruff check {{.SOURCES}}"
      - "{{.RUNNER}} ruff format --check --diff {{.SOURCES}}"

  format:
    desc: Format python source files
    aliases: ["fmt"]
    cmds:
      - "{{.RUNNER}} ruff format {{ .SOURCES }}"
      - "{{.RUNNER}} ruff check --fix {{.SOURCES}}"

  deptry:
    desc: Check used dependencies with deptry
    cmd: "{{.RUNNER}} deptry {{.SOURCES_ROOT}}"

  typecheck:
    desc: Perform type-checking
    cmd: "{{.RUNNER}} mypy {{.SOURCES}}"

  test:
    desc: Run tests
    cmds:
      - "{{.RUNNER}} pytest -n auto --cov"

  all:
    desc: Run the standard set of checks performed in CI
    cmds:
      - task: format
      - task: deptry
      - task: typecheck
      - task: test
