From e7861de4353363bb5eae4c01530984127e345c8c Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Tue, 3 May 2022 15:37:26 +0200 Subject: [PATCH 1/5] Update lint.yml --- .github/workflows/lint.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d9fd1cdffd..22daf65b04 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,8 +22,8 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: ${{ matrix.py-version }} - architecture: ${{ matrix.py-arch }} + python-version: + 3.6 - name: Install dependencies run: | @@ -31,18 +31,11 @@ jobs: sudo apt-get install gfortran libopenblas-dev libhdf5-openmpi-dev libgsl0-dev cmake libfftw3-3 libfftw3-dev libmpfr6 libmpfr-dev pip install numpy scipy matplotlib docutils mpi4py pytest pytest-timeout if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python -m pip install pylint pycodestyle pydocstyle flake8 - name: Install amuse run: | pip install -e . - - name: Install Python dependencies - run: | - python -m pip install pylint pycodestyle pydocstyle flake8 - #- name: Run linters - # uses: wearerequired/lint-action@v1 - # with: - # flake8: true - name: Analysing the code with pylint run: | - # pylint examples/textbook/*.py -r y --evaluation="max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) )" - pylint examples/textbook/*.py -r y --evaluation="max(0, 0 if fatal else 10.0 - ((float(5 * error + warning) / statement) * 10) )" + python lint.py --path ./examples/textbook --threshold 3.0 From 57c85f5d80dbeacd2114484557aecb057d88f3dc Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Tue, 3 May 2022 15:40:16 +0200 Subject: [PATCH 2/5] Create lint.py --- support/lint.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 support/lint.py diff --git a/support/lint.py b/support/lint.py new file mode 100644 index 0000000000..39cee4a157 --- /dev/null +++ b/support/lint.py @@ -0,0 +1,56 @@ +# Pylint runner for github, based on the version in https://github.com/doedotdev/wool + +import argparse +import logging +from pylint.lint import Run + + +logging.getLogger().setLevel(logging.INFO) + +parser = argparse.ArgumentParser(prog="LINT") + +parser.add_argument('-p', + '--path', + help='path to directory you want to run pylint | ' + 'Default: %(default)s | ' + 'Type: %(type)s ', + default='./src', + type=str) + +parser.add_argument('-t', + '--threshold', + help='score threshold to fail pylint runner | ' + 'Default: %(default)s | ' + 'Type: %(type)s ', + default=7, + type=float) + +args = parser.parse_args() +path = str(args.path) +threshold = float(args.threshold) + +logging.info('PyLint Starting | ' + 'Path: {} | ' + 'Threshold: {} '.format(path, threshold)) + +results = Run([path], do_exit=False) + +final_score = results.linter.stats['global_note'] + +if final_score < threshold: + + message = ('PyLint Failed | ' + 'Score: {} | ' + 'Threshold: {} '.format(final_score, threshold)) + + logging.error(message) + raise Exception(message) + +else: + message = ('PyLint Passed | ' + 'Score: {} | ' + 'Threshold: {} '.format(final_score, threshold)) + + logging.info(message) + + exit(0) From fb40799a191c543c95cbeac28f384d95bbc3bab0 Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Tue, 3 May 2022 15:40:41 +0200 Subject: [PATCH 3/5] Update lint.yml --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 22daf65b04..cc7e2c63ad 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -38,4 +38,4 @@ jobs: - name: Analysing the code with pylint run: | - python lint.py --path ./examples/textbook --threshold 3.0 + python support/lint.py --path ./examples/textbook --threshold 3.0 From 2152ad84e7a8b13fca4896345eabe2272a9b2e5e Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Tue, 3 May 2022 15:47:19 +0200 Subject: [PATCH 4/5] Update lint.yml --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cc7e2c63ad..6e7605203e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -38,4 +38,4 @@ jobs: - name: Analysing the code with pylint run: | - python support/lint.py --path ./examples/textbook --threshold 3.0 + python support/lint.py --path ./examples/textbook/*.py --threshold 3.0 From 71874a83b22ca78f5fcf616469a1232cb9d60d95 Mon Sep 17 00:00:00 2001 From: Steven Rieder Date: Tue, 3 May 2022 16:04:07 +0200 Subject: [PATCH 5/5] Update lint.yml --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6e7605203e..e93fa93d3d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -38,4 +38,4 @@ jobs: - name: Analysing the code with pylint run: | - python support/lint.py --path ./examples/textbook/*.py --threshold 3.0 + python support/lint.py --path ./examples/textbook/\*.py --threshold 3.0