blob: 49491c11e5e033203a13a768cfa4530c433bdc0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#!/usr/bin/env bash
# ensure consistent behaviour
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
aggregate_rv=0
function check_rv {
if test "$1" -eq 0; then
echo -e " ${green}OK${reset}"
else
echo -e " ${red}FAIL${reset}"
fi
aggregate_rv=$(( $aggregate_rv + $1 ))
}
# stop failing early, because we wouldn't do anything else than fail
set +e
# check that all dependencies are installed correctly
echo -e "${yellow}Checking that all dependencies are properly installed...${reset}"
poetry install --dry-run --only main,dev,lint | grep "0 install" > /dev/null
check_rv $?
echo
# early exit when dependencies are not installed
if test "$aggregate_rv" -ne "0"; then
echo -e "${red}Dependencies are not properly installed. Run this command to fix it:${reset}"
echo -e " ${red}poetry install${reset}"
exit 1
fi
# check formatting using black
echo -e "${yellow}Checking formatting using black...${reset}"
black python/knot_resolver_manager tests/manager scripts/poe-tasks/utils/create_setup.py --check --diff
check_rv $?
echo
# check code with pylint
echo -e "${yellow}Linting using pylint...${reset}"
pylint python/knot_resolver_manager
check_rv $?
echo
# check code with flake8
echo -e "${yellow}Linting using flake8...${reset}"
flake8 --max-line-length=200 --ignore=E266,W503 --extend-ignore=E203 python/knot_resolver_manager
check_rv $?
echo
# check types with mypy
echo -e "${yellow}Type checking using mypy...${reset}"
mypy python/knot_resolver_manager
check_rv $?
echo
# check that setup.py is not behind pyproject.toml
echo -e "${yellow}Checking setup.py${reset}"
python scripts/poe-tasks/utils/create_setup.py | diff - setup.py
check_rv $?
python setup.py --help > /dev/null
check_rv $?
echo
# fancy messages at the end :)
if test "$aggregate_rv" -eq "0"; then
echo -e "${green}Everything looks great!${reset}"
else
echo -e "${red}Failure.${reset}"
echo -e "${red}These commands might help you:${reset}"
echo -e "${red}\tpoe format${reset}"
echo -e "${red}\tpoe gen-setuppy${reset}"
echo -e "${red}That's not great. Could you please fix that?${reset} 😲😟"
fi
# exit with the aggregate return value
exit $aggregate_rv
|