From c1c0e1429a6694decf91f90f59504051cdaee72f Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Fri, 23 Jul 2021 14:00:48 +0200 Subject: [PATCH] [python][ci] Run black linter in the CI (only passes if no black would not change anything) --- .gitlab-ci/default.yml | 9 +++++++++ python/README.md | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/.gitlab-ci/default.yml b/.gitlab-ci/default.yml index 012847136f..db7ffd2359 100644 --- a/.gitlab-ci/default.yml +++ b/.gitlab-ci/default.yml @@ -3,6 +3,7 @@ default: stages: + - linting - configure - select - build @@ -30,6 +31,14 @@ configure: - build-cmake expire_in: 3 hours +python linting: + stage: linting + image: registry.gitlab.com/pipeline-components/black:latest + script: + # only check the python folder for now (Python code related to bindings) + # TODO: maybe extend this to the utility scripts? + - black --check --verbose -- python + select tests: stage: select diff --git a/python/README.md b/python/README.md index 851ef4e6fb..ea6f6044b4 100644 --- a/python/README.md +++ b/python/README.md @@ -69,3 +69,14 @@ You can run all currently existing DuMu<sup>x</sup> Python tests with cd dumux/build-cmake ctest -L python ``` +## Development + +All Python files should be linted by the tool [`black`](https://pypi.org/project/black/). +You can install `black` with `pip install black` and run it from the dumux top-directory + +``` +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. -- GitLab