jjb: xci: xci-set-scenario: Allow automatic detection of generic scenarios 13/54913/4
authorMarkos Chandras <mchandras@suse.de>
Wed, 4 Apr 2018 16:19:43 +0000 (17:19 +0100)
committerMarkos Chandras <mchandras@suse.de>
Fri, 6 Apr 2018 08:28:21 +0000 (09:28 +0100)
The list of supported scenarios is hardcoded and this makes it difficult
to test new scenarios. As such, lets determine the scenario and the
installer based on the actual files that have been changed on every
patchset.

Change-Id: I4868a1da08d58cd6ff37347a0c0bc5c5e28b15bb
Signed-off-by: Markos Chandras <mchandras@suse.de>
jjb/xci/xci-set-scenario.sh

index c3012cd..3e64ab1 100755 (executable)
@@ -96,22 +96,22 @@ function determine_generic_scenario() {
 
     # get the changeset
     cd $WORKSPACE
-    CHANGESET=$(git diff HEAD^..HEAD --name-only)
-    for CHANGED_FILE in $CHANGESET; do
+    SCENARIOS=$(git diff HEAD^..HEAD --name-only -- 'xci/scenarios' | cut -d "/" -f 3 | uniq)
+    # We need to set default scenario for changes that do not mess with scenarios
+    NO_SCENARIOS=$(git diff HEAD^..HEAD --name-only | grep -v 'xci/scenarios' | cut -d "/" -f 3 | uniq)
+    for CHANGED_SCENARIO in $SCENARIOS; do
+        [[ ${DEPLOY_SCENARIO[@]} =~ $CHANGED_SCENARIO ]] || DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]=$CHANGED_SCENARIO
+    done
+    for CHANGED_FILE in $NO_SCENARIOS; do
         case $CHANGED_FILE in
-            *k8-nosdn*|*kubespray*)
+            kubespray)
                 [[ ${DEPLOY_SCENARIO[@]} =~ "k8-nosdn-nofeature" ]] || DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]='k8-nosdn-nofeature'
                 ;;
-            *os-odl*)
-                [[ ${DEPLOY_SCENARIO[@]} =~ "os-odl-nofeature" ]] || DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]='os-odl-nofeature'
-                ;;
-            *os-nosdn*|*osa*)
-                [[ ${DEPLOY_SCENARIO[@]} =~ "os-nosdn-nofeature" ]] || DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]='os-nosdn-nofeature'
-                ;;
+            # Default case (including OSA changes)
             *)
                 [[ ${DEPLOY_SCENARIO[@]} =~ "os-nosdn-nofeature" ]] || DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]='os-nosdn-nofeature'
                 ;;
-            esac
+        esac
     done
 
     # extract releng-xci sha