From 2376c2111705da293b0e8d6b5b0e04d1a00ae243 Mon Sep 17 00:00:00 2001 From: Pietro Abate Date: Tue, 18 Nov 2025 11:39:32 +0100 Subject: [PATCH] ciao: use the same pipeline defaults everywhere --- .gitlab/ci/pipelines/base_images.yml | 8 +++++ .gitlab/ci/pipelines/octez_monitoring.yml | 8 +++++ .../ci/pipelines/security-scans-master.yml | 8 +++++ ci/bin/main.ml | 2 +- ci/lib_tezos_ci/tezos_ci.ml | 30 ++++++++++++------- ci/lib_tezos_ci/tezos_ci.mli | 8 ++++- ci/lib_tezos_ci_jobs/common.ml | 8 ----- ci/lib_tezos_ci_jobs/debian_repository.ml | 1 - ci/lib_tezos_ci_jobs/homebrew.ml | 2 -- ci/lib_tezos_ci_jobs/rpm_repository.ml | 1 - 10 files changed, 52 insertions(+), 24 deletions(-) diff --git a/.gitlab/ci/pipelines/base_images.yml b/.gitlab/ci/pipelines/base_images.yml index a2d11149b6b3..8109d231bd6d 100644 --- a/.gitlab/ci/pipelines/base_images.yml +++ b/.gitlab/ci/pipelines/base_images.yml @@ -1,6 +1,14 @@ # This file was automatically generated, do not edit. # Edit file ci/bin/main.ml instead. +default: + interruptible: true + retry: + max: 2 + when: + - stuck_or_timeout_failure + - runner_system_failure + workflow: rules: - if: $foo != "bar" || $foo == "bar" diff --git a/.gitlab/ci/pipelines/octez_monitoring.yml b/.gitlab/ci/pipelines/octez_monitoring.yml index be49b1fa83e4..7c8d351f071d 100644 --- a/.gitlab/ci/pipelines/octez_monitoring.yml +++ b/.gitlab/ci/pipelines/octez_monitoring.yml @@ -1,6 +1,14 @@ # This file was automatically generated, do not edit. # Edit file ci/bin/main.ml instead. +default: + interruptible: true + retry: + max: 2 + when: + - stuck_or_timeout_failure + - runner_system_failure + workflow: rules: - if: $foo != "bar" || $foo == "bar" diff --git a/.gitlab/ci/pipelines/security-scans-master.yml b/.gitlab/ci/pipelines/security-scans-master.yml index 168399668dea..8db6621bc066 100644 --- a/.gitlab/ci/pipelines/security-scans-master.yml +++ b/.gitlab/ci/pipelines/security-scans-master.yml @@ -1,6 +1,14 @@ # This file was automatically generated, do not edit. # Edit file ci/bin/main.ml instead. +default: + interruptible: true + retry: + max: 2 + when: + - stuck_or_timeout_failure + - runner_system_failure + workflow: rules: - if: $foo != "bar" || $foo == "bar" diff --git a/ci/bin/main.ml b/ci/bin/main.ml index b243c7192ddb..0b91d29a6c6f 100644 --- a/ci/bin/main.ml +++ b/ci/bin/main.ml @@ -552,7 +552,7 @@ let () = match Cli.config.action with | Write -> Pipeline.write - ~default:Common.Helpers.retry_default + ~default:Pipeline.default_config ~variables ~filename:".gitlab-ci.yml" () ; diff --git a/ci/lib_tezos_ci/tezos_ci.ml b/ci/lib_tezos_ci/tezos_ci.ml index 1a5f851a3f79..aa1f31966735 100644 --- a/ci/lib_tezos_ci/tezos_ci.ml +++ b/ci/lib_tezos_ci/tezos_ci.ml @@ -169,7 +169,6 @@ module Pipeline = struct if_ : Gitlab_ci.If.t; variables : Gitlab_ci.Types.variables option; auto_cancel : Gitlab_ci.Types.auto_cancel option; - default : Gitlab_ci.Types.default option; jobs : tezos_job list; } @@ -178,7 +177,7 @@ module Pipeline = struct description : string; auto_cancel : Gitlab_ci.Types.auto_cancel option; inherit_ : Gitlab_ci.Types.inherit_ option; - default : Gitlab_ci.Types.default option; + default : Gitlab_ci.Types.default; jobs : tezos_job list; } @@ -195,8 +194,19 @@ module Pipeline = struct | Child_pipeline {jobs; _} -> jobs | Pipeline {jobs; _} -> jobs + let default_config = + Gitlab_ci.Types. + { + image = None; + interruptible = Some true; + retry = + Some + {max = 2; when_ = [Stuck_or_timeout_failure; Runner_system_failure]}; + } + let default = function - | Pipeline {default; _} | Child_pipeline {default; _} -> default + | Pipeline _ -> default_config + | Child_pipeline {default; _} -> default let set_jobs jobs = function | Child_pipeline pl -> Child_pipeline {pl with jobs} @@ -213,11 +223,12 @@ module Pipeline = struct (name pipeline) else pipelines := pipeline :: !pipelines - let register ?variables ?auto_cancel ?default ~description ~jobs name if_ = + let register ?variables ?auto_cancel ~description ~jobs name if_ = register_raw - (Pipeline {variables; if_; name; jobs; auto_cancel; default; description}) + (Pipeline {variables; if_; name; jobs; auto_cancel; description}) - let register_child ?auto_cancel ?inherit_ ?default ~description ~jobs name = + let register_child ?auto_cancel ?inherit_ ?(default = default_config) + ~description ~jobs name = let child_pipeline = {name; inherit_; jobs; auto_cancel; default; description} in @@ -444,7 +455,6 @@ module Pipeline = struct let pipeline = add_image_builders pipeline in let jobs = jobs pipeline in let name = name pipeline in - let pipeline_default = default pipeline in if not (Sys.getenv_opt "CI_DISABLE_PRECHECK" = Some "true") then precheck pipeline ; if jobs = [] then @@ -464,9 +474,9 @@ module Pipeline = struct jobs ; let prepend_config = templates_to_config (templates pipeline) - @ (match pipeline_default with - | Some default_config -> [Gitlab_ci.Types.Default default_config] - | None -> []) + @ (match pipeline with + | Pipeline _ -> [] + | Child_pipeline _ -> [Gitlab_ci.Types.Default (default pipeline)]) @ (match pipeline with | Pipeline _ -> [] | Child_pipeline _ -> diff --git a/ci/lib_tezos_ci/tezos_ci.mli b/ci/lib_tezos_ci/tezos_ci.mli index 6529c96f040a..82ddd4633222 100644 --- a/ci/lib_tezos_ci/tezos_ci.mli +++ b/ci/lib_tezos_ci/tezos_ci.mli @@ -84,6 +84,13 @@ end (** A facility for registering pipelines. *) module Pipeline : sig + (** Default pipeline configuration. + + It is included in [.gitlab-ci.yml] and thus all pipelines inherit it, + with the exception of child pipelines. You can specify different defaults + for child pipelines, with the default defaults being [default_config]. *) + val default_config : Gitlab_ci.Types.default + (** Register a pipeline. [register ~description ?variables ?default name rule] will register a pipeline [name] @@ -104,7 +111,6 @@ module Pipeline : sig val register : ?variables:Gitlab_ci.Types.variables -> ?auto_cancel:Gitlab_ci.Types.auto_cancel -> - ?default:Gitlab_ci.Types.default -> description:string -> jobs:tezos_job list -> string -> diff --git a/ci/lib_tezos_ci_jobs/common.ml b/ci/lib_tezos_ci_jobs/common.ml index 964c770ba201..802298f8c7ae 100644 --- a/ci/lib_tezos_ci_jobs/common.ml +++ b/ci/lib_tezos_ci_jobs/common.ml @@ -23,14 +23,6 @@ open Tezos_ci.Cache (** {2 Shared Helpers} *) module Helpers = struct - (* Sets up the [default:] top-level configuration element. *) - let retry_default = - Gitlab_ci.Util.default - ~interruptible:true - ~retry: - {max = 2; when_ = [Stuck_or_timeout_failure; Runner_system_failure]} - () - (** The default [before_script:] section. In general, the result of this script should be used as the diff --git a/ci/lib_tezos_ci_jobs/debian_repository.ml b/ci/lib_tezos_ci_jobs/debian_repository.ml index a5306fac3520..818d7ecd2e5c 100644 --- a/ci/lib_tezos_ci_jobs/debian_repository.ml +++ b/ci/lib_tezos_ci_jobs/debian_repository.ml @@ -529,7 +529,6 @@ let register ~auto ~description pipeline_type = Pipeline.register_child pipeline_name ~description - ~default:Common.Helpers.retry_default ~jobs:(job_datadog_pipeline_trace :: jobs) let child_pipeline_partial = diff --git a/ci/lib_tezos_ci_jobs/homebrew.ml b/ci/lib_tezos_ci_jobs/homebrew.ml index 2a8848aa8e34..cd25381ed457 100644 --- a/ci/lib_tezos_ci_jobs/homebrew.ml +++ b/ci/lib_tezos_ci_jobs/homebrew.ml @@ -79,7 +79,6 @@ let child_pipeline_full = ~description: "A child pipeline of 'before_merging' building and testing the homebrew \ packaging. Manually triggered." - ~default:Common.Helpers.retry_default ~jobs:(jobs Full) let child_pipeline_full_auto = @@ -89,5 +88,4 @@ let child_pipeline_full_auto = "A child pipeline of 'before_merging' (and thus 'merge_train') building \ and testing the homebrew packaging. Starts automatically on certain \ conditions." - ~default:Common.Helpers.retry_default ~jobs:(jobs Full) diff --git a/ci/lib_tezos_ci_jobs/rpm_repository.ml b/ci/lib_tezos_ci_jobs/rpm_repository.ml index 2046669f6d7d..6a1d2e420d9b 100644 --- a/ci/lib_tezos_ci_jobs/rpm_repository.ml +++ b/ci/lib_tezos_ci_jobs/rpm_repository.ml @@ -378,7 +378,6 @@ let register ~auto ~description pipeline_type = Pipeline.register_child pipeline_name ~description - ~default:Common.Helpers.retry_default ~jobs:(job_datadog_pipeline_trace :: jobs) let child_pipeline_partial = -- GitLab