Pep8 environment to run on delta code only
Currently tox -epep8 will run flake8 on whole code. To make this fast, flake8 support is added for only updated(delta) code. Same can be run by "tox -efast8". It also determines how many commits to check based on the $FAST8_NUM_COMMITS env variable. If set to "smart", it uses git to try to run against all unsubmitted commits. This allows fast8 to be more useful when actively developing a series of patches. Closes-Bug: #1829455 Change-Id: Ic02d7a91c6f6b227abf14bc6f7cb85815591c0d3
This commit is contained in:
parent
5c5d71cce9
commit
e054b368dc
|
@ -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
|
7
tox.ini
7
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
|
||||
|
|
Loading…
Reference in New Issue