-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci_badges.sh
64 lines (55 loc) · 1.63 KB
/
ci_badges.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
pip install anybadge
mkdir -p public/quality/
exit_status=false
args_list=()
for arg in $*
do
if [ "$arg" == "--exit-status" ]; then
exit_status=true
else
args_list+=($arg)
fi
done
# Black badge
black . --check --diff > .blackout 2>&1
black_status=$?
if [[ $black_status -eq 0 ]]; then
BLACK_RESULT=passing
else
BLACK_RESULT=failing
fi
anybadge -l black -v $BLACK_RESULT -f ./public/quality/black.svg passing=green failing=red
# Isort badge
isort -c --diff . > .isortout 2>&1
isort_status=$?
if [[ $isort_status -eq 0 ]]; then
ISORT_RESULT=passing
else
ISORT_RESULT=failing
fi
anybadge -l isort -v $ISORT_RESULT -f ./public/quality/isort.svg passing=green failing=red
# Pylint badge
pylint "${args_list[@]}" -f text --exit-zero > .pylintout 2> .pylinterror
anybadge -l pylint -v $(cat .pylintout | tail -n2 | awk '{print $7}' | cut -d"/" -f1) -f ./public/quality/pylint.svg 5=red 8=orange 9=yellow 9.5=yellowgreen 10=green
# Building htmls
echo "<pre>" > ./public/quality/black.html
cat .blackout >> ./public/quality/black.html
echo "</pre>" >> ./public/quality/black.html
echo "<pre>" > ./public/quality/isort.html
cat .isortout >> ./public/quality/isort.html
echo "</pre>" >> ./public/quality/isort.html
echo "<pre>" > ./public/quality/pylint.html
cat .pylinterror >> ./public/quality/pylint.html
cat .pylintout >> ./public/quality/pylint.html
echo "</pre>" >> ./public/quality/pylint.html
# print quality tools output
cat .blackout
cat .isortout
cat .pylinterror
cat .pylintout
if $exit_status; then
if [ "$isort_status" -ne "0" ] || [ "$black_status" -ne "0" ]; then
exit -1
fi
fi