blob: 0db140ff78750d51afc185c1f90de48cbf5df42c [file] [log] [blame]
Matthew Watkins8850db12022-12-16 18:01:56 +00001#!/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
21echo "---> prepare-csit.sh"
22
23set -exo pipefail
24
25ROBOT_INSTALLER='include-raw-integration-install-robotframework-py3.sh'
26
Matthew Watkins795671a2023-01-04 11:29:33 +000027# Allows testing for root permissions
28REQ_USER=$(id -un)
29
30if ! (which git > /dev/null 2>&1); then
31 echo "GIT binary not found in current PATH"
32 # Add missing package to prevent script/job failures
33 if (grep Ubuntu /etc/os-release > /dev/null 2>&1) || \
34 (grep Debian /etc/os-release > /dev/null 2>&1); then
35 echo "Installing package dependency for Ubuntu/Debian"
36 if [[ "${REQ_USER}" == 'root' ]]; then
37 apt-get update
38 apt-get install -y git
39 else
40 sudo apt-get update
41 sudo apt-get install -y git
42 fi
43 elif (grep RedHat /etc/os-release > /dev/null 2>&1) || \
44 (grep CentOS /etc/os-release > /dev/null 2>&1); then
45 echo "Installing package dependency for CentOS/RedHat"
46 if [[ "${REQ_USER}" == 'root' ]]; then
47 yum install -y git
48 else
49 sudo yum install -y git
50 fi
51 else
52 echo "Warning: unmatched OS/distribution"
53 echo "Missing software will not be installed"
54 fi
Matthew Watkins8850db12022-12-16 18:01:56 +000055fi
56
Matthew Watkins795671a2023-01-04 11:29:33 +000057if [[ -z "${WORKSPACE}" ]]; then
58 if (git rev-parse --show-toplevel > /dev/null 2>&1); then
59 WORKSPACE=$(git rev-parse --show-toplevel)
60 export WORKSPACE
61 else
62 WORKSPACE=$(pwd)
63 export WORKSPACE
64 fi
Matthew Watkins8850db12022-12-16 18:01:56 +000065fi
66
67# shellcheck disable=SC2034
Matthew Watkins795671a2023-01-04 11:29:33 +000068TESTPLANDIR="${WORKSPACE}/${TESTPLAN}"
Matthew Watkins8850db12022-12-16 18:01:56 +000069
70# Python version should match that used to setup
71# robot-framework in other jobs/stages
72# Use pyenv for selecting the python version
73if [[ -d "/opt/pyenv" ]]; then
74 echo "Setup pyenv:"
75 export PYENV_ROOT="/opt/pyenv"
76 export PATH="$PYENV_ROOT/bin:$PATH"
77 pyenv versions
78 if command -v pyenv 1>/dev/null 2>&1; then
79 eval "$(pyenv init - --no-rehash)"
80 # Choose the latest numeric Python version from installed list
81 version=$(pyenv versions --bare | sed '/^[^0-9]/d' \
82 | sort -V | tail -n 1)
83 pyenv local "${version}"
84 fi
85fi
86
87# Assume that if ROBOT3_VENV is set, virtualenv
88# with system site packages can be activated
Matthew Watkins795671a2023-01-04 11:29:33 +000089if [[ -f "${WORKSPACE}/env.properties" ]]; then
90 source "${WORKSPACE}/env.properties"
91elif [[ -f /tmp/env.properties ]]; then
92 source /tmp/env.properties
Matthew Watkins8850db12022-12-16 18:01:56 +000093fi
Matthew Watkins795671a2023-01-04 11:29:33 +000094
95if [[ -f "${ROBOT3_VENV}/bin/activate" ]]; then
96 source "${ROBOT3_VENV}/bin/activate"
Matthew Watkins8850db12022-12-16 18:01:56 +000097else
98 # Robot framework was not found
99 # clone ci-management repository and use install script
100 git clone "https://gerrit.onap.org/r/ci-management" \
101 /tmp/ci-management
Matthew Watkins795671a2023-01-04 11:29:33 +0000102 # shellcheck disable=SC1090
103 source "/tmp/ci-management/jjb/integration/${ROBOT_INSTALLER}"
Matthew Watkins8850db12022-12-16 18:01:56 +0000104fi
105
106# install eteutils
Matthew Watkins795671a2023-01-04 11:29:33 +0000107mkdir -p "${ROBOT3_VENV}/src/onap"
108rm -rf "${ROBOT3_VENV}/src/onap/testsuite"
Matthew Watkins8850db12022-12-16 18:01:56 +0000109# Source from the Nexus repository
110python3 -m pip install --upgrade \
111 --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" \
112 'robotframework-onap==11.0.0.dev17' \
113 --pre
114
115echo "Versioning information:"
116python3 --version
117pip freeze
118python3 -m robot.run --version || :
119