Merge "Updating docker images list in El Alto" into elalto
[oom/offline-installer.git] / offline-installer-review.sh
1 #! /usr/bin/env bash
2 #   COPYRIGHT NOTICE STARTS HERE
3 #
4 #   Copyright 2018 © Samsung Electronics Co., Ltd.
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 #   COPYRIGHT NOTICE ENDS HERE
19 ###############################################################################
20 # This script performs Jenkins Change Verification for ONAP Offline Installer #
21 # No parameters are expected                                                  #
22 ###############################################################################
23
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
28   sudo apt update
29   sudo apt install --assume-yes python3.6
30   sudo apt install --assume-yes python3.6-venv
31 }
32
33 function run_molecule() {
34   prep_ubuntu_16_04_for_molecule
35   local roles=("$@")
36   local MOLECULE_RC
37   for role in ${roles[@]}
38     do
39       if `find ${role} -name molecule.yml | grep -q '.*'`; then
40         ./ansible/test/bin/ci-molecule.sh ${role}
41         MOLECULE_RC=$?
42         if [ ${MOLECULE_RC} -ne "0" ]; then FAILED_ROLES+=(${role}); fi
43       else
44         echo "[WARNING] ---------- THERE ARE NO TESTS DEFINED FOR  ${role} ----------"
45       fi
46   done
47 }
48
49 #######################################################################$
50 #                           MAIN                                      #$
51 #######################################################################$
52 FAILED_ROLES=()
53
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"
58 else
59   run_molecule "${ROLE_CHANGES[@]}"
60 fi
61
62 #if ansible was changed
63
64 if `git diff  HEAD^ HEAD --name-only | grep -q "ansible/test"`; then
65   PLAYBOOKS=(`find ansible/test -name "play-*"`)
66   run_molecule "${PLAYBOOKS[@]}"
67 else
68   echo "NO FULL ANSIBLE TEST REQUIRED";
69 fi
70
71 #if build was changed
72
73 if `git diff  HEAD^ HEAD --name-only | grep -q "build"`; then
74   echo "TO DO: BUILD TEST" ;
75 else
76   echo "NO BUILD TEST REQUIRED"
77 fi
78
79 #if documentation was changed
80
81 if `git diff  HEAD^ HEAD --name-only | grep -q "docs"`; then
82   echo "TO DO: DOC TEST";
83 else
84   echo "NO DOC TEST REQUIRED"
85 fi
86
87 #SUMMARY RESULTS
88
89 if [ -z ${FAILED_ROLES}  ]; then
90   echo "All verification steps passed"
91 else
92   echo "Verification failed for ${FAILED_ROLES[*]}"
93   exit 1
94 fi
95