From 677f7b891851ef85f132a0ad65efa1324a5086fd Mon Sep 17 00:00:00 2001 From: Jiri Kucera Date: Mon, 13 Jan 2020 15:30:02 +0100 Subject: [PATCH] Wrap pylint runner Prior this change, RUN_PYLINT_* environment variables set by config.sh have effect only while running in Travis (because runtox script sets them by including config.sh). By wrapping pylint runner with shell script, RUN_PYLINT_* environment variables have effect also while running tox locally. --- .travis/config.sh | 6 +++++ run_pylint.py => .travis/custom_pylint.py | 4 ++-- .travis/runpylint.sh | 29 +++++++++++++++++++++++ tox.ini | 4 +++- 4 files changed, 40 insertions(+), 3 deletions(-) rename run_pylint.py => .travis/custom_pylint.py (98%) create mode 100755 .travis/runpylint.sh diff --git a/.travis/config.sh b/.travis/config.sh index 95a61a2..2e3f401 100644 --- a/.travis/config.sh +++ b/.travis/config.sh @@ -10,6 +10,12 @@ # Environment variables that not start with LSR_* but have influence on CI # process: # +# * .travis/runpylint.sh: +# +# - RUN_PYLINT_INCLUDE +# - RUN_PYLINT_EXCLUDE +# - RUN_PYLINT_DISABLED +# # * .travis/runblack.sh: # # - RUN_BLACK_INCLUDE diff --git a/run_pylint.py b/.travis/custom_pylint.py similarity index 98% rename from run_pylint.py rename to .travis/custom_pylint.py index 0e79124..e8725e7 100644 --- a/run_pylint.py +++ b/.travis/custom_pylint.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # SPDX-License-Identifier: MIT # -# Copyright (c) 2019 Red Hat, Inc. +# Copyright (c) 2019-2020 Red Hat, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -24,7 +24,7 @@ """ Probe directory tree for python files and pass them to pylint. -Usage: python run_pylint.py ARGUMENTS +Usage: python custom_pylint.py ARGUMENTS Run pylint with ARGUMENTS followed by the list of python files contained in the working directory and its subdirectories. As a python file is recognized a diff --git a/.travis/runpylint.sh b/.travis/runpylint.sh new file mode 100755 index 0000000..619d85c --- /dev/null +++ b/.travis/runpylint.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT + +# A shell wrapper around custom_pylint.py. The purpose of this wrapper is to +# set environment variables defined in config.sh before custom_pylint.py +# invocation, so user can control what should be pylinted via config.sh. + +# Note: Prior this change, RUN_PYLINT_* environment variables set in config.sh +# take effect only when running inside Travis (because of runtox script +# which set them by including config.sh). Now, they take effect also when +# running tox locally. + +# First argument to the script is a path to environment python, the rest of +# arguments are passed to custom_pylint.py. + +set -e + +ME=$(basename $0) +SCRIPTDIR=$(readlink -f $(dirname $0)) + +. ${SCRIPTDIR}/config.sh + +# 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} ${SCRIPTDIR}/custom_pylint.py "$@" diff --git a/tox.ini b/tox.ini index 6b782a3..1fe8eb6 100644 --- a/tox.ini +++ b/tox.ini @@ -145,8 +145,10 @@ deps = pylint>=1.8.4 ansible -rpylint_extra_requirements.txt +whitelist_externals = + {[base]whitelist_externals} commands = - {envpython} ./run_pylint.py --errors-only {posargs} + bash {toxinidir}/.travis/runpylint.sh {envpython} --errors-only {posargs} [testenv:flake8] envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:2.7}