aboutsummaryrefslogtreecommitdiff
path: root/guix/forge
diff options
context:
space:
mode:
authorArun Isaac2024-01-09 16:31:42 +0000
committerArun Isaac2024-01-09 17:14:10 +0000
commit151940a342848c768e372ec9f232b898ca2c738d (patch)
tree4f856393a832e003538ab0e91dda83189a31748a /guix/forge
parent51e10bab897a98b28ecb7a3ea73640015522b4d5 (diff)
downloadguix-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.
Diffstat (limited to 'guix/forge')
-rw-r--r--guix/forge/forge.scm31
1 files changed, 26 insertions, 5 deletions
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