gitlab-ci: handle the defconfig build conditions in script
authorYann E. MORIN <yann.morin.1998@free.fr>
Sun, 6 Sep 2020 20:12:22 +0000 (22:12 +0200)
committerYann E. MORIN <yann.morin.1998@free.fr>
Wed, 9 Sep 2020 07:24:18 +0000 (09:24 +0200)
Note that we do not propagate the existing comment, because it is
partially wrong; instead we just keep the per-condition comments.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Romain Naour <romain.naour@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
Reviewed-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
support/misc/gitlab-ci.yml.in
support/scripts/generate-gitlab-ci-yml

index f00c764aaffefef2cef2b82e2e71306a389556f9..7f2ae3272562c08cd85c4cdf512a57530ca88ded 100644 (file)
@@ -67,15 +67,6 @@ check-package:
 
 .defconfig:
     extends: .defconfig_base
-    # Running the defconfigs for every push is too much, so limit to
-    # explicit triggers through the API.
-    rules:
-        # For tags, create a pipeline.
-        - if: '$CI_COMMIT_TAG'
-        # For pipeline created by using a trigger token.
-        - if: '$CI_PIPELINE_TRIGGERED'
-        # For the branch or tag name named *-defconfigs, create a pipeline.
-        - if: '$CI_COMMIT_REF_NAME =~ /^.*-defconfigs$/'
     before_script:
         - DEFCONFIG_NAME=${CI_JOB_NAME}
 
index b076b01d0529299b70c0bf01e649b33afb6c2d72..ed56a516a7c23abae4ee63cf93e66fb489bcd4c8 100755 (executable)
@@ -7,11 +7,7 @@ main() {
 
     preamble "${template}"
 
-    (
-        cd configs
-        LC_ALL=C ls -1 *_defconfig
-    ) \
-    | sed -r -e 's/^(.+)$/\1: { extends: .defconfig }\n\1_check: { extends: .defconfig_check }/'
+    gen_defconfigs
 
     ./support/testing/run-tests -l 2>&1 \
     | sed -r -e '/^test_run \((.*)\).*/!d; s//\1: { extends: .runtime_test }/' \
@@ -30,4 +26,32 @@ preamble() {
 _EOF_
 }
 
+gen_defconfigs() {
+    local -a defconfigs
+    local build_defconfigs cfg
+
+    defconfigs=( $(cd configs; LC_ALL=C ls -1 *_defconfig) )
+
+    build_defconfigs=false
+    if [ -n "${CI_COMMIT_TAG}" ]; then
+        # For tags, create a pipeline.
+        build_defconfigs=true
+    fi
+    if [ -n "${CI_PIPELINE_TRIGGERED}" ]; then
+        # For pipeline created by using a trigger token.
+        build_defconfigs=true
+    fi
+    case "${CI_COMMIT_REF_NAME}" in
+        # For the branch or tag name named *-defconfigs, create a pipeline.
+        (*-defconfigs) build_defconfigs=true;;
+    esac
+
+    for cfg in "${defconfigs[@]}"; do
+        printf '%s_check: { extends: .defconfig_check }\n' "${cfg}"
+        if ${build_defconfigs}; then
+            printf '%s: { extends: .defconfig }\n' "${cfg}"
+        fi
+    done
+}
+
 main "${@}"