diff options
author | Arun Isaac | 2024-01-09 16:31:42 +0000 |
---|---|---|
committer | Arun Isaac | 2024-01-09 17:14:10 +0000 |
commit | 151940a342848c768e372ec9f232b898ca2c738d (patch) | |
tree | 4f856393a832e003538ab0e91dda83189a31748a | |
parent | 51e10bab897a98b28ecb7a3ea73640015522b4d5 (diff) | |
download | guix-forge-151940a342848c768e372ec9f232b898ca2c738d.tar.gz guix-forge-151940a342848c768e372ec9f232b898ca2c738d.tar.lz guix-forge-151940a342848c768e372ec9f232b898ca2c738d.zip |
forge: Limit number of parallel CI job runs.
* guix/forge/forge.scm (<forge-project>)[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 <forge-laminar-context>
objects.
(forge-service-type): Call forge-ci-jobs+contexts+groups instead of
forge-ci-jobs-and-groups.
* doc/forge.skb (Reference)[<forge-project>]{parallel-ci-job-runs}:
Document it.
-rw-r--r-- | doc/forge.skb | 3 | ||||
-rw-r--r-- | guix/forge/forge.scm | 31 |
2 files changed, 29 insertions, 5 deletions
diff --git a/doc/forge.skb b/doc/forge.skb index 83b4100..99d1b86 100644 --- a/doc/forge.skb +++ b/doc/forge.skb @@ -555,6 +555,9 @@ jobs when a request is received on ,(samp "http://hostname:port/hooks/<name>") \ specified, a cron job triggers the CI jobs once a day.]))] :default [,(code ['post-receive-hook]) for local repositories and ,(code ['cron]) for remote repositories]) + (record-field "parallel-ci-job-runs" + [Number of CI job runs of this project to run +simultaneously]) (record-field "repository-branch" [Main branch of the repository. This field is currently unused unused, and may be deprecated in the future.])) 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> 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{<forge-laminar-job>} 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{<forge-laminar-context>} 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{<forge-laminar-job>} 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{<forge-laminar-job>} or a @code{<forge-laminar-group>} object." +@code{<forge-laminar-job>}, @code{<forge-laminar-context>} or +@code{<forge-laminar-group>} 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{<webhook-hook>} 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 |