image: ghcr.io/astral-sh/uv:python3.12-bookworm

stages:
  - lint
  - typecheck
  - test

variables:
  UV_PYTHON: "3.12"
  PIP_DISABLE_PIP_VERSION_CHECK: "1"
  PYTHONDONTWRITEBYTECODE: "1"

before_script:
  - uv sync --frozen --extra linting

lint:
  stage: lint
  script:
    - uv run ruff format --check .
    - uv run ruff check --force-exclude .
  rules:
    - changes:
        - "**/*.py"
        - "pyproject.toml"
        - ".pre-commit-config.yaml"
      when: on_success
    - when: never

typecheck:
  stage: typecheck
  script:
    - uv run ty check
  rules:
    - changes:
        - "**/*.py"
        - "pyproject.toml"
      when: on_success
    - when: never

test:
  stage: test
  script:
    - uv run pytest -q
  rules:
    - changes:
        - "**/*.py"
        - "pyproject.toml"
        - "pytest.ini"
        - "pyproject.toml"
      when: on_success
    - when: never