Wrap flake8

Wrapping flake8 give a possibility to a user to dissable flake8 via
setting environment variable in config.sh.
This commit is contained in:
Jiri Kucera 2020-01-20 10:10:14 +01:00
parent 7007a0ec1f
commit fc0c37efc1
3 changed files with 42 additions and 2 deletions

View file

@ -22,5 +22,9 @@
# - RUN_BLACK_EXCLUDE
# - RUN_BLACK_DISABLED
#
# * .travis/runflake8.sh:
#
# - RUN_FLAKE8_DISABLED
#
export LSR_MOLECULE_DEPS='-rmolecule_requirements.txt'

34
.travis/runflake8.sh Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
# A shell wrapper around flake8. The purpose of this wrapper is to get to user
# an opportunity to disable running flake8 via config.sh.
# The first script argument is a path to Python interpreter, the rest of
# arguments are passed to flake8.
# Environment variables:
#
# RUN_FLAKE8_DISABLED
# if set to an arbitrary non-empty value, flake8 will be not executed
set -e
ME=$(basename $0)
SCRIPTDIR=$(readlink -f $(dirname $0))
. ${SCRIPTDIR}/utils.sh
. ${SCRIPTDIR}/config.sh
if [[ "${RUN_FLAKE8_DISABLED}" ]]; then
lsr_info "${ME}: flake8 is disabled. Skipping."
exit 0
fi
# Sanitize path in case if running within tox (see
# https://github.com/tox-dev/tox/issues/1463):
ENVPYTHON=$(readlink -f $1)
shift
set -x
${ENVPYTHON} -m flake8 "$@"

View file

@ -153,11 +153,13 @@ commands =
[testenv:flake8]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:2.7}
basepython = python2.7
passenv = RUN_FLAKE8_*
deps =
flake8>=3.5
whitelist_externals = flake8
whitelist_externals =
{[base]whitelist_externals}
commands =
flake8 --statistics {posargs} .
bash {toxinidir}/.travis/runflake8.sh {envpython} --statistics {posargs} .
[testenv:coveralls]
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:coveralls}