Add fast8 check for cybrog

Add "tox -e fast8" command, that we can check the changes file whether
is ok of it's PEP8 format.

Change-Id: I370bc8449321932831df4fe783be5c9ff0ed65df
This commit is contained in:
zhangbailin 2020-09-29 10:45:38 +08:00
parent 58be956842
commit c61e8ef3fc
2 changed files with 35 additions and 1 deletions

27
tools/flake8wrap.sh Normal file
View File

@ -0,0 +1,27 @@
#!/bin/sh
#
# A simple wrapper around flake8 which makes it possible
# to ask it to only verify files changed in the current
# git HEAD patch.
#
# Intended to be invoked via tox:
#
# tox -epep8 -- -HEAD
#
if test "x$1" = "x-HEAD" ; then
shift
files=$(git diff --name-only HEAD~1 | tr '\n' ' ')
echo "Running flake8 on ${files}"
echo ""
echo "Consider using the 'pre-commit' tool instead."
echo ""
echo " pip install --user pre-commit"
echo " pre-commit install --allow-missing-config"
echo ""
diff -u --from-file /dev/null ${files} | flake8 --diff "$@"
else
echo "Running flake8 on all files"
echo ""
exec flake8 "$@"
fi

View File

@ -11,6 +11,7 @@ ignore_basepython_conflict = True
basepython = python3
usedevelop = True
whitelist_externals =
bash
rm
make
install_command = {[testenv:common-constraints]install_command}
@ -50,7 +51,6 @@ deps = bindep
commands = bindep test
usedevelop = False
[testenv:pep8]
commands =
flake8
@ -60,6 +60,13 @@ commands =
install_command = {[testenv:common-constraints]install_command}
commands = flake8 {posargs}
[testenv:fast8]
description =
Run style checks on the changes made since HEAD~. For a full run including docs, use 'pep8'
envdir = {toxworkdir}/shared
commands =
bash tools/flake8wrap.sh -HEAD
[testenv:venv]
commands = {posargs}