blob: 3530d8f8eba6a29ae2662b2a57299a1565e21fd8 [file] [log] [blame]
Mateusz Pilat9c9be6f2019-05-06 17:12:36 +02001#! /usr/bin/env bash
Mateusz Pilat9c9be6f2019-05-06 17:12:36 +02002# 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
Mateusz Pilatb0f546a2019-05-08 13:33:46 +020019###############################################################################
20# This script performs Jenkins Change Verification for ONAP Offline Installer #
21# No parameters are expected #
22###############################################################################
Mateusz Pilat9c9be6f2019-05-06 17:12:36 +020023
Mateusz Pilatb0f546a2019-05-08 13:33:46 +020024function 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
33function 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#######################################################################$
52FAILED_ROLES=()
53
54#if ansible role was changed$$
55ROLE_CHANGES=(`git diff HEAD^ HEAD --name-only | grep "ansible/role" | cut -f 1-3 -d "/" | sort -u`)
56if [ -z "${ROLE_CHANGES}" ]; then
57 echo "NO ANSIBLE ROLE TESTS REQUIRED"
58else
59 run_molecule "${ROLE_CHANGES[@]}"
60fi
61
Mateusz Pilat9c9be6f2019-05-06 17:12:36 +020062#if ansible was changed
63
Mateusz Pilatb0f546a2019-05-08 13:33:46 +020064if `git diff HEAD^ HEAD --name-only | grep -q "ansible/test"`; then
65 PLAYBOOKS=(`find ansible/test -name "play-*"`)
66 run_molecule "${PLAYBOOKS[@]}"
67else
68 echo "NO FULL ANSIBLE TEST REQUIRED";
69fi
Mateusz Pilat9c9be6f2019-05-06 17:12:36 +020070
71#if build was changed
72
Mateusz Pilatb0f546a2019-05-08 13:33:46 +020073if `git diff HEAD^ HEAD --name-only | grep -q "build"`; then
74 echo "TO DO: BUILD TEST" ;
75else
76 echo "NO BUILD TEST REQUIRED"
77fi
Mateusz Pilat9c9be6f2019-05-06 17:12:36 +020078
79#if documentation was changed
80
Mateusz Pilatb0f546a2019-05-08 13:33:46 +020081if `git diff HEAD^ HEAD --name-only | grep -q "docs"`; then
82 echo "TO DO: DOC TEST";
83else
84 echo "NO DOC TEST REQUIRED"
85fi
86
87#SUMMARY RESULTS
88
89if [ -z ${FAILED_ROLES} ]; then
90 echo "All verification steps passed"
91else
92 echo "Verification failed for ${FAILED_ROLES[*]}"
93 exit 1
94fi
Mateusz Pilat9c9be6f2019-05-06 17:12:36 +020095