Subject: [bug#47929] [PATCH 4/5] scripts: weather: Add packages dashboard support.

From: Mathieu Othacehe <[email-masked]>
Date: Wed, 21 Apr 2021 14:21:07 +0200

* guix/scripts/weather.scm (display-dashboard-url): New procedure.
(guix-weather): Call it.
---
 guix/scripts/weather.scm | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/guix/scripts/weather.scm b/guix/scripts/weather.scm
index 5164fe0494..be0b2e3509 100644
--- a/guix/scripts/weather.scm
+++ b/guix/scripts/weather.scm
@@ -499,6 +499,17 @@ SERVER.  Display information for packages with at least THRESHOLD dependents."
              #f
              systems))))
 
+(define (display-dashboard-url server packages)
+  "Display a link to the dashboard for PACKAGES on the given CI SERVER."
+  (let* ((id (dashboard-register server packages))
+         (url (and id (dashboard-url server id))))
+    (when url
+      (format #t "~%")
+      (format #t (G_ "The packages dashboard is available ~a.~%")
+              (if (supports-hyperlinks?)
+                  (hyperlink url (G_ "here"))
+                  (format #f "here: ~a" url))))))
+
 
 ;;;
 ;;; Entry point.
@@ -554,15 +565,18 @@ SERVER.  Display information for packages with at least THRESHOLD dependents."
                      (report-server-coverage server items
                                              #:display-missing?
                                              (assoc-ref opts 'display-missing?)))
-                   (match (assoc-ref opts 'coverage)
-                     (#f #f)
-                     (threshold
-                      ;; PACKAGES may include non-package objects coming from a
-                      ;; manifest.  Filter them out.
-                      (report-package-coverage server
-                                               (filter package? packages)
-                                               systems
-                                               #:threshold threshold)))
+
+                   ;; PACKAGES may include non-package objects coming from a
+                   ;; manifest.  Filter them out.
+                   (let ((packages (filter package? packages)))
+                     (match (assoc-ref opts 'coverage)
+                       (#f #f)
+                       (threshold
+                        (report-package-coverage server
+                                                 packages
+                                                 systems
+                                                 #:threshold threshold)))
+                     (display-dashboard-url server packages))
 
                    (= 1 coverage))
                  urls))))))
-- 
2.31.1