From 86e1c8baf63386e9dec216bccfe6a419b99dacca Mon Sep 17 00:00:00 2001 From: Audrius Mecionis Date: Wed, 18 Nov 2020 17:52:45 +0100 Subject: [PATCH] ci: added flake8 linter addresses https://github.com/reanahub/reana/issues/456 --- .flake8 | 20 ++++++++++++++++++++ .github/workflows/ci.yml | 17 +++++++++++++++++ MANIFEST.in | 1 + run-tests.sh | 6 ++++++ setup.py | 2 +- tests/benchmark/locustfile.py | 4 ++-- 6 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..5b9686af --- /dev/null +++ b/.flake8 @@ -0,0 +1,20 @@ +[flake8] +max-line-length = 89 + +exclude = + build + modules + dist + docs + coverage.xml + reana_job_controller.egg-info + .*/ + env/ + .git + __pycache__ + +ignore = E203, E231, E266, E501, W503, F403, F401 + +max-complexity = 18 + +select = B,C,E,F,W,T4,B9 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0816114c..3a328a6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,23 @@ jobs: pip install black==19.10b0 ./run-tests.sh --check-black + lint-flake8: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Check compliance with pep8, pyflakes and circular complexity + run: | + pip install --upgrade pip + pip install flake8 + ./run-tests.sh --check-flake8 + lint-pydocstyle: runs-on: ubuntu-20.04 steps: diff --git a/MANIFEST.in b/MANIFEST.in index a41d20ec..3e2faeca 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -11,6 +11,7 @@ include *.html include *.yaml include *.yml include *.sh +include .flake8 include pytest.ini prune docs/_build recursive-include reana *.py diff --git a/run-tests.sh b/run-tests.sh index ae28b6fc..a7e7bfd0 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -20,6 +20,10 @@ check_black () { black --check . } +check_flake8 () { + flake8 . +} + check_pydocstyle () { pydocstyle reana } @@ -43,6 +47,7 @@ check_helm () { check_all () { check_script check_black + check_flake8 check_pydocstyle check_manifest check_sphinx @@ -60,6 +65,7 @@ do case $arg in --check-shellscript) check_script;; --check-black) check_black;; + --check-flake8) check_flake8;; --check-pydocstyle) check_pydocstyle;; --check-manifest) check_manifest;; --check-sphinx) check_sphinx;; diff --git a/setup.py b/setup.py index 9be6387d..b8b4665d 100644 --- a/setup.py +++ b/setup.py @@ -52,7 +52,7 @@ # Get the version string. Cannot be done with import! with open(os.path.join("reana", "version.py"), "rt") as f: - version = re.search('__version__\s*=\s*"(?P.*)"\n', f.read()).group( + version = re.search(r'__version__\s*=\s*"(?P.*)"\n', f.read()).group( "version" ) diff --git a/tests/benchmark/locustfile.py b/tests/benchmark/locustfile.py index af9a9f78..2769150c 100644 --- a/tests/benchmark/locustfile.py +++ b/tests/benchmark/locustfile.py @@ -65,12 +65,12 @@ def setup(self): @task def ping(self): """Ping reana instance.""" - self.client.get(f"/api/ping") + self.client.get("/api/ping") @task def get_worflows(self): """Get workflows.""" - self.client.get(f"/api/workflows", params=(("access_token", TOKEN),)) + self.client.get("/api/workflows", params=(("access_token", TOKEN),)) @task def get_worflow_logs(self):