]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add pylint and flake8 tests to GitLab CI
authorOndřej Surý <ondrej@sury.org>
Mon, 30 Mar 2020 12:18:01 +0000 (14:18 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 15 Apr 2020 05:44:39 +0000 (07:44 +0200)
Our python code didn't adhere to any coding standard.  In this commit, we add
flame8 (https://pypi.org/project/flake8/), and pylint (https://www.pylint.org/).

There's couple of exceptions:

- ans.py scripts are not checked, nor fixed as part of this MR
- pylint's missing-*-docstring and duplicate-code checks have
  been disabled via .pylintrc

Both exceptions should be removed in due time.

(cherry picked from commit ee534592e3c5ecd9f0d6c115c43b680baa692ed3)

.gitlab-ci.yml
.pylintrc [new file with mode: 0644]
util/copyrights

index ced68fdde3a7f28d5aea5e741a7c66aba5f6ac19..91c9d82fc80dc6994d0f0a89c4b9014dfe7ca2b9 100644 (file)
@@ -419,6 +419,37 @@ coccinelle:
     - util/check-cocci
     - if test "$(git status --porcelain | grep -Ev '\?\?' | wc -l)" -gt "0"; then git status --short; exit 1; fi
 
+flake8:
+  <<: *default_triggering_rules
+  <<: *base_image
+  stage: postcheck
+  needs:
+    - job: autoreconf
+      artifacts: true
+  before_script:
+    - pip3 install flake8
+  script:
+    - *configure
+    - flake8 --max-line-length=80 $(git ls-files '*.py' | grep -v 'ans\.py')
+  only:
+    - merge_requests
+
+pylint:
+  <<: *default_triggering_rules
+  <<: *base_image
+  stage: postcheck
+  needs:
+    - job: autoreconf
+      artifacts: true
+  before_script:
+    - pip3 install pylint
+    - PYTHONPATH="$PYTHONPATH:$CI_PROJECT_DIR/bin/python"
+  script:
+    - *configure
+    - pylint --rcfile $CI_PROJECT_DIR/.pylintrc $(git ls-files '*.py' | grep -v 'ans\.py')
+  only:
+    - merge_requests
+
 tarball-create:
   stage: precheck
   <<: *base_image
diff --git a/.pylintrc b/.pylintrc
new file mode 100644 (file)
index 0000000..62cbfae
--- /dev/null
+++ b/.pylintrc
@@ -0,0 +1,6 @@
+[MASTER]
+disable=
+    C0114, # missing-module-docstring
+    C0115, # missing-class-docstring
+    C0116, # missing-function-docstring
+    R0801, # duplicate-code
index fa07f42aba055a42143aad38fc03061593b49e74..65f86742ce585ee7199160d3a6ba703169b3556a 100644 (file)
@@ -1,6 +1,7 @@
 ./.dir-locals.el                               X       2019,2020
 ./.gitattributes                               X       2015,2017,2018,2019,2020
 ./.gitlab-ci.yml                               X       2018,2019,2020
+./.pylintrc                                    X       2020
 ./CHANGES                                      X       2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020
 ./CONTRIBUTING                                 X       2018,2019,2020
 ./CONTRIBUTING.md                              MKD     2018,2019,2020