summaryrefslogtreecommitdiffstats
path: root/build-gluster-org/scripts/python-lint.sh
diff options
context:
space:
mode:
authorDeepshikha khandelwal <dkhandel@redhat.com>2018-10-31 17:19:06 +0530
committerNigel Babu <nigelb@redhat.com>2018-11-09 06:44:20 +0000
commitae9b1ece95d4b2f8a5fe38c79c259ad616099a5b (patch)
tree5f50248c28f1dc0185cfb446739568729b0f7438 /build-gluster-org/scripts/python-lint.sh
parent97dda0acc3c20bdae100e6daffa1ce03e52b4ac3 (diff)
Smoke job for python validation using tools like flake8 and pylint
- pylint: Output will be archived in pylint-check.txt. This job will fail if there's any [W]arning, [C]onvention, [R]efactor, [E]rror, [F]atal message type. - flake8: Output will be archived in flake8-check.txt This is a non-voting smoke job for now. The count of pylint and flake8 issue is too huge as mentioned in https://bugzilla.redhat.com/show_bug.cgi?id=1584992 Change-Id: Idbe0ebfdbbf9ac955c26bd4befc4b3cf9f62d395
Diffstat (limited to 'build-gluster-org/scripts/python-lint.sh')
-rw-r--r--build-gluster-org/scripts/python-lint.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/build-gluster-org/scripts/python-lint.sh b/build-gluster-org/scripts/python-lint.sh
new file mode 100644
index 0000000..772b6ba
--- /dev/null
+++ b/build-gluster-org/scripts/python-lint.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+RESULT="$WORKSPACE/python-lint"
+mkdir $RESULT
+
+./autogen.sh
+./configure --disable-bd-xlator --enable-debug --enable-gnfs --silent
+
+# run flake8
+flake8 . >"$RESULT/flake8-check.txt"
+FLAKE_COUNT="$(wc -l < '$RESULT/flake8-check.txt')"
+
+#run pylint
+find . -iname "*.py" | xargs pylint --output-format=text >"$RESULT/pylint-check.txt"
+PYLINT_COUNT="$(egrep -wc 'R:|C:|W:|E:|F:' 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