From a5d50dd3ed5fd331f75bd3563f37fdf97a117d4a Mon Sep 17 00:00:00 2001 From: Shu Muto Date: Wed, 25 Apr 2018 13:48:34 +0900 Subject: [PATCH] Fix tox jobs and remove tox_helper.sh Horizon plugins needs horizon on master branch for our master development and test. Recent changes in CI infra and horizon force to change horizon installation, and added tox_helper.sh as trivial fix. Now, reasonable fix found for horizon plugins, so this patch fixes them. Change-Id: Ieae9bfdfed113795c0a7065964781914a2d041ce Depends-On: I506e9c761ad1af3126db2c4778aa9dbbcf340130 --- .zuul.yaml | 8 +++- magnum_ui/karma.conf.js | 2 +- package.json | 2 +- tools/tox_helper.sh | 20 --------- tox.ini | 98 +++++++++++++++++++++++++++-------------- 5 files changed, 72 insertions(+), 58 deletions(-) delete mode 100755 tools/tox_helper.sh diff --git a/.zuul.yaml b/.zuul.yaml index 67a39c42..737eaf35 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,7 +1,11 @@ - project: check: jobs: - - openstack-tox-lower-constraints + - openstack-tox-lower-constraints: + required-projects: + - openstack/horizon gate: jobs: - - openstack-tox-lower-constraints + - openstack-tox-lower-constraints: + required-projects: + - openstack/horizon diff --git a/magnum_ui/karma.conf.js b/magnum_ui/karma.conf.js index 80b88065..1a4543db 100644 --- a/magnum_ui/karma.conf.js +++ b/magnum_ui/karma.conf.js @@ -19,7 +19,7 @@ var path = require('path'); module.exports = function (config) { // This tox venv is setup in the post-install npm step - var toxPath = '../.tox/karma/lib/python2.7/site-packages/'; + var toxPath = '../.tox/karma/lib/python3.5/site-packages/'; process.env.PHANTOMJS_BIN = 'node_modules/phantomjs-prebuilt/bin/phantomjs'; diff --git a/package.json b/package.json index c67d54ac..9ad611b5 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ }, "dependencies": {}, "scripts": { - "postinstall": "if [ ! -d .tox ] || [ ! -d .tox/karma ]; then tox -ekarma --notest; git clone https://git.openstack.org/openstack/horizon.git .tox/karma/src/horizon; pip install -U -t .tox/karma/lib/python2.7/site-packages/ .tox/karma/src/horizon; fi", + "postinstall": "if [ ! -d .tox ] || [ ! -d .tox/karma ]; then tox -ekarma --notest; pip install -U -t ./.tox/karma/lib/python3.5/site-packages/ ../horizon; fi", "lint": "eslint --no-color magnum_ui/static", "lintq": "eslint --quiet magnum_ui/static", "test": "karma start magnum_ui/karma.conf.js --single-run" diff --git a/tools/tox_helper.sh b/tools/tox_helper.sh deleted file mode 100755 index 8549089e..00000000 --- a/tools/tox_helper.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -ENVNAME=$1 -BASEPYTHON=$2 -COMMAND=$3 - -if [ ${COMMAND} = "pre" ]; then - # crean-up - rm -fr .tox/${ENVNAME}-log/ - # install horizon from git - rm -fr .tox/${ENVNAME}/src/ - git clone https://git.openstack.org/openstack/horizon.git .tox/${ENVNAME}/src/horizon - pip install -U -t .tox/${ENVNAME}/lib/${BASEPYTHON}/site-packages/ .tox/${ENVNAME}/src/horizon -elif [ ${COMMAND} = "post" ]; then - # crean-up - rm -fr .tox/${ENVNAME}/src/ - mv .tox/${ENVNAME}/log/ .tox/${ENVNAME}-log/ - rm -fr .tox/${ENVNAME}/ -fi - diff --git a/tox.ini b/tox.ini index 9a8ae06b..76142afe 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pep8,py35,py35dj20,py27,eslint,karma,docs,releasenotes +envlist = pep8,py27-local,py35-local,py35dj20-local,eslint,karma-local,docs-local,releasenotes,lower-constraints-local minversion = 2.3.2 skipsdist = True @@ -15,12 +15,20 @@ deps = -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -commands = python manage.py test {posargs} --settings=magnum_ui.test.settings +commands = + python manage.py test {posargs} --settings=magnum_ui.test.settings + +# For installation of horizon on local +# NOTICE: this tox.ini requires horizon repository cloned in sibling directory. +[testenv:hz-local] +commands = + pip install -e ../horizon [testenv:venv] commands = {posargs} [testenv:pep8] +basepython = python3.5 commands = flake8 {posargs} [flake8] @@ -34,68 +42,81 @@ commands = coverage xml --omit '.tox/cover/*' -o 'cover/coverage.xml' coverage html --omit '.tox/cover/*' -d 'cover/htmlcov' +# NOTE(shu-mutow): On CI infra, horizon will be installed +# according to job setting. but on local, we need to install +# horizon from master branch. [testenv:py27] -commands = - # Clean-up env and install horizon from git - {toxinidir}/tools/tox_helper.sh {envname} {basepython} pre - # Run test - python manage.py test {posargs} - # Clean-up env except log - {toxinidir}/tools/tox_helper.sh {envname} {basepython} post +basepython = python2.7 -[testenv:py35] +[testenv:py27-local] +basepython = python2.7 +commands = + {[testenv:hz-local]commands} + {[testenv]commands} + +[testenv:py35-local] basepython = python3.5 commands = - # Clean-up env and install horizon from git - {toxinidir}/tools/tox_helper.sh {envname} {basepython} pre - # Run test - python manage.py test {posargs} - # Clean-up env except log - {toxinidir}/tools/tox_helper.sh {envname} {basepython} post + {[testenv:hz-local]commands} + {[testenv]commands} [testenv:py35dj20] basepython = python3.5 commands = - # Clean-up env and install horizon from git - {toxinidir}/tools/tox_helper.sh {envname} {basepython} pre - # Run test - pip install django>=2.0,<2.1 - python manage.py test {posargs} - # Clean-up env except log - {toxinidir}/tools/tox_helper.sh {envname} {basepython} post + {[testenv:hz-local]commands} + {[testenv]commands} + +[testenv:py35dj20-local] +basepython = python3.5 +commands = + {[testenv:hz-local]commands} + pip install -U django>=2.0,<2.1 + {[testenv]commands} [testenv:eslint] +basepython = python3.5 whitelist_externals = npm commands = - # Clean-up env and install horizon from git - {toxinidir}/tools/tox_helper.sh {envname} {basepython} pre - # Run test npm install npm run lint - # Clean-up env except log - {toxinidir}/tools/tox_helper.sh {envname} {basepython} post +# NOTE(shu-mutow): The "postinstall" script on package.json will install horizon +# from master branch into karma environment with py35 for testing javascripts. +# Horizon from master is needed to be cloned into ../horizon on both local and CI. [testenv:karma] +basepython = python3.5 whitelist_externals = - npm + {[testenv:eslint]whitelist_externals} commands = - # Clean-up env and install horizon from git - {toxinidir}/tools/tox_helper.sh {envname} {basepython} pre - # Run test npm install npm run test - # Clean-up env except log - {toxinidir}/tools/tox_helper.sh {envname} {basepython} post + +[testenv:karma-local] +basepython = python3.5 +whitelist_externals = + {[testenv:eslint]whitelist_externals} +commands = + {[testenv:karma]commands} [testenv:docs] +basepython = python3.5 deps = -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} -r{toxinidir}/doc/requirements.txt commands= sphinx-build -W -b html doc/source doc/build/html +[testenv:docs-local] +basepython = python3.5 +deps = + {[testenv:docs]deps} +commands= + {[testenv:hz-local]commands} + {[testenv:docs]commands} + [testenv:releasenotes] +basepython = python3.5 deps = {[testenv:docs]deps} commands = @@ -107,3 +128,12 @@ deps = -c{toxinidir}/lower-constraints.txt -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt + +[testenv:lower-constraints-local] +basepython = python3 +deps = + {[testenv:lower-constraints]deps} +commands = + {[testenv:hz-local]commands} + {[testenv]commands} +