From 151940a342848c768e372ec9f232b898ca2c738d Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 9 Jan 2024 16:31:42 +0000 Subject: forge: Limit number of parallel CI job runs. * guix/forge/forge.scm ()[parallel-ci-job-runs]: New field. * guix/forge/forge.scm (forge-ci-jobs): Add project context to CI jobs. (forge-ci-job-contexts): New function. (forge-ci-jobs-and-groups): Rename to forge-ci-jobs+contexts+groups. Also return objects. (forge-service-type): Call forge-ci-jobs+contexts+groups instead of forge-ci-jobs-and-groups. * doc/forge.skb (Reference)[]{parallel-ci-job-runs}: Document it. --- guix/forge/forge.scm | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'guix/forge') diff --git a/guix/forge/forge.scm b/guix/forge/forge.scm index 7cf3ff3..6e24cbf 100644 --- a/guix/forge/forge.scm +++ b/guix/forge/forge.scm @@ -87,7 +87,9 @@ 'post-receive-hook) ;; 'cron for remote repositories (else 'cron))) - (thunked))) + (thunked)) + (parallel-ci-job-runs forge-project-parallel-ci-job-runs + (default 1))) (define-record-type* forge-configuration make-forge-configuration @@ -407,7 +409,24 @@ When @var{verbose?} is #true, verbose build logs are shown." (define (forge-ci-jobs config) "Return list of CI jobs for forge configuraion @var{config}. Each value of the returned list is a @code{} object." - (append-map forge-project-ci-jobs + (append-map (lambda (project) + ;; Add project context to CI jobs. + (map (lambda (job) + (forge-laminar-job + (inherit job) + (contexts (cons (forge-project-name project) + (forge-laminar-job-contexts job))))) + (forge-project-ci-jobs project))) + (forge-configuration-projects config))) + +(define (forge-ci-job-contexts config) + "Return list of CI job contexts for forge configuration +@var{config}. Each element of the returned list is a +@code{} object." + (filter-map (lambda (project) + (forge-laminar-context + (name (forge-project-name project)) + (executors (forge-project-parallel-ci-job-runs project)))) (forge-configuration-projects config))) (define (forge-ci-job-groups config) @@ -427,11 +446,13 @@ value of the returned list is a @code{} object." ")$")))))) (forge-configuration-projects config))) -(define (forge-ci-jobs-and-groups config) +(define (forge-ci-jobs+contexts+groups config) "Return list of CI jobs and job groups for forge configuration @var{config}. Each element of the returned list is either a -@code{} or a @code{} object." +@code{}, @code{} or +@code{} object." (append (forge-ci-jobs config) + (forge-ci-job-contexts config) (forge-ci-job-groups config))) (define (forge-cron-jobs config) @@ -475,7 +496,7 @@ value is a list of @code{} objects." (extensions (list (service-extension activation-service-type forge-activation) (service-extension forge-laminar-service-type - forge-ci-jobs-and-groups) + forge-ci-jobs+contexts+groups) ;; TODO: Run CI job only if there are new commits ;; in the remote repository. (service-extension mcron-service-type -- cgit v1.2.3