Align tox_install.sh with other projects
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: I49bb60a05cf63247091ee72591a799f6efc7c84b
This commit is contained in:
parent
a2f556e3f5
commit
9f52b6b7a9
|
@ -1,88 +1,65 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Client constraint file contains this client version pin that is in conflict
|
# Many of neutron's repos suffer from the problem of depending on neutron,
|
||||||
# with installing the client from source. We should remove the version pin in
|
# but it not existing on pypi.
|
||||||
# the constraints file before applying it for from-source installation.
|
|
||||||
# The script also has a secondary purpose to install certain special
|
|
||||||
# dependencies directly from git.
|
|
||||||
|
|
||||||
# Wrapper for pip install that always uses constraints.
|
# This wrapper for tox's package installer will use the existing package
|
||||||
function pip_install() {
|
# if it exists, else use zuul-cloner if that program exists, else grab it
|
||||||
pip install -c"$localfile" -U "$@"
|
# from neutron master via a hard-coded URL. That last case should only
|
||||||
}
|
# happen with devs running unit tests locally.
|
||||||
|
|
||||||
# Grab the library from git using either zuul-cloner or pip. The former is
|
# From the tox.ini config page:
|
||||||
# there to a take advantage of the setup done by the gate infrastructure
|
# install_command=ARGV
|
||||||
# and honour any/all Depends-On headers in the commit message
|
# default:
|
||||||
function install_from_git() {
|
# pip install {opts} {packages}
|
||||||
ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner
|
|
||||||
# GIT_HOST=git.openstack.org
|
|
||||||
GIT_HOST=github.com
|
|
||||||
PROJ=$1
|
|
||||||
EGG=$2
|
|
||||||
|
|
||||||
edit-constraints "$localfile" -- "$EGG"
|
ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner
|
||||||
if [ -x "$ZUUL_CLONER" ]; then
|
BRANCH_NAME=master
|
||||||
SRC_DIR="$VIRTUAL_ENV/src"
|
GIT_BASE=${GIT_BASE:-https://git.openstack.org/}
|
||||||
mkdir -p "$SRC_DIR"
|
|
||||||
cd "$SRC_DIR" >/dev/null
|
install_project() {
|
||||||
ZUUL_CACHE_DIR=${ZUUL_CACHE_DIR:-/opt/git} $ZUUL_CLONER \
|
local project=$1
|
||||||
--branch "$BRANCH_NAME" \
|
local branch=${2:-$BRANCH_NAME}
|
||||||
"git://$GIT_HOST" "$PROJ"
|
local module_name=${project//-/_}
|
||||||
pip_install -e "$PROJ/."
|
|
||||||
cd - >/dev/null
|
set +e
|
||||||
|
project_installed=$(echo "import $module_name" | python 2>/dev/null ; echo $?)
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ $project_installed -eq 0 ]; then
|
||||||
|
echo "ALREADY INSTALLED" > /tmp/tox_install.txt
|
||||||
|
echo "$project already installed; using existing package"
|
||||||
|
elif [ -x "$ZUUL_CLONER" ]; then
|
||||||
|
echo "ZUUL CLONER" > /tmp/tox_install.txt
|
||||||
|
# Make this relative to current working directory so that
|
||||||
|
# git clean can remove it. We cannot remove the directory directly
|
||||||
|
# since it is referenced after $install_cmd -e
|
||||||
|
mkdir -p .tmp
|
||||||
|
PROJECT_DIR=$(/bin/mktemp -d -p $(pwd)/.tmp)
|
||||||
|
pushd $PROJECT_DIR
|
||||||
|
$ZUUL_CLONER --cache-dir \
|
||||||
|
/opt/git \
|
||||||
|
--branch $branch \
|
||||||
|
http://git.openstack.org \
|
||||||
|
openstack/$project
|
||||||
|
cd openstack/$project
|
||||||
|
$install_cmd -e .
|
||||||
|
popd
|
||||||
else
|
else
|
||||||
SRC_DIR="$VIRTUAL_ENV/src/$PROJ"
|
echo "PIP HARDCODE" > /tmp/tox_install.txt
|
||||||
git clone --depth 1 --branch $BRANCH_NAME https://$GIT_HOST/$PROJ $SRC_DIR
|
local GIT_REPO="$GIT_BASE/openstack/$project"
|
||||||
pip_install -e $SRC_DIR
|
SRC_DIR="$VIRTUAL_ENV/src/$project"
|
||||||
|
git clone --depth 1 --branch $branch $GIT_REPO $SRC_DIR
|
||||||
|
$install_cmd -U -e $SRC_DIR
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CONSTRAINTS_FILE="$1"
|
|
||||||
shift 1
|
|
||||||
|
|
||||||
# This script will either complete with a return code of 0 or the return code
|
|
||||||
# of whatever failed.
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# NOTE(tonyb): Place this in the tox environment's log dir so it will get
|
install_cmd="pip install -c$1"
|
||||||
# published to logs.openstack.org for easy debugging.
|
shift
|
||||||
mkdir -p "$VIRTUAL_ENV/log/"
|
|
||||||
localfile="$VIRTUAL_ENV/log/upper-constraints.txt"
|
|
||||||
|
|
||||||
if [[ "$CONSTRAINTS_FILE" != http* ]]; then
|
install_project horizon
|
||||||
CONSTRAINTS_FILE="file://$CONSTRAINTS_FILE"
|
|
||||||
fi
|
|
||||||
# NOTE(tonyb): need to add curl to bindep.txt if the project supports bindep
|
|
||||||
curl "$CONSTRAINTS_FILE" --insecure --progress-bar --output "$localfile"
|
|
||||||
|
|
||||||
pip_install openstack-requirements
|
$install_cmd -U $*
|
||||||
|
exit $?
|
||||||
# This is the main purpose of the script: Allow local installation of
|
|
||||||
# the current repo. It is listed in constraints file and thus any
|
|
||||||
# install will be constrained and we need to unconstrain it.
|
|
||||||
edit-constraints "$localfile" -- "$CLIENT_NAME"
|
|
||||||
|
|
||||||
declare -a passthrough_args
|
|
||||||
while [ $# -gt 0 ] ; do
|
|
||||||
case "$1" in
|
|
||||||
# If we have any special os:<repo_name:<egg_name> deps then process them
|
|
||||||
os:*)
|
|
||||||
declare -a pkg_spec
|
|
||||||
IFS=: pkg_spec=($1)
|
|
||||||
install_from_git "${pkg_spec[1]}" "${pkg_spec[2]}"
|
|
||||||
;;
|
|
||||||
# Otherwise just pass the other deps through to the constrained pip install
|
|
||||||
*)
|
|
||||||
passthrough_args+=("$1")
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift 1
|
|
||||||
done
|
|
||||||
|
|
||||||
# If *only* had special args then then isn't any need to run pip.
|
|
||||||
if [ -n "$passthrough_args" ] ; then
|
|
||||||
pip_install "${passthrough_args[@]}"
|
|
||||||
fi
|
|
||||||
|
|
4
tox.ini
4
tox.ini
|
@ -16,8 +16,6 @@ setenv = VIRTUAL_ENV={envdir}
|
||||||
install_command = {toxinidir}/tools/tox_install.sh {env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
|
install_command = {toxinidir}/tools/tox_install.sh {env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
|
||||||
deps = -r{toxinidir}/requirements.txt
|
deps = -r{toxinidir}/requirements.txt
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
# os:* is handled by tox_install.sh
|
|
||||||
os:openstack/horizon:horizon
|
|
||||||
commands = python manage.py test {posargs} --settings=castellan_ui.test.settings
|
commands = python manage.py test {posargs} --settings=castellan_ui.test.settings
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
|
@ -66,5 +64,5 @@ commands = python setup.py build_sphinx
|
||||||
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,node_modules
|
exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,node_modules,.tmp
|
||||||
max-complexity = 20
|
max-complexity = 20
|
Loading…
Reference in New Issue