diff --git a/tools/fast8.sh b/tools/fast8.sh new file mode 100755 index 0000000000..22976ce09b --- /dev/null +++ b/tools/fast8.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +NUM_COMMITS=${FAST8_NUM_COMMITS:-1} + +if [[ $NUM_COMMITS = "smart" ]]; then + # Run on all commits not submitted yet + # (sort of -- only checks vs. "master" since this is easy) + NUM_COMMITS=$(git cherry master | wc -l) +fi + +echo "Checking last $NUM_COMMITS commits." + +cd $(dirname "$0")/.. +CHANGED=$(git diff --name-only HEAD~${NUM_COMMITS} | tr '\n' ' ') + +# Skip files that don't exist +# (have been git rm'd) +CHECK="" +for FILE in $CHANGED; do + if [ -f "$FILE" ]; then + CHECK="$CHECK $FILE" + fi +done + +diff -u --from-file /dev/null $CHECK | flake8 --diff diff --git a/tox.ini b/tox.ini index 186981cea7..081e956dfa 100644 --- a/tox.ini +++ b/tox.ini @@ -39,6 +39,13 @@ commands = # Run security linter bandit -r keystone -x tests +[testenv:fast8] +basepython = python3 +envdir = {toxworkdir}/pep8 +commands = + {toxinidir}/tools/fast8.sh +passenv = FAST8_NUM_COMMITS + [testenv:bandit] basepython = python3 # NOTE(browne): This is required for the integration test job of the bandit