[doc("All commands")]
default:
    just --list --unsorted --list-heading $'Commands…\n'

# =========
# > Docker
# =========

[no-cd]
[group("Docker")]
[doc("Rebuild all images")]
build:
    docker compose --profile migrations --profile tests --profile observability build

[no-cd]
[group("Docker")]
[doc("Compose start")]
up:
    docker compose --profile migrations --profile observability up -d --remove-orphans --quiet-pull --force-recreate

# =========
# > Tests
# =========

[no-cd]
[group("Tests")]
[doc("Tests run")]
tests:
    just up

    docker compose --profile migrations --profile tests up tests --remove-orphans --abort-on-container-exit
    
# =========
# > Lints
# =========

[no-cd]
[group("Lints")]
[doc("Linters run")]
lint:
    ruff check
    mypy
    codespell src tests
    bandit src tests

[no-cd]
[group("Formatters")]
format:
    ruff format

# =========
# > Overall check
# =========

[no-cd]
[group("Check")]
[doc("Check before commit")]
check:
    just lint
    just tests

# =========
# > Migrations
# =========

[no-cd]
[group("Migrations")]
[doc("Run alembic upgrade")]
migrations-run tag="head":
    CONFIGURATION_PATH=config.toml alembic upgrade {{tag}}

[no-cd]
[group("Migrations")]
[doc("Create new alembic revision")]
migrations-make message="":
    CONFIGURATION_PATH=config.toml alembic revision --autogenerate -m "{{message}}"
