-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_code.sh
executable file
·48 lines (41 loc) · 1.12 KB
/
check_code.sh
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
#!/usr/bin/env bash
echo "Collecting python files..."
# TODO: check all python files
py_files=$(git ls-files -- '*.py' ':!:examples')
if ! poetry run isort -m 3 -tc --check-only ${py_files}; \
then
echo "'isort' returned non-zero code"
poetry run isort -m 3 -tc --diff ${py_files}
exit 1
fi
if ! poetry run black -l 79 -S --check -q ${py_files}; \
then
echo "'black' returned non-zero code"
poetry run black -l 79 -S --diff -q ${py_files}
exit 1
fi
echo ""
echo "Code:"
not_tests=$(git ls-files -- '*.py' ':!:examples' ':!:tests')
poetry run pylint ${not_tests}
exit_code="$?"
if [ $(((exit_code & 1) >> 0)) -ne 0 ]; then
echo "Fatal message issued by pylint"
exit 1
elif [ $(((exit_code & 2) >> 0)) -ne 0 ]; then
echo "Error message issued by pylint"
exit 1
fi
echo ""
echo "Tests:"
tests=$(git ls-files -- '*.py' ':!:examples' ':!:ancalagon')
poetry run pylint ${tests} --disable=W0621,W0212
exit_code="$?"
if [ $(((exit_code & 1) >> 0)) -ne 0 ]; then
echo "Fatal message issued by pylint"
exit 1
elif [ $(((exit_code & 2) >> 0)) -ne 0 ]; then
echo "Error message issued by pylint"
exit 1
fi
echo "Nice."