#!/usr/bin/ bash

set -e

# defaults if not set
: "${SKIP_LINT:=0}"
: "${SKIP_TYPE_CHECKS:=0}"

# type checking
if [ "$SKIP_TYPE_CHECKS" -ne 1 ]; then
    echo 'Running mypy...'
    python -m mypy --cache-dir=/dev/null src 
else
    echo 'Skipping type checks...'
fi

# run linting of files
if [ "$SKIP_LINT" -ne 1 ]; then
    echo 'Running yaml linter...'
    python -m yamllint docker-compose.yaml
    echo 'Running ruff linter...'
    python -m ruff check src --no-cache
    echo 'Running ruff formatter check...'
    python -m ruff format src --diff --no-cache
else
    echo 'Skipping linting...'
fi

