jjb: xci: Only set default scenario if no scenario is set 65/55065/1
authorMarkos Chandras <mchandras@suse.de>
Fri, 6 Apr 2018 14:30:17 +0000 (15:30 +0100)
committerMarkos Chandras <mchandras@suse.de>
Fri, 6 Apr 2018 14:33:28 +0000 (15:33 +0100)
Previously, the code was already setting the default scenario if we had
changes outside the xci/scenario directory. However, this is somewhat
problematic since scenarios may touch other files which do not necessary
affect other scenarios such as anything in xci/playbooks etc. As such,
lets only set a default scenario if no scenario was set up to that
point. However, since installers and scenarios need to match, we also
need to consider installer changes because we fallback to the default
scenario. Finally, since we are filtering results with 'uniq' we can
simply drop the bash regexps prior to adding the scenario to the array.

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

index 3e64ab1..9cb9407 100755 (executable)
@@ -97,22 +97,26 @@ function determine_generic_scenario() {
     # get the changeset
     cd $WORKSPACE
     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)
+    # We need to set default scenario for changes that mess with installers
+    INSTALLERS=$(git diff HEAD^..HEAD --name-only -- 'xci/installer' | cut -d "/" -f 3 | uniq)
     for CHANGED_SCENARIO in $SCENARIOS; do
-        [[ ${DEPLOY_SCENARIO[@]} =~ $CHANGED_SCENARIO ]] || DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]=$CHANGED_SCENARIO
+        DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]=$CHANGED_SCENARIO
     done
-    for CHANGED_FILE in $NO_SCENARIOS; do
-        case $CHANGED_FILE in
+    for CHANGED_INSTALLER in $INSTALLERS; do
+        case $CHANGED_INSTALLER in
             kubespray)
-                [[ ${DEPLOY_SCENARIO[@]} =~ "k8-nosdn-nofeature" ]] || DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]='k8-nosdn-nofeature'
+                DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]='k8-nosdn-nofeature'
                 ;;
             # Default case (including OSA changes)
             *)
-                [[ ${DEPLOY_SCENARIO[@]} =~ "os-nosdn-nofeature" ]] || DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]='os-nosdn-nofeature'
+                DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]='os-nosdn-nofeature'
                 ;;
         esac
     done
+    # For all other changes, we only need to set a default scenario if it's not set already
+    if git diff HEAD^..HEAD --name-only | grep -q -v 'xci/installer\|xci/scenario'; then
+         [[ ${#DEPLOY_SCENARIO[@]} -gt 0 ]] && DEPLOY_SCENARIO[${#DEPLOY_SCENARIO[@]}]='os-nosdn-nofeature'
+    fi
 
     # extract releng-xci sha
     XCI_SHA=$(cd $WORKSPACE && git rev-parse HEAD)