diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d9fd1cdffd..e93fa93d3d 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 support/lint.py --path ./examples/textbook/\*.py --threshold 3.0 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)