blob: 564a568f238ee1fb9c65596726bc87af814b9293 (
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
|
#!/bin/bash
RESULT="$WORKSPACE/python-lint"
mkdir $RESULT
./autogen.sh
./configure --enable-debug --enable-gnfs --silent
# create and activate virtual env
python3 -m venv env
. env/bin/activate
#install flake8 and pylint
pip install -I flake8 pylint
# run flake8
find . -path './env' -prune -o -name '*.py' -print | xargs flake8 > "$RESULT/flake8-check.txt"
FLAKE_COUNT="$(wc -l < $RESULT/flake8-check.txt)"
#run pylint
find . -path './env' -print -o -name '*.py' | xargs pylint --output-format=text > "$RESULT/pylint-check.txt"
PYLINT_COUNT="$(egrep -wc 'R:|C:|W:|E:|F:' $RESULT/pylint-check.txt)"
#fail build if there's any pylint and flake8 related issues
if [[ "$FLAKE_COUNT" -gt 0 && "$PYLINT_COUNT" -gt 0 ]]; then
echo ""
echo "========================================================="
echo " Result of python linter"
echo " Number of flake8 issues: ${FLAKE_COUNT}"
echo " Number of pylint issues: ${PYLINT_COUNT}"
echo "========================================================="
exit 1
fi
|