From a880634a6f39aac6e36e4442b825f235eb32a1d1 Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Mon, 27 May 2019 04:54:26 +0200 Subject: [PATCH] Automatically select python version on scenario and fucntional tests Change-Id: I6da8e7fd15f913758c562bcc5aa7baca6a9692a2 --- roles/run-tox/defaults/main.yaml | 2 +- roles/run-tox/tasks/main.yaml | 2 +- tools/ci/tox | 23 +++++++++++++++++++++++ tox.ini | 2 -- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100755 tools/ci/tox diff --git a/roles/run-tox/defaults/main.yaml b/roles/run-tox/defaults/main.yaml index 47a02d3d2..9cbcb4b27 100644 --- a/roles/run-tox/defaults/main.yaml +++ b/roles/run-tox/defaults/main.yaml @@ -1,3 +1,3 @@ tox_dir: /opt/stack/tobiko -tox_envlist: neutron +tox_envlist: scenario tox_extra_args: '' diff --git a/roles/run-tox/tasks/main.yaml b/roles/run-tox/tasks/main.yaml index 0d22f0403..32a555850 100644 --- a/roles/run-tox/tasks/main.yaml +++ b/roles/run-tox/tasks/main.yaml @@ -1,5 +1,5 @@ - name: Run Tobiko - command: tox -e {{tox_envlist}} {{tox_extra_args}} + command: tools/ci/tox -e {{tox_envlist}} {{tox_extra_args}} args: chdir: "{{tox_dir}}" become: true diff --git a/tools/ci/tox b/tools/ci/tox new file mode 100755 index 000000000..b26e314ff --- /dev/null +++ b/tools/ci/tox @@ -0,0 +1,23 @@ +#!/bin/bash + +set -eux + +# Prefer python3 on python2 +PYTHON=$(which python3 || which python) + +# Create a virtualenv for executing Tox and activate it +BASE_VIRTUALENV_DIR=.tox/base +if ! [ -d "${BASE_VIRTUALENV_DIR}" ]; then + "${PYTHON}" -m virtualenv "${BASE_VIRTUALENV_DIR}" + set +eux + source "${BASE_VIRTUALENV_DIR}/bin/activate" + set -eux + curl https://bootstrap.pypa.io/get-pip.py | python + pip install --upgrade setuptools wheel virtualenv tox +else + set +eux + source "${BASE_VIRTUALENV_DIR}/bin/activate" + set -eux +fi + +tox "$*" diff --git a/tox.ini b/tox.ini index 45f57c9de..151c9be44 100644 --- a/tox.ini +++ b/tox.ini @@ -38,7 +38,6 @@ commands = {[base]commands} [testenv:cover] -basepython = python3 setenv = {[testenv]setenv} PYTHON=coverage run --parallel-mode @@ -106,7 +105,6 @@ commands = {[base]commands} [testenv:functional] -basepython = python3 deps = {[openstack]deps} passenv = {[openstack]passenv} setenv = {[openstack]setenv}