gitlab-ci: handle the run-time tests conditions in script
authorYann E. MORIN <yann.morin.1998@free.fr>
Sun, 6 Sep 2020 20:12:24 +0000 (22:12 +0200)
committerYann E. MORIN <yann.morin.1998@free.fr>
Wed, 9 Sep 2020 07:24:58 +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 7f2ae3272562c08cd85c4cdf512a57530ca88ded..c6c4d35a0c86c1bd439b50c2097fff5e4199746e 100644 (file)
@@ -96,15 +96,6 @@ one-defconfig:
 
 .runtime_test:
     extends: .runtime_test_base
-    # Running the runtime tests 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 *-runtime-tests, create a pipeline.
-        - if: '$CI_COMMIT_REF_NAME =~ /^.*-runtime-tests$/'
     before_script:
         - TEST_CASE_NAME=${CI_JOB_NAME}
 
index 23db376944dd7bc19a552c5b7de0742257174593..21963b29758052f4aec83c127c904382b3948033 100755 (executable)
@@ -8,10 +8,7 @@ main() {
     preamble "${template}"
 
     gen_defconfigs
-
-    ./support/testing/run-tests -l 2>&1 \
-    | sed -r -e '/^test_run \((.*)\).*/!d; s//\1: { extends: .runtime_test }/' \
-    | LC_ALL=C sort
+    gen_tests
 }
 
 preamble() {
@@ -55,4 +52,32 @@ gen_defconfigs() {
     done
 }
 
+gen_tests() {
+    local -a tests
+    local run_tests tst
+
+    tests=( $(./support/testing/run-tests -l 2>&1 \
+              | sed -r -e '/^test_run \((.*)\).*/!d; s//\1/'\
+              | LC_ALL=C sort)
+          )
+
+    run_tests=false
+    if [ -n "${CI_COMMIT_TAG}" ]; then
+        # For tags, create a pipeline.
+        run_tests=true
+    fi
+    if [ -n "${CI_PIPELINE_TRIGGERED}" ]; then
+        # For pipeline created by using a trigger token.
+        run_tests=true
+    fi
+    case "${CI_COMMIT_REF_NAME}" in
+        # For the branch or tag name named *-runtime-tests, create a pipeline.
+        (*-runtime-tests) run_tests=true;;
+    esac
+
+    if ${run_tests}; then
+        printf '%s: { extends: .runtime_test }\n' "${tests[@]}"
+    fi
+}
+
 main "${@}"