aboutsummaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorArun Isaac2022-04-09 00:30:45 +0530
committerArun Isaac2022-04-09 10:54:50 +0530
commita64841eb92a1cece95001ec5ed87e3a0b59d9375 (patch)
tree1dcfa962f9b00cfe29b6437face21495d3335412 /guix
parent956ff3141a7eb17c2fa84706ac8430897013f8a2 (diff)
downloadguix-forge-a64841eb92a1cece95001ec5ed87e3a0b59d9375.tar.gz
guix-forge-a64841eb92a1cece95001ec5ed87e3a0b59d9375.tar.lz
guix-forge-a64841eb92a1cece95001ec5ed87e3a0b59d9375.zip
forge: Do not try to trigger CI jobs when there are none.
* guix/forge/forge.scm (ci-jobs-trigger-gexp): Import (ice-9 match). Do not try to trigger CI jobs when there are none to be triggered. (forge-service-type): Do not set up cron jobs and webhooks when there are no CI jobs to be triggered.
Diffstat (limited to 'guix')
-rw-r--r--guix/forge/forge.scm41
1 files changed, 30 insertions, 11 deletions
diff --git a/guix/forge/forge.scm b/guix/forge/forge.scm
index f99576f..f9ef272 100644
--- a/guix/forge/forge.scm
+++ b/guix/forge/forge.scm
@@ -89,18 +89,33 @@
<forge-laminar-job> objects."
(with-imported-modules '((guix build utils))
#~(begin
- (use-modules (guix build utils))
+ (use-modules (guix build utils)
+ (ice-9 match))
;; TODO: Only trigger on updates to the main/master branch.
- (display "Triggering continuous integration jobs..." (current-error-port))
- (newline (current-error-port))
- (when #$reason
- (setenv "LAMINAR_REASON" #$reason))
- (apply invoke
- #$(file-append laminar "/bin/laminarc")
- "queue" '#$(filter-map (lambda (job)
- (and (forge-laminar-job-trigger? job)
- (forge-laminar-job-name job)))
- ci-jobs)))))
+
+ ;; Trigger jobs if there are jobs that need to be
+ ;; triggered.
+ ;;
+ ;; Even if there are none, we still need to manage the
+ ;; post-receive-hook to ensure that it does not go
+ ;; stale. Suppose that in one generation the user configures
+ ;; CI jobs, but removes them in the next generation. If we did
+ ;; not write to the post-receive-hook in the second
+ ;; generation, it would still retain its previous contents and
+ ;; trigger the jobs from the first generation.
+ (match '#$(filter-map (lambda (job)
+ (and (forge-laminar-job-trigger? job)
+ (forge-laminar-job-name job)))
+ ci-jobs)
+ (() #t)
+ (job-names
+ (display "Triggering continuous integration jobs..." (current-error-port))
+ (newline (current-error-port))
+ (when #$reason
+ (setenv "LAMINAR_REASON" #$reason))
+ (apply invoke
+ #$(file-append laminar "/bin/laminarc")
+ "queue" job-names))))))
(define (forge-activation config)
(let ((projects
@@ -271,6 +286,8 @@ clone and does not include the .git directory."
(filter-map (lambda (project)
(and (eq? (forge-project-ci-jobs-trigger project)
'cron)
+ (any forge-laminar-job-trigger?
+ (forge-project-ci-jobs project))
#~(job '(next-day)
#$(program-file
(string-append (forge-project-name project)
@@ -285,6 +302,8 @@ clone and does not include the .git directory."
(filter-map (lambda (project)
(and (eq? (forge-project-ci-jobs-trigger project)
'webhook)
+ (any forge-laminar-job-trigger?
+ (forge-project-ci-jobs project))
(webhook-hook
(id (forge-project-name project))
(run (ci-jobs-trigger-gexp