4 # vim: set ts=2 sw=2 expandtab:
7 # ============LICENSE_START=======================================================
8 # Copyright (C) 2019 The Nordix Foundation. All rights reserved.
9 # ================================================================================
10 # Licensed under the Apache License, Version 2.0 (the "License");
11 # you may not use this file except in compliance with the License.
12 # You may obtain a copy of the License at
14 # http://www.apache.org/licenses/LICENSE-2.0
16 # Unless required by applicable law or agreed to in writing, software
17 # distributed under the License is distributed on an "AS IS" BASIS,
18 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 # See the License for the specific language governing permissions and
20 # limitations under the License.
22 # SPDX-License-Identifier: Apache-2.0
23 # ============LICENSE_END=========================================================
29 # this function processes commit message to determine the impacted scenario
30 # using the input provided by the committer.
32 # installer type and scenario should be placed at the beginning of lines
33 # separately and the format of the entry in commit message is as below
35 # installer-type: <installer type>
36 # deploy-scenario: <scenario name>
40 # installer-type: kubespray
41 # deploy-scenario: k8-calico-nofeature
42 function override_installer_scenario() {
43 echo "Processing $GERRIT_PROJECT patchset $GERRIT_REFSPEC to determine the installer and the scenario"
45 COMMIT_MESSAGE=$(git show -s --format=%B)
47 if [[ "$COMMIT_MESSAGE" =~ "deploy-scenario:" && "$COMMIT_MESSAGE" =~ "installer-type:" ]]; then
48 export INSTALLER_TYPE=$(echo "$COMMIT_MESSAGE" | grep '^installer-type:' | cut -d":" -f2 | sed 's/\s*//g')
49 export DEPLOY_SCENARIO=$(echo "$COMMIT_MESSAGE" | grep '^deploy-scenario:' | cut -d":" -f2 | sed 's/\s*//g')
50 generate_temporary_sdf
52 echo "Installer type or deploy scenario is not specified."
53 echo "Falling back to programmatically determining them."
58 # this function will process the changed files to determine the impacted scenario
59 # if it is no specified by the committer. only one scenario per change should be
61 # TODO: this is not implented yet.
62 function determine_scenario() {
63 echo "Processing $GERRIT_PROJECT patchset $GERRIT_REFSPEC"
65 COMMIT_MESSAGE=$(git show -s --format=%B)
66 echo "Not implemented!"
70 # this function generates temporary sdf file with the details of the impacted
72 function generate_temporary_sdf() {
73 echo "Generating temporary SDF to use for verification"
74 cat << EOF > $WORKSPACE/sdf.yml
79 version: $GERRIT_PATCHSET_REVISION
80 refspec: $GERRIT_REFSPEC
83 role: scenarios/$DEPLOY_SCENARIO/$INSTALLER_TYPE/role/$DEPLOY_SCENARIO
89 echo "Determining the impacted scenario"
91 declare -a DEPLOY_SCENARIO
93 override_installer_scenario
94 generate_temporary_sdf
96 # execute cloud engine test.sh script with arguments
97 echo "Testing scenario $DEPLOY_SCENARIO deployed using $INSTALLER_TYPE"
98 cd $WORKSPACE && git clone -q $TEST_REPO_URL
100 ./test/test.sh -c -f $TEST_FW -t $TEST_SUITE -s $DEPLOY_SCENARIO
102 # vim: set ts=2 sw=2 expandtab: