set shell := ["bash", "-c"]
set dotenv-load := true

# Print available commands.
help:
    @just --list

# --- Build and release ---

# Prepare wheel in `dist` directory.
[group('Build')]
build:
    uv build

# Publish a new release. Requires `UV_PUBLISH_TOKEN` to be exported in the env.
[group('Build')]
publish:
    uv publish \
        --index "https://test.pypi.org/legacy/" \
        --token "{{env_var('UV_PUBLISH_TOKEN')}}"

# Clean `dist` and cache files.
[group('Build')]
clean:
    rm -rf dist/ {.,src,src/*}/.ruff_cache/ {.,src,src/*}/.mypy_cache/ .pytest_cache/ .coverage .tox
    find src/ -name "__pycache__" | xargs rm -r

# --- Linters ---

# Autofix code and run all linters.
[group('Linters')]
lint: ruff mypy

# Autofix and lint code.
[group('Linters')]
ruff:
    uv run ruff format ./src
    uv run ruff check --fix ./src

# Static type checking.
[group('Linters')]
mypy:
    uv run mypy ./src

# --- Testing ---

# Run tests under `src/tests/`.
[group('Testing')]
test:
    uv run pytest

# Run tests for all supported Python versions.
[group('Testing')]
tox:
    uv run tox
