All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 2/3] Makefile: offload .gitlab-ci.yml generation
Date: Sun, 9 Dec 2018 21:32:39 +0100	[thread overview]
Message-ID: <20181209213239.44d2f16c@windsurf> (raw)
In-Reply-To: <20181028235839.22472-3-ricardo.martincoski@gmail.com>

Hello,

On Sun, 28 Oct 2018 20:58:38 -0300, Ricardo Martincoski wrote:
> GitLab has severe limitations imposed to triggers.
> Using a variable in a regexp is not allowed:
> |    only:
> |        - /-$CI_JOB_NAME$/
> |        - /-\$CI_JOB_NAME$/
> |        - /-%CI_JOB_NAME%$/
> Using the key 'variables' always lead to an AND with 'refs', so:
> |    only:
> |        refs:
> |            - branches
> |            - tags
> |        variables:
> |            - $CI_JOB_NAME == $CI_COMMIT_REF_NAME
> would make the push of a tag not to trigger all jobs anymore.
> Inheritance is used only for the second level of keys, so:
> |.runtime_test: &runtime_test
> |    only:
> |        - tags
> |tests.package.test_python_txaio.TestPythonPy2Txaio:
> |    <<: *runtime_test
> |    only:
> |        - /-TestPythonPy2Txaio$/
> would override the entire key 'only', making the push of a tag not to
> trigger all jobs anymore.
> 
> So, in order to have a trigger per job and still allow the push of a tag
> to trigger all jobs (all this in a follow up patch), the regexp for each
> job must be hardcoded in the .gitlab-ci.yml and also the inherited
> values for key 'only' must be repeated for every job.
> This is not a big issue, .gitlab-ci.yml is already automatically
> generated from a template and there will be no need to hand-editing it
> when jobs are added or removed.
> 
> Since the logic to generate the yaml file from the template will become
> more complex, move the commands from the main Makefile to a script.
> 
> Using Python or other advanced scripting language for that script would
> be the most versatile solution, but that would bring another dependency
> on the host machine, pyyaml if Python is used. So every developer that
> needs to run 'make .gitlab-ci.yml' and also the docker image used in the
> GitLab pipelines would need to have pyyaml pre-installed.
> Instead of adding the mentioned dependency, keep using a bash script.
> 
> While moving the commands to the script:
>  - mimic the behavior of the previous make target and fail on any
>    command that fails, by using 'set -e';
>  - break the original lines in one command per line, making the diff for
>    any patch to be applied to this file to look nicer;
>  - keep the script as simple as possible, without functions, just a
>    script that executes from the top to bottom;
>  - do not perform validations on the input parameters, any command that
>    fails already makes the script to fail;
>  - do not add an usage message, the script is not intended to be called
>    directly.
> 
> This patch does not change functionality.
> 
> Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
> Cc: Arnout Vandecappelle <arnout@mind.be>

I've applied after changing one thing, see below.

> diff --git a/support/scripts/generate-gitlab-ci-yml b/support/scripts/generate-gitlab-ci-yml
> new file mode 100755
> index 0000000000..d824f669b5
> --- /dev/null
> +++ b/support/scripts/generate-gitlab-ci-yml
> @@ -0,0 +1,20 @@
> +#!/usr/bin/env bash
> +set -e
> +set -o pipefail
> +
> +input="${1}"
> +output="${2}"
> +
> +cp "${input}" "${output}"
> +
> +(
> +    cd configs
> +    LC_ALL=C ls -1 *_defconfig
> +) \
> +    | sed 's/$/: *defconfig/' \
> +    >> "${output}"
> +
> +./support/testing/run-tests -l 2>&1 \
> +    | sed -r -e '/^test_run \((.*)\).*/!d; s//\1: *runtime_test/' \
> +    | LC_ALL=C sort \
> +    >> "${output}"

I think it is more common for this kind of script to output on stdout,
and have the caller redirect to a file. It makes the script slightly
simpler, since you don't have to redirect to ${output}. So I've changed
to use this solution before applying.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2018-12-09 20:32 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-28 23:58 [Buildroot] [PATCH 0/3] .gitlab-ci.yml: add trigger per job and per type of job Ricardo Martincoski
2018-10-28 23:58 ` [Buildroot] [PATCH 1/3] .gitlab-ci.yml: add trigger " Ricardo Martincoski
2018-12-09 20:29   ` Thomas Petazzoni
2018-10-28 23:58 ` [Buildroot] [PATCH 2/3] Makefile: offload .gitlab-ci.yml generation Ricardo Martincoski
2018-12-09 20:32   ` Thomas Petazzoni [this message]
2018-10-28 23:58 ` [Buildroot] [PATCH 3/3] .gitlab-ci.yml: add trigger per job Ricardo Martincoski
2018-12-09 20:59   ` Thomas Petazzoni
2019-01-16 22:57     ` Ricardo Martincoski
2018-12-10 13:30   ` Matthew Weber
2018-12-13 16:55     ` Matthew Weber
2019-01-09 14:57       ` Matthew Weber
2019-01-11  2:52         ` Ricardo Martincoski
2019-01-16 22:45   ` [Buildroot] [PATCH v2] " Ricardo Martincoski
2019-01-18 10:21     ` Arnout Vandecappelle
2019-01-20 20:21       ` Ricardo Martincoski
2019-01-21  1:11     ` [Buildroot] [PATCH v3 0/5] .gitlab-ci.yml: rework and " Ricardo Martincoski
2019-01-21  1:11       ` [Buildroot] [PATCH v3 1/5] .gitlab-ci.yml: use "extends" keyword Ricardo Martincoski
2019-02-06 10:53         ` Arnout Vandecappelle
2019-01-21  1:11       ` [Buildroot] [PATCH v3 2/5] .gitlab-ci.yml: use "include" keyword Ricardo Martincoski
2019-02-06 10:59         ` Arnout Vandecappelle
2019-04-08  3:22           ` Ricardo Martincoski
2019-01-21  1:11       ` [Buildroot] [PATCH v3 3/5] .gitlab-ci.yml: reorder jobs Ricardo Martincoski
2019-01-21  1:11       ` [Buildroot] [PATCH v3 4/5] .gitlab-ci.yml: prepare to reuse scripts Ricardo Martincoski
2019-01-21  1:11       ` [Buildroot] [PATCH v3 5/5] .gitlab-ci.yml: add trigger per job Ricardo Martincoski
2019-04-08  3:22       ` [Buildroot] [PATCH v4 0/3] .gitlab-ci.yml: rework and " Ricardo Martincoski
2019-04-08  3:22         ` [Buildroot] [PATCH v4 1/3] .gitlab-ci.yml: reorder jobs Ricardo Martincoski
2019-04-13 13:43           ` Arnout Vandecappelle
2019-04-08  3:22         ` [Buildroot] [PATCH v4 2/3] .gitlab-ci.yml: prepare to reuse scripts Ricardo Martincoski
2019-04-08  3:22         ` [Buildroot] [PATCH v4 3/3] .gitlab-ci.yml: add trigger per job Ricardo Martincoski
2019-04-13 13:46           ` Arnout Vandecappelle
2019-04-22  1:27             ` Ricardo Martincoski
2019-04-22  7:19               ` Arnout Vandecappelle
2019-05-01 13:54                 ` Arnout Vandecappelle
2018-10-31  9:13 ` [Buildroot] [PATCH 0/3] .gitlab-ci.yml: add trigger per job and per type of job Thomas Petazzoni
2018-11-02  4:22   ` Ricardo Martincoski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181209213239.44d2f16c@windsurf \
    --to=thomas.petazzoni@bootlin.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.