From 4fa99dd51d0ace6c2f8f56a3671d0a762515c1ae Mon Sep 17 00:00:00 2001 From: songwenping Date: Tue, 28 Dec 2021 09:13:01 +0000 Subject: [PATCH] Enable fast8 check Fast8 only check these files that changed, which is more efficient for tox test. Change-Id: I9a9816e12361900261fa2ee693bf211154eb2e0f --- tools/flake8wrap.sh | 28 ++++++++++++++++++++++++++++ tox.ini | 13 +++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tools/flake8wrap.sh 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}