From f4855dd66faf8922aa1f3df775615e39118810fd Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Mon, 20 Aug 2018 16:40:59 -0500 Subject: [PATCH] Check for oslo library usage Occasionally oslo library usage sneaks in, so add a coding check that checks for ^oslo\. in requirements.txt. We currently still use oslo.test, so don't check test-requirements.txt. This should fail to pass tests until I34357d5a594330d07f5cad372859d98efb5d3fde merges. Change-Id: I53108584ee47a7f1b6c7df90c49f95725cec69f9 --- HACKING.rst | 14 ++++++++++++-- tools/coding-checks.sh | 16 +++++++++++++++- tox.ini | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/HACKING.rst b/HACKING.rst index 5df73333..25fcb063 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -1,4 +1,14 @@ ovsdbapp Style Commandments -=============================================== +=========================== -Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/ +- Step 1: Read the OpenStack Style Commandments + https://docs.openstack.org/hacking/latest/ + +- Step 2: Read on + +ovsdbapp-specific Commandments +------------------------------ + +- ovsdbapp is intended to be a simple wrapper on top of python-ovs. As such, + it must build and be deployable without any OpenStack dependencies (oslo + projects included). It does currently use oslo.test for testing. diff --git a/tools/coding-checks.sh b/tools/coding-checks.sh index 0aa78490..6de32182 100755 --- a/tools/coding-checks.sh +++ b/tools/coding-checks.sh @@ -27,12 +27,22 @@ process_options () { case $opt in -h|--help) usage;; -Y|--pylint) pylint=1;; + -O|--oslo) oslo=1;; + -a|--all) oslo=1; pylint=1;; *) join_args;; esac i=$((i+1)) done } +run_oslo () { + echo "Checking for oslo libraries in requirements.txt..." + if grep -q "^oslo[.-]" requirements.txt; then + echo "oslo libraries are not allowed" + exit 1 + fi +} + run_pylint () { local target="${scriptargs:-all}" @@ -56,10 +66,14 @@ run_pylint () { } scriptargs= -pylint=1 +pylint=0 +oslo=0 process_options $@ +if [ $oslo -eq 1 ]; then + run_oslo +fi if [ $pylint -eq 1 ]; then run_pylint exit 0 diff --git a/tox.ini b/tox.ini index d6f2b9ef..a28d7fa0 100644 --- a/tox.ini +++ b/tox.ini @@ -19,7 +19,7 @@ commands = stestr run --slowest {posargs} [testenv:pep8] basepython = python2.7 commands = flake8 - {toxinidir}/tools/coding-checks.sh --pylint '{posargs}' + {toxinidir}/tools/coding-checks.sh --all '{posargs}' [testenv:venv] commands = {posargs}