branch: main
commit f5020950c8fe3b4f4f3cd464343c07cff278ce4d
Author: Romain GARBAGE <[email protected]>
AuthorDate: Fri Apr 4 18:34:38 2025 +0200
forgejo: Add support for different types of notification to Forgejo.
* src/cuirass/forges/forgejo.scm (forgejo-handle-notification): Add support
for different types of notification to Forgejo.
(forgejo-notification-in-pull-request-body): New variable.
* src/cuirass/parameters.scm (%forgejo-notification-type): New variable.
Signed-off-by: Ludovic Courtès <[email protected]>
---
src/cuirass/forges/forgejo.scm | 43 ++++++++++++++++++++++++++++++++----------
src/cuirass/parameters.scm | 9 ++++++++-
2 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/src/cuirass/forges/forgejo.scm b/src/cuirass/forges/forgejo.scm
index eef6885..f5e3cdc 100644
--- a/src/cuirass/forges/forgejo.scm
+++ b/src/cuirass/forges/forgejo.scm
@@ -384,16 +384,17 @@ CONTENT, a string. Returns the content of the updated
pull-request body."
;;; Forgejo specific handler of the forge-notification-service agent.
;;;
-(define* (forgejo-handle-notification spec
- #:key
- (jobset-created #f)
- (evaluation-started #f)
- (evaluation-succeeded #f)
- (evaluation-failed #f)
- (build-results #f))
- "Send notifications to a Forgejo instance. SPEC is a specification record,
-JOBSET-CREATED is a boolean, EVALUATION-STARTED, EVALUATION-SUCCEEDED and
-EVALUATION-FAILED are numbers and BUILD-RESULTS is a list of build records."
+(define* (forgejo-notification-in-pull-request-body spec
+ #:key
+ (jobset-created #f)
+ (evaluation-started #f)
+ (evaluation-succeeded #f)
+ (evaluation-failed #f)
+ (build-results #f))
+ "Notify a Forgejo instance of a status change by editing the pull request
main
+message. SPEC is a specification record, JOBSET-CREATED is a boolean,
+EVALUATION-STARTED, EVALUATION-SUCCEEDED and EVALUATION-FAILED are numbers and
+BUILD-RESULTS is a list of build records."
(log-info "preparing Forgejo notification for spec '~a'"
(specification-name spec))
@@ -454,3 +455,25 @@ EVALUATION-FAILED are numbers and BUILD-RESULTS is a list
of build records."
;; XXX: Raise an error when no message has been generated?
(when message
(update-forgejo-pull-request-from-spec spec message))))
+
+(define* (forgejo-handle-notification spec
+ #:key
+ (jobset-created #f)
+ (evaluation-started #f)
+ (evaluation-succeeded #f)
+ (evaluation-failed #f)
+ (build-results #f))
+ "Send notifications to a Forgejo instance. SPEC is a specification record,
+JOBSET-CREATED is a boolean, EVALUATION-STARTED, EVALUATION-SUCCEEDED and
+EVALUATION-FAILED are numbers and BUILD-RESULTS is a list of build records."
+ (match (%forgejo-notification-type)
+ ('update-pull-request-body
+ (forgejo-notification-in-pull-request-body spec
+ #:jobset-created jobset-created
+ #:evaluation-started
evaluation-started
+ #:evaluation-succeeded
evaluation-succeeded
+ #:evaluation-failed
evaluation-failed
+ #:build-results build-results))
+ (type
+ (log-error "forgejo-handle-notification: unsupported notification type ~a"
+ type))))
diff --git a/src/cuirass/parameters.scm b/src/cuirass/parameters.scm
index 0a5fe21..668c29c 100644
--- a/src/cuirass/parameters.scm
+++ b/src/cuirass/parameters.scm
@@ -1,5 +1,6 @@
;;; parameters.scm -- Cuirass parameters.
;;; Copyright © 2021 Mathieu Othacehe <[email protected]>
+;;; Copyright © 2025 Romain Garbage <[email protected]>
;;;
;;; This file is part of Cuirass.
;;;
@@ -29,7 +30,9 @@
%mastodon-instance-name
%mastodon-instance-url
- %mastodon-instance-token))
+ %mastodon-instance-token
+
+ %forgejo-notification-type))
;; This variable is looked up by 'mu-message-send'.
(define-public mu-debug 0)
@@ -71,3 +74,7 @@
;; The token used to authenticate on the Mastodon instance.
(define %mastodon-instance-token
(make-parameter #f))
+
+;; The type of notification to send to a Forgejo server.
+(define %forgejo-notification-type
+ (make-parameter 'update-pull-request-body))