[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 observability --profile backend build

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

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

[no-cd]
[group("Tests")]
[doc("Tests run")]
tests:
    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 || exit 0
    codespell src tests
    bandit -r src || exit 0

[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}}"
