2 # COPYRIGHT NOTICE STARTS HERE
4 # Copyright 2018 © Samsung Electronics Co., Ltd.
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # COPYRIGHT NOTICE ENDS HERE
19 ###############################################################################
20 # This script performs Jenkins Change Verification for ONAP Offline Installer #
21 # No parameters are expected #
22 ###############################################################################
24 function prep_ubuntu_16_04_for_molecule() {
25 sudo killall apt apt-get
26 sudo apt-get --assume-yes install software-properties-common
27 sudo add-apt-repository --yes ppa:deadsnakes/ppa
29 sudo apt install --assume-yes python3.6
30 sudo apt install --assume-yes python3.6-venv
33 function run_molecule() {
34 prep_ubuntu_16_04_for_molecule
37 for role in ${roles[@]}
39 if `find ${role} -name molecule.yml | grep -q '.*'`; then
40 ./ansible/test/bin/ci-molecule.sh ${role}
42 if [ ${MOLECULE_RC} -ne "0" ]; then FAILED_ROLES+=(${role}); fi
44 echo "[WARNING] ---------- THERE ARE NO TESTS DEFINED FOR ${role} ----------"
49 #######################################################################$
51 #######################################################################$
54 #if ansible role was changed$$
55 ROLE_CHANGES=(`git diff HEAD^ HEAD --name-only | grep "ansible/role" | cut -f 1-3 -d "/" | sort -u`)
56 if [ -z "${ROLE_CHANGES}" ]; then
57 echo "NO ANSIBLE ROLE TESTS REQUIRED"
59 run_molecule "${ROLE_CHANGES[@]}"
62 #if ansible was changed
64 if `git diff HEAD^ HEAD --name-only | grep -q "ansible/test"`; then
65 PLAYBOOKS=(`find ansible/test -name "play-*"`)
66 run_molecule "${PLAYBOOKS[@]}"
68 echo "NO FULL ANSIBLE TEST REQUIRED";
73 if `git diff HEAD^ HEAD --name-only | grep -q "build"`; then
74 echo "TO DO: BUILD TEST" ;
76 echo "NO BUILD TEST REQUIRED"
79 #if documentation was changed
81 if `git diff HEAD^ HEAD --name-only | grep -q "docs"`; then
82 echo "TO DO: DOC TEST";
84 echo "NO DOC TEST REQUIRED"
89 if [ -z ${FAILED_ROLES} ]; then
90 echo "All verification steps passed"
92 echo "Verification failed for ${FAILED_ROLES[*]}"