twnet_parser/scripts/run_tests.sh

30 lines
902 B
Bash
Raw Normal View History

2023-03-16 15:43:53 +00:00
#!/bin/bash
RESET="\e[0m"
GREEN="\e[1;32m"
RED="\033[1;91m"
BG_RED="\033[0;101m"
2023-03-16 15:43:53 +00:00
# TODO: use yq to parse .gitlab-ci.yaml and auto run whatever the CI does
2023-04-02 09:51:21 +00:00
SCRIPT_ROOT="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 && pwd -P )"
cd "$SCRIPT_ROOT/.." || exit 1
err() {
local msg="$1"
printf '❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌\n'
printf '%b%s%b%b%s%b\n' "$BG_RED" "[FATAL FAILURE]" "$RESET" "$RED" " Error: $msg" "$RESET"
printf '❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌\n'
exit 1
}
bash "$SCRIPT_ROOT/lint_json.sh" || err "json lint failed!"
find . -type f -name '*.sh' -print0 | xargs -0 shellcheck -x || err "shellcheck failed!"
pytest . || err "pytest failed!"
pylint twnet_parser/ || err "pylint failed!"
mypy twnet_parser/ || err "mypy failed!"
printf "\n%b%s%b\n" "$GREEN" "✅ all tests passed." "$RESET"
2023-03-16 15:43:53 +00:00