summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2021-08-22 21:36:29 +0200
committerMathieu Othacehe <othacehe@gnu.org>2021-08-22 21:36:29 +0200
commitbb5f395a08deacb799ef1e085863ba01a5f05e70 (patch)
treea4d1ee462fe78cadf9fcd7b89e276dd9faa7016a /guix
parent9adb69b089cc22fc054219bb83187331769d1284 (diff)
ci: Add jobs history support.
* guix/ci.scm (history?, history-evaluation, history-checkouts, history-jobs, jobs-history): New procedures. (<history>): New record.
Diffstat (limited to 'guix')
-rw-r--r--guix/ci.scm34
1 files changed, 32 insertions, 2 deletions
diff --git a/guix/ci.scm b/guix/ci.scm
index 6a3af8b42c..01b493b3af 100644
--- a/guix/ci.scm
+++ b/guix/ci.scm
@@ -59,6 +59,11 @@
job-status
job-name
+ history?
+ history-evaluation
+ history-checkouts
+ history-jobs
+
%query-limit
queued-builds
latest-builds
@@ -66,6 +71,7 @@
evaluation-jobs
build
job-build
+ jobs-history
latest-evaluations
evaluations-for-commit
@@ -127,6 +133,18 @@
integer->build-status)
(name job-name)) ;string
+(define-json-mapping <history> make-history history?
+ json->history
+ (evaluation history-evaluation) ;integer
+ (checkouts history-checkouts "checkouts" ;<checkout>*
+ (lambda (checkouts)
+ (map json->checkout
+ (vector->list checkouts))))
+ (jobs history-jobs "jobs"
+ (lambda (jobs)
+ (map json->job
+ (vector->list jobs)))))
+
(define-json-mapping <checkout> make-checkout checkout?
json->checkout
(commit checkout-commit) ;string (SHA1)
@@ -247,8 +265,20 @@ found (404)."
"Return the build associated with JOB."
(build url (job-build-id job)))
-;; TODO: job history:
-;; https://ci.guix.gnu.org/api/jobs/history?spec=master&names=coreutils.x86_64-linux&nr=10
+(define* (jobs-history url jobs
+ #:key
+ (specification "master")
+ (limit 20))
+ "Return the job history for the SPECIFICATION jobs which names are part of
+the JOBS list, from the CI server at URL. Limit the history to the latest
+LIMIT evaluations. "
+ (let ((names (string-join jobs ",")))
+ (map json->history
+ (vector->list
+ (json->scm
+ (http-fetch
+ (format #f "~a/api/jobs/history?spec=~a&names=~a&nr=~a"
+ url specification names (number->string limit))))))))
(define (find-latest-commit-with-substitutes url)
"Return the latest commit with available substitutes for the Guix package