From 1e64ddb24a55ca955a52a545e09bf0de5b5f3106 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Mon, 26 Jul 2021 18:38:33 +0200 Subject: [PATCH] [ci][python] Test Python bindings --- .gitlab-ci/default.yml | 18 ++++++++++++++++-- python/README.md | 15 +++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci/default.yml b/.gitlab-ci/default.yml index 7b1ced751d..83b9bbbe6c 100644 --- a/.gitlab-ci/default.yml +++ b/.gitlab-ci/default.yml @@ -3,8 +3,8 @@ default: stages: - - linting - configure + - linting - select - build - test @@ -31,7 +31,8 @@ configure: - build-cmake expire_in: 3 hours -python linting: + +black (python): stage: linting image: registry.gitlab.com/pipeline-components/black:latest script: @@ -41,6 +42,19 @@ python linting: - black --check --verbose -- test/python +pylint (python): + stage: linting + script: + - source bin/testing/ci-setup-python-env.sh + - | + if [ -d build-cmake/python/dumux ] ; then + pylint --rcfile=.pylintrc build-cmake/python/dumux + fi + needs: + - job: configure + artifacts: true + + select tests: stage: select script: diff --git a/python/README.md b/python/README.md index ea6f6044b4..236956fc09 100644 --- a/python/README.md +++ b/python/README.md @@ -80,3 +80,18 @@ black ./python You can also run it on a specific file (replace `./python` by file name) This will automatically format the Python files. Run black before every commit changing Python files. + +The `dumux` Python module should be get a score of `10` from +the tool [`pylint`](https://pypi.org/project/pylint/). +You can install `pylint` with `pip install pylint` and run it from the dumux top-directory + +``` +pylint build-cmake/python/dumux +``` + +Pylint needs to be able to check imports so the modules need to be properly set up +with `setup-dunepy.py` (see above). The `pylint` configuration file `dumux/.pylintrc` can +be used to configure `pylint`. Some exceptions or other parameters than the default +might be sensible in the future but generally advice given by `pylint` leads to better code. +Different from `black`, `pylint` does no itself fix the code, you need to do this yourself. +Always run `black` before checking `pylint`. -- GitLab