Enable fast8 check

Fast8 only check these files that changed, which is more efficient for tox test.

Change-Id: I9a9816e12361900261fa2ee693bf211154eb2e0f
This commit is contained in:
songwenping 2021-12-28 09:13:01 +00:00
parent dea080a5d4
commit 4fa99dd51d
2 changed files with 41 additions and 0 deletions

28
tools/flake8wrap.sh Normal file
View File

@ -0,0 +1,28 @@
#!/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

13
tox.ini
View File

@ -10,6 +10,12 @@ basepython = python3
setenv = VIRTUAL_ENV={envdir}
OS_TEST_PATH=venus/tests/unit
usedevelop = True
allowlist_externals =
bash
find
rm
env
make
install_command = pip install {opts} {packages}
deps =
@ -30,6 +36,13 @@ commands =
# Check that .po and .pot files are valid:
doc8 --ignore D001 doc/source/ CONTRIBUTING.rst HACKING.rst README.rst
[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}