Matthew Watkins | 8850db1 | 2022-12-16 18:01:56 +0000 | [diff] [blame^] | 1 | #!/bin/bash -x |
| 2 | # |
| 3 | # Copyright 2019-2021 Samsung Electronics Co., Ltd. |
| 4 | # Modifications Copyright (C) 2021 Pantheon.tech |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | # This script installs common libraries required by CSIT tests |
| 19 | # |
| 20 | |
| 21 | echo "---> prepare-csit.sh" |
| 22 | |
| 23 | set -exo pipefail |
| 24 | |
| 25 | ROBOT_INSTALLER='include-raw-integration-install-robotframework-py3.sh' |
| 26 | |
| 27 | if !(which git > /dev/null 2>&1); then |
| 28 | echo "GIT binary not found current PATH" |
| 29 | echo $PATH; exit 1 |
| 30 | fi |
| 31 | |
| 32 | if [ -z "$WORKSPACE" ]; then |
| 33 | # shellcheck disable=SC2155 |
| 34 | export WORKSPACE=`git rev-parse --show-toplevel` |
| 35 | fi |
| 36 | |
| 37 | # shellcheck disable=SC2034 |
| 38 | TESTPLANDIR=${WORKSPACE}/${TESTPLAN} |
| 39 | |
| 40 | # Python version should match that used to setup |
| 41 | # robot-framework in other jobs/stages |
| 42 | # Use pyenv for selecting the python version |
| 43 | if [[ -d "/opt/pyenv" ]]; then |
| 44 | echo "Setup pyenv:" |
| 45 | export PYENV_ROOT="/opt/pyenv" |
| 46 | export PATH="$PYENV_ROOT/bin:$PATH" |
| 47 | pyenv versions |
| 48 | if command -v pyenv 1>/dev/null 2>&1; then |
| 49 | eval "$(pyenv init - --no-rehash)" |
| 50 | # Choose the latest numeric Python version from installed list |
| 51 | version=$(pyenv versions --bare | sed '/^[^0-9]/d' \ |
| 52 | | sort -V | tail -n 1) |
| 53 | pyenv local "${version}" |
| 54 | fi |
| 55 | fi |
| 56 | |
| 57 | # Assume that if ROBOT3_VENV is set, virtualenv |
| 58 | # with system site packages can be activated |
| 59 | if [ -f ${WORKSPACE}/env.properties ]; then |
| 60 | source ${WORKSPACE}/env.properties |
| 61 | fi |
| 62 | if [ -f ${ROBOT3_VENV}/bin/activate ]; then |
| 63 | source ${ROBOT3_VENV}/bin/activate |
| 64 | else |
| 65 | # Robot framework was not found |
| 66 | # clone ci-management repository and use install script |
| 67 | git clone "https://gerrit.onap.org/r/ci-management" \ |
| 68 | /tmp/ci-management |
| 69 | source /tmp/ci-management/jjb/integration/${ROBOT_INSTALLER} |
| 70 | fi |
| 71 | |
| 72 | # install eteutils |
| 73 | mkdir -p ${ROBOT3_VENV}/src/onap |
| 74 | rm -rf ${ROBOT3_VENV}/src/onap/testsuite |
| 75 | # Source from the Nexus repository |
| 76 | python3 -m pip install --upgrade \ |
| 77 | --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" \ |
| 78 | 'robotframework-onap==11.0.0.dev17' \ |
| 79 | --pre |
| 80 | |
| 81 | echo "Versioning information:" |
| 82 | python3 --version |
| 83 | pip freeze |
| 84 | python3 -m robot.run --version || : |
| 85 | |