#!/bin/sh
set -eu
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
REPO_ROOT=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)
PYTHON=${PYTHON:-"$REPO_ROOT/.venv/bin/python"}
if [ ! -x "$PYTHON" ]; then
    echo "check: create .venv and install the dev dependencies first" >&2
    exit 1
fi
cd "$REPO_ROOT"
"$PYTHON" -m ruff check --no-fix .
"$PYTHON" -m ruff format --check .
"$PYTHON" -m mypy
"$PYTHON" scripts/documents/lint.py *.md documents/
"$PYTHON" scripts/changelog.py
