summaryrefslogtreecommitdiff
path: root/guix/scripts/weather.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-03-13 10:53:49 +0100
committerLudovic Courtès <ludo@gnu.org>2020-03-13 17:33:37 +0100
commitbe764b47ad1079df531f016c1946cbf98ff48c41 (patch)
tree1194a8da879387b02b4bc65f0beb3ebdda9d0203 /guix/scripts/weather.scm
parent10b99ddf4596a033eaf348dddf519639e029f9d1 (diff)
weather: Exit with non-zero when coverage is below 100%.
* guix/scripts/weather.scm (report-server-coverage): Return the coverage ratio. (guix-weather): Exit if and only if each server's coverage is 1.
Diffstat (limited to 'guix/scripts/weather.scm')
-rw-r--r--guix/scripts/weather.scm29
1 files changed, 19 insertions, 10 deletions
diff --git a/guix/scripts/weather.scm b/guix/scripts/weather.scm
index 733986be0c..913c84955e 100644
--- a/guix/scripts/weather.scm
+++ b/guix/scripts/weather.scm
@@ -178,7 +178,8 @@ about the derivations queued, as is the case with Hydra."
(define* (report-server-coverage server items
#:key display-missing?)
"Report the subset of ITEMS available as substitutes on SERVER.
-When DISPLAY-MISSING? is true, display the list of missing substitutes."
+When DISPLAY-MISSING? is true, display the list of missing substitutes.
+Return the coverage ratio, an exact number between 0 and 1."
(define MiB (* (expt 2 20) 1.))
(format #t (G_ "looking for ~h store items on ~a...~%")
@@ -267,7 +268,11 @@ are queued~%")
(when (and display-missing? (not (null? missing)))
(newline)
(format #t (G_ "Substitutes are missing for the following items:~%"))
- (format #t "~{ ~a~%~}" missing)))))
+ (format #t "~{ ~a~%~}" missing))
+
+ ;; Return the coverage ratio.
+ (let ((total (length items)))
+ (/ (- total (length missing)) total)))))
;;;
@@ -538,16 +543,20 @@ SERVER. Display information for packages with at least THRESHOLD dependents."
(lambda (system)
(package-outputs packages system))
systems))))))
- (for-each (lambda (server)
+ (exit
+ (every (lambda (server)
+ (define coverage
(report-server-coverage server items
#:display-missing?
- (assoc-ref opts 'display-missing?))
- (match (assoc-ref opts 'coverage)
- (#f #f)
- (threshold
- (report-package-coverage server packages systems
- #:threshold threshold))))
- urls)))))
+ (assoc-ref opts 'display-missing?)))
+ (match (assoc-ref opts 'coverage)
+ (#f #f)
+ (threshold
+ (report-package-coverage server packages systems
+ #:threshold threshold)))
+
+ (= 1 coverage))
+ urls))))))
;;; Local Variables:
;;; eval: (put 'let/time 'scheme-indent-function 1)