diff --git a/tools/flake8wrap.sh b/tools/flake8wrap.sh new file mode 100644 index 0000000..e12d063 --- /dev/null +++ b/tools/flake8wrap.sh @@ -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 + diff --git a/tox.ini b/tox.ini index 7da272b..65ae2e6 100644 --- a/tox.ini +++ b/tox.ini @@ -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}