]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
pytests: add python lint checks
authorTomas Krizek <tomas.krizek@nic.cz>
Mon, 12 Nov 2018 15:58:59 +0000 (16:58 +0100)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 4 Dec 2018 16:13:42 +0000 (17:13 +0100)
.gitlab-ci.yml
ci/pytests/lint.sh [new file with mode: 0755]
ci/pytests/pylint-run.sh [new file with mode: 0755]
tests/pytests/pylintrc [new file with mode: 0644]

index a0c9e841137847f452aa0b04380bd3e4fa0919b0..950e8da7bdc0b7ad0df4bd71e69779b20b80f4e4 100644 (file)
@@ -268,6 +268,18 @@ test:linux:amd64:valgrind:
     - linux
     - amd64
 
+pytests:lint:
+  stage: test
+  dependencies: []
+  except:
+    - master
+  script:
+    - ./ci/pytests/lint.sh
+  tags:
+    - docker
+    - linux
+    - amd64
+
 .respdiff:  &respdiff
   stage: respdiff
   dependencies: []
diff --git a/ci/pytests/lint.sh b/ci/pytests/lint.sh
new file mode 100755 (executable)
index 0000000..b6c0bfc
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+python3 -m flake8 --max-line-length=100 tests/pytests
+FLAKE8=$?
+
+ci/pytests/pylint-run.sh
+PYLINT=$?
+
+if [ $PYLINT -ne 0 ]; then
+       exit 1
+fi
+if [ $FLAKE8 -ne 0 ]; then
+       exit 1
+fi
+
+exit 0
diff --git a/ci/pytests/pylint-run.sh b/ci/pytests/pylint-run.sh
new file mode 100755 (executable)
index 0000000..159a830
--- /dev/null
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+set -e
+
+# Find Python modules and standalone Python scripts
+FILES=$(find ./tests/pytests \
+       -type d -exec test -e '{}/__init__.py' \; -print -prune -o \
+       -name '*.py' -print)
+
+python3 -m pylint -j 0 --rcfile ./tests/pytests/pylintrc ${FILES}
diff --git a/tests/pytests/pylintrc b/tests/pytests/pylintrc
new file mode 100644 (file)
index 0000000..b1cc558
--- /dev/null
@@ -0,0 +1,28 @@
+[MESSAGES CONTROL]
+
+disable=
+    missing-docstring,
+    too-many-arguments,
+    too-many-instance-attributes,
+    fixme,
+    unused-import,  # checked by flake8
+    line-too-long,  # checked by flake8
+    invalid-name,
+    broad-except,
+    bad-continuation,
+    global-statement,
+    no-else-return,
+    redefined-outer-name,  # commonly used with pytest fixtures
+
+
+[SIMILARITIES]
+min-similarity-lines=6
+ignore-comments=yes
+ignore-docstrings=yes
+ignore-imports=no
+
+[DESIGN]
+max-parents=10
+
+[TYPECHECK]
+ignored-modules=ssl