From 7dc747646e56a90767387d5637cfa71c95fbba43 Mon Sep 17 00:00:00 2001 From: Killian Delarue Date: Fri, 6 Dec 2024 14:28:45 +0100 Subject: [PATCH] CIAO: Add [inherit] rule to [trigger_job] --- ci/lib_gitlab_ci/to_yaml.ml | 7 ++++++- ci/lib_gitlab_ci/types.ml | 7 +++++++ ci/lib_gitlab_ci/util.ml | 4 ++-- ci/lib_gitlab_ci/util.mli | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ci/lib_gitlab_ci/to_yaml.ml b/ci/lib_gitlab_ci/to_yaml.ml index 1c566f1abc3a..57a54a9b1757 100644 --- a/ci/lib_gitlab_ci/to_yaml.ml +++ b/ci/lib_gitlab_ci/to_yaml.ml @@ -311,14 +311,19 @@ let enc_job : job -> value = opt "parallel" enc_parallel parallel; ] +let enc_inherit : inherit_ -> value = function + | Variable_bool b -> `O (key "variables" bool b) + | Variable_list v -> `O (key "variables" (list string) v) + let enc_trigger_job : trigger_job -> value = let enc_trigger_include trigger_include = `O [("include", `String trigger_include)] in - fun {name = _; stage; when_; rules; needs; trigger_include} -> + fun {name = _; stage; when_; inherit_; rules; needs; trigger_include} -> obj_flatten [ opt "stage" string stage; + opt "inherit" enc_inherit inherit_; opt "rules" enc_job_rules rules; opt "needs" enc_needs needs; opt "when" enc_when_trigger_job when_; diff --git a/ci/lib_gitlab_ci/types.ml b/ci/lib_gitlab_ci/types.ml index e307349d3d92..110462b2063a 100644 --- a/ci/lib_gitlab_ci/types.ml +++ b/ci/lib_gitlab_ci/types.ml @@ -194,6 +194,11 @@ type matrix = (string * string list) list list YAML keyword reference for more information. *) type parallel = Vector of int | Matrix of matrix +(** Represents an inherit rule. + + See https://docs.gitlab.com/ee/ci/yaml/index.html#inherit *) +type inherit_ = Variable_list of string list | Variable_bool of bool + type job = { name : string; (** Note that [name] does not translate to a field in a job, but @@ -252,6 +257,7 @@ type job = { - [extends]. - [needs], but not [needs:project]. - [only] and [except]. + - [inherit] - [rules]. - [stage]. - [trigger]. @@ -268,6 +274,7 @@ type trigger_job = { name : string; stage : string option; when_ : when_trigger_job option; + inherit_ : inherit_ option; rules : job_rule list option; needs : need list option; trigger_include : string; diff --git a/ci/lib_gitlab_ci/util.ml b/ci/lib_gitlab_ci/util.ml index c221aa01ff33..7afd6d25565e 100644 --- a/ci/lib_gitlab_ci/util.ml +++ b/ci/lib_gitlab_ci/util.ml @@ -59,8 +59,8 @@ let job ?after_script ?allow_failure ?artifacts ?before_script ?cache ?image parallel; } -let trigger_job ?needs ?rules ?stage ?when_ ~name trigger_include = - {name; needs; rules; stage; when_; trigger_include} +let trigger_job ?needs ?inherit_ ?rules ?stage ?when_ ~name trigger_include = + {name; needs; inherit_; rules; stage; when_; trigger_include} let artifacts ?expire_in ?reports ?when_ ?expose_as ?name paths = (match (reports, paths) with diff --git a/ci/lib_gitlab_ci/util.mli b/ci/lib_gitlab_ci/util.mli index 7c68746a5dff..40b33d56adc9 100644 --- a/ci/lib_gitlab_ci/util.mli +++ b/ci/lib_gitlab_ci/util.mli @@ -86,6 +86,7 @@ val job : (** [trigger_job child_pipeline_path] constructs a {!trigger_job} job. *) val trigger_job : ?needs:need list -> + ?inherit_:inherit_ -> ?rules:job_rule list -> ?stage:string -> ?when_:when_trigger_job -> -- GitLab