summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.com>2017-11-22 19:51:31 +0100
committerAndreas Jaeger <jaegerandi@gmail.com>2017-11-23 11:35:30 +0000
commit804206bb9c8af5c1d4f540664a6f9b36d45696e6 (patch)
treea6e11fe4e3c03c76de7a2e4d07fddba0bcb28716
parent00c241d97bd3a116513580cfe8006480723d7c17 (diff)
Align tox_install.sh with other projectsstable/pike
The tox_install.sh here behaves a bit differently than the others, which is causing some problems when trying to rework some of the shared gate jobs. Align it to the form used in other repos. Change-Id: I93d14b522b2c55e8988c6586e4b5c32cbd151e56
Notes
Notes (review): Code-Review+1: Luigi Toscano <ltoscano@redhat.com> Code-Review+2: Telles Mota Vidal Nóbrega <tenobreg@redhat.com> Workflow+1: Telles Mota Vidal Nóbrega <tenobreg@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 23 Nov 2017 21:01:54 +0000 Reviewed-on: https://review.openstack.org/522523 Project: openstack/sahara-dashboard Branch: refs/heads/stable/pike
-rwxr-xr-xtools/tox_install.sh124
-rw-r--r--tox.ini3
2 files changed, 53 insertions, 74 deletions
diff --git a/tools/tox_install.sh b/tools/tox_install.sh
index 2075924..7890956 100755
--- a/tools/tox_install.sh
+++ b/tools/tox_install.sh
@@ -1,85 +1,65 @@
1#!/usr/bin/env bash 1#!/usr/bin/env bash
2 2
3# Client constraint file contains this client version pin that is in conflict 3# Many of neutron's repos suffer from the problem of depending on neutron,
4# with installing the client from source. We should remove the version pin in 4# but it not existing on pypi.
5# the constraints file before applying it for from-source installation.
6# The script also has a secondary purpose to install certain special
7# dependencies directly from git.
8 5
9# Wrapper for pip install that always uses constraints. 6# This wrapper for tox's package installer will use the existing package
10function pip_install() { 7# if it exists, else use zuul-cloner if that program exists, else grab it
11 pip install -c"$localfile" -U "$@" 8# from neutron master via a hard-coded URL. That last case should only
12} 9# happen with devs running unit tests locally.
13 10
14# Grab the library from git using either zuul-cloner or pip. The former is 11# From the tox.ini config page:
15# there to a take advantage of the setup done by the gate infrastructure 12# install_command=ARGV
16# and honour any/all Depends-On headers in the commit message 13# default:
17function install_from_git() { 14# pip install {opts} {packages}
18 ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner
19 GIT_HOST=git.openstack.org
20 PROJ=$1
21 EGG=$2
22 15
23 edit-constraints "$localfile" -- "$EGG" 16ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner
24 if [ -x "$ZUUL_CLONER" ]; then 17BRANCH_NAME=master
25 SRC_DIR="$VIRTUAL_ENV/src" 18GIT_BASE=${GIT_BASE:-https://git.openstack.org/}
26 mkdir -p "$SRC_DIR"
27 cd "$SRC_DIR" >/dev/null
28 ZUUL_CACHE_DIR=${ZUUL_CACHE_DIR:-/opt/git} $ZUUL_CLONER \
29 --branch "$BRANCH_NAME" \
30 "git://$GIT_HOST" "$PROJ"
31 pip_install -e "$PROJ/."
32 cd - >/dev/null
33 else
34 pip_install -e"git+https://$GIT_HOST/$PROJ@$BRANCH_NAME#egg=${EGG}"
35 fi
36}
37 19
20install_project() {
21 local project=$1
22 local branch=${2:-$BRANCH_NAME}
23 local module_name=${project//-/_}
38 24
25 set +e
26 project_installed=$(echo "import $module_name" | python 2>/dev/null ; echo $?)
27 set -e
39 28
40CONSTRAINTS_FILE="$1" 29 if [ $project_installed -eq 0 ]; then
41shift 1 30 echo "ALREADY INSTALLED" > /tmp/tox_install.txt
31 echo "$project already installed; using existing package"
32 elif [ -x "$ZUUL_CLONER" ]; then
33 echo "ZUUL CLONER" > /tmp/tox_install.txt
34 # Make this relative to current working directory so that
35 # git clean can remove it. We cannot remove the directory directly
36 # since it is referenced after $install_cmd -e
37 mkdir -p .tmp
38 PROJECT_DIR=$(/bin/mktemp -d -p $(pwd)/.tmp)
39 pushd $PROJECT_DIR
40 $ZUUL_CLONER --cache-dir \
41 /opt/git \
42 --branch $branch \
43 http://git.openstack.org \
44 openstack/$project
45 cd openstack/$project
46 $install_cmd -e .
47 popd
48 else
49 echo "PIP HARDCODE" > /tmp/tox_install.txt
50 local GIT_REPO="$GIT_BASE/openstack/$project"
51 SRC_DIR="$VIRTUAL_ENV/src/$project"
52 git clone --depth 1 --branch $branch $GIT_REPO $SRC_DIR
53 $install_cmd -U -e $SRC_DIR
54 fi
55}
42 56
43# This script will either complete with a return code of 0 or the return code
44# of whatever failed.
45set -e 57set -e
46 58
47# NOTE(tonyb): Place this in the tox environment's log dir so it will get 59install_cmd="pip install -c$1"
48# published to logs.openstack.org for easy debugging. 60shift
49mkdir -p "$VIRTUAL_ENV/log/"
50localfile="$VIRTUAL_ENV/log/upper-constraints.txt"
51
52if [[ "$CONSTRAINTS_FILE" != http* ]]; then
53 CONSTRAINTS_FILE="file://$CONSTRAINTS_FILE"
54fi
55# NOTE(tonyb): need to add curl to bindep.txt if the project supports bindep
56curl "$CONSTRAINTS_FILE" --insecure --progress-bar --output "$localfile"
57
58pip_install openstack-requirements
59
60# This is the main purpose of the script: Allow local installation of
61# the current repo. It is listed in constraints file and thus any
62# install will be constrained and we need to unconstrain it.
63edit-constraints "$localfile" -- "$CLIENT_NAME"
64 61
65declare -a passthrough_args 62install_project horizon
66while [ $# -gt 0 ] ; do
67 case "$1" in
68 # If we have any special os:<repo_name:<egg_name> deps then process them
69 os:*)
70 declare -a pkg_spec
71 IFS=: pkg_spec=($1)
72 install_from_git "${pkg_spec[1]}" "${pkg_spec[2]}"
73 ;;
74 # Otherwise just pass the other deps through to the constrained pip install
75 *)
76 passthrough_args+=("$1")
77 ;;
78 esac
79 shift 1
80done
81 63
82# If *only* had special args then then isn't any need to run pip. 64$install_cmd -U $*
83if [ -n "$passthrough_args" ] ; then 65exit $?
84 pip_install "${passthrough_args[@]}"
85fi
diff --git a/tox.ini b/tox.ini
index c90e0aa..35f93b9 100644
--- a/tox.ini
+++ b/tox.ini
@@ -12,7 +12,6 @@ setenv =
12 CLIENT_NAME=sahara-dashboard 12 CLIENT_NAME=sahara-dashboard
13deps = -r{toxinidir}/requirements.txt 13deps = -r{toxinidir}/requirements.txt
14 -r{toxinidir}/test-requirements.txt 14 -r{toxinidir}/test-requirements.txt
15 os:openstack/horizon:horizon
16whitelist_externals = /bin/bash 15whitelist_externals = /bin/bash
17commands = /bin/bash run_tests.sh -N --no-pep8 {posargs} 16commands = /bin/bash run_tests.sh -N --no-pep8 {posargs}
18 17
@@ -71,7 +70,7 @@ show-source = True
71ignore = E123,E125,H405 70ignore = E123,E125,H405
72enable-extensions = H203,H106 71enable-extensions = H203,H106
73builtins = _ 72builtins = _
74exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.ropeproject,tools 73exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.ropeproject,tools,.tmp
75 74
76[testenv:bindep] 75[testenv:bindep]
77# Do not install any requirements. We want this to be fast and work even if 76# Do not install any requirements. We want this to be fast and work even if