#!/bin/bash

set -e

export CANARY_CACHE_DIR=/dev/null

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

cd $SCRIPT_DIR/..

echo "========================="
echo "ruff: formatting examples"
echo "========================="
find src/canary/examples -name "*.pyt" | xargs ruff format
ruff format src/canary/examples
ruff format docs/source/static

echo ""
echo "======================"
echo "ruff: formatting tests"
echo "======================"
find tests -name "*.pyt" | xargs ruff format
ruff format tests

echo ""
echo "===================="
echo "ruff: formatting src"
echo "===================="
ruff format src

echo ""
echo "======================="
echo "ruff: checking examples"
echo "======================="
find src/canary/examples -name "*.pyt" | xargs ruff check --fix
ruff check --fix src/canary/examples
ruff check --fix docs/source/static

echo ""
echo "===================="
echo "ruff: checking tests"
echo "===================="
find tests -name "*.pyt" | xargs ruff check --fix
ruff check --fix tests

echo ""
echo "=================="
echo "ruff: checking src"
echo "=================="
ruff check --fix src

echo ""
echo "================="
echo "mpy: checking src"
echo "================="
mypy src

echo ""
echo "======================="
echo "coverage: running tests"
echo "======================="
coverage run

echo ""
echo "==================================="
echo "coverage: creating coverate reports"
echo "==================================="
coverage report
coverage html
