support/scripts: prioritize conditions for pipeline creation
authorYann E. MORIN <yann.morin.1998@free.fr>
Mon, 21 Sep 2020 21:08:41 +0000 (23:08 +0200)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Tue, 22 Sep 2020 19:29:39 +0000 (21:29 +0200)
When multiple conditions match simultaneously, even though that should
not happen in practice, we want the more "important" one to win over
the less "important" ones. For example, a tag is more important than a
branch name or a trigger.

Currently, the latest condition to match takes precendence over any
previous one, while we want the exact opposite.

Fix that with proper fallbacks in else-blocks.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
support/scripts/generate-gitlab-ci-yml

index e42943953ca8c5c52dcf560a5fabf580ed07e454..faa52e85b27d5a74b40de4ca519ac839c19c2119 100755 (executable)
@@ -49,26 +49,26 @@ gen_defconfigs() {
     if [ -n "${CI_COMMIT_TAG}" ]; then
         # For tags, create a pipeline.
         template=base
-    fi
-    if [ -n "${CI_PIPELINE_TRIGGERED}" ]; then
+    elif [ -n "${CI_PIPELINE_TRIGGERED}" ]; then
         # For pipeline created by using a trigger token.
         template=base
+    else
+        case "${CI_COMMIT_REF_NAME}" in
+            # For master, next, and maintenance branches, only check the defconfigs
+            (master|next|????.??.x)
+                template=check
+                ext=_check
+            ;;
+            # For the branch or tag name named *-defconfigs, create a pipeline.
+            (*-defconfigs)
+                template=base
+            ;;
+            (*-*_defconfig)
+                defconfigs=( "${CI_COMMIT_REF_NAME##*-}" )
+                template=base
+            ;;
+        esac
     fi
-    case "${CI_COMMIT_REF_NAME}" in
-        # For master, next, and maintenance branches, only check the defconfigs
-        (master|next|????.??.x)
-            template=check
-            ext=_check
-        ;;
-        # For the branch or tag name named *-defconfigs, create a pipeline.
-        (*-defconfigs)
-            template=base
-        ;;
-        (*-*_defconfig)
-            defconfigs=( "${CI_COMMIT_REF_NAME##*-}" )
-            template=base
-        ;;
-    esac
 
     if [ -n "${template}" ]; then
         for cfg in "${defconfigs[@]}"; do
@@ -91,21 +91,21 @@ gen_tests() {
     if [ -n "${CI_COMMIT_TAG}" ]; then
         # For tags, create a pipeline.
         run_tests=true
-    fi
-    if [ -n "${CI_PIPELINE_TRIGGERED}" ]; then
+    elif [ -n "${CI_PIPELINE_TRIGGERED}" ]; then
         # For pipeline created by using a trigger token.
         run_tests=true
+    else
+        case "${CI_COMMIT_REF_NAME}" in
+            # For the branch or tag name named *-runtime-tests, create a pipeline.
+            (*-runtime-tests)
+                run_tests=true
+            ;;
+            (*-tests.*)
+                tests=( "${CI_COMMIT_REF_NAME##*-}" )
+                run_tests=true
+            ;;
+        esac
     fi
-    case "${CI_COMMIT_REF_NAME}" in
-        # For the branch or tag name named *-runtime-tests, create a pipeline.
-        (*-runtime-tests)
-            run_tests=true
-        ;;
-        (*-tests.*)
-            tests=( "${CI_COMMIT_REF_NAME##*-}" )
-            run_tests=true
-        ;;
-    esac
 
     if ${run_tests}; then
         printf '%s: { extends: .runtime_test_base }\n' "${tests[@]}"