diff --git a/tools/coding-checks.sh b/tools/coding-checks.sh index 709f24e2ed..8a8457dde1 100755 --- a/tools/coding-checks.sh +++ b/tools/coding-checks.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -eu @@ -26,23 +26,36 @@ process_options() { } run_pylint() { + local target="${scriptargs:-HEAD~1}" + local concurrency=$(python -c 'import multiprocessing as mp; print(mp.cpu_count())') + CODE_OKAY=0 if [[ "$target" = *"all"* ]]; then files="manila" + test_files="manila.tests" else - files=$(git diff --name-only --diff-filter=ACMRU $target "*.py") + files=$(git diff --name-only --diff-filter=ACMRU HEAD~1 ':!manila/tests/*' '*.py') + test_files=$(git diff --name-only --diff-filter=ACMRU HEAD~1 'manila/tests/*.py') fi - - if [ -n "${files}" ]; then - echo "Running pylint against:" - printf "\t%s\n" "${files[@]}" - pylint --rcfile=.pylintrc --output-format=colorized ${files} -E \ - -j `python -c 'import multiprocessing as mp; print(mp.cpu_count())'` - else + if [[ -z "${files}" || -z "${test_files}" ]]; then echo "No python changes in this commit, pylint check not required." exit 0 fi + if [[ -n "${files}" ]]; then + echo "Running pylint against manila code modules:" + printf "\t%s\n" "${files[@]}" + pylint --rcfile=.pylintrc --output-format=colorized ${files} \ + -E -j $concurrency || CODE_OKAY=1 + fi + if [[ -n "${test_files}" ]]; then + echo "Running pylint against manila test modules:" + printf "\t%s\n" "${test_files[@]}" + pylint --rcfile=.pylintrc --output-format=colorized ${test_files} \ + -E -d "no-member,assignment-from-no-return,assignment-from-none" \ + -j $concurrency || CODE_OKAY=1 + fi + exit $CODE_OKAY } scriptargs= diff --git a/tox.ini b/tox.ini index 6c28eade4c..bc3b807d27 100644 --- a/tox.ini +++ b/tox.ini @@ -56,7 +56,8 @@ commands = devstack/upgrade/shutdown.sh \ devstack/upgrade/upgrade.sh \ tools/cover.sh \ - tools/check_logging.sh + tools/check_logging.sh \ + tools/coding-checks.sh {toxinidir}/tools/check_exec.py {toxinidir}/manila {toxinidir}/tools/check_logging.sh {toxinidir}/manila