diff mbox series

[03/10] gitlab-ci: handle the defconfig build conditions in script

Message ID 1f090850bcbbad6d3d8482949f54cebc9a129346.1599423132.git.yann.morin.1998@free.fr
State Accepted
Headers show
Series [01/10] gitlab-ci: introduce main() in generating script | expand

Commit Message

Yann E. MORIN Sept. 6, 2020, 8:12 p.m. UTC
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>
---
 support/misc/gitlab-ci.yml.in          |  9 -------
 support/scripts/generate-gitlab-ci-yml | 34 ++++++++++++++++++++++----
 2 files changed, 29 insertions(+), 14 deletions(-)

Comments

Romain Naour Sept. 8, 2020, 9:08 p.m. UTC | #1
Le 06/09/2020 à 22:12, Yann E. MORIN a écrit :
> 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>
> ---
>  support/misc/gitlab-ci.yml.in          |  9 -------
>  support/scripts/generate-gitlab-ci-yml | 34 ++++++++++++++++++++++----
>  2 files changed, 29 insertions(+), 14 deletions(-)
> 
> diff --git a/support/misc/gitlab-ci.yml.in b/support/misc/gitlab-ci.yml.in
> index f00c764aaf..7f2ae32725 100644
> --- a/support/misc/gitlab-ci.yml.in
> +++ b/support/misc/gitlab-ci.yml.in
> @@ -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}
>  
> diff --git a/support/scripts/generate-gitlab-ci-yml b/support/scripts/generate-gitlab-ci-yml
> index b076b01d05..ed56a516a7 100755
> --- a/support/scripts/generate-gitlab-ci-yml
> +++ b/support/scripts/generate-gitlab-ci-yml
> @@ -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

Indeed since the defconfig_check was introduced, defconfig_check jobs and
defconfig jobs is created in the same pipeline when a tag or a branch named
*-defconfigs is pushed in gitlab...

Hopefully this is fixed by the following patch of this series.

Reviewed-by: Romain Naour <romain.naour@gmail.com>

Best regards,
Romain


> +    done
> +}
> +
>  main "${@}"
>
diff mbox series

Patch

diff --git a/support/misc/gitlab-ci.yml.in b/support/misc/gitlab-ci.yml.in
index f00c764aaf..7f2ae32725 100644
--- a/support/misc/gitlab-ci.yml.in
+++ b/support/misc/gitlab-ci.yml.in
@@ -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}
 
diff --git a/support/scripts/generate-gitlab-ci-yml b/support/scripts/generate-gitlab-ci-yml
index b076b01d05..ed56a516a7 100755
--- a/support/scripts/generate-gitlab-ci-yml
+++ b/support/scripts/generate-gitlab-ci-yml
@@ -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 "${@}"