Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,20 @@ 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: |
python -m pip install --upgrade pip
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 support/lint.py --path ./examples/textbook/\*.py --threshold 3.0
56 changes: 56 additions & 0 deletions support/lint.py
Original file line number Diff line number Diff line change
@@ -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)