diff options
author | Ludovic Courtès <ludo@gnu.org> | 2021-07-03 18:02:11 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2021-07-04 23:00:36 +0200 |
commit | 77dba2281ffec5294f39d4f10f9cc64a936cf9ff (patch) | |
tree | 5f40841b3cb6714a0f5b841dff90111d35db7ae7 | |
parent | a2b22cae4fca3e7ff8b51677ef61c54a81205f63 (diff) | |
download | guix-77dba2281ffec5294f39d4f10f9cc64a936cf9ff.tar.gz guix-77dba2281ffec5294f39d4f10f9cc64a936cf9ff.zip |
ci: Represent build status as a symbol.
* guix/ci.scm (define-enumeration-mapping): New macro.
(integer->build-status): New procedure.
(<build>)[status]: Use it.
-rw-r--r-- | guix/ci.scm | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/guix/ci.scm b/guix/ci.scm index 0af04ff97d..bf3573247a 100644 --- a/guix/ci.scm +++ b/guix/ci.scm @@ -75,13 +75,31 @@ (file-size build-product-file-size) ;integer (path build-product-path)) ;string +(define-syntax-rule (define-enumeration-mapping proc + (names integers) ...) + (define (proc value) + (match value + (integers 'names) ...))) + +(define-enumeration-mapping integer->build-status + ;; Copied from 'build-status' in Cuirass. + (submitted -3) + (scheduled -2) + (started -1) + (succeeded 0) + (failed 1) + (failed-dependency 2) + (failed-other 3) + (canceled 4)) + (define-json-mapping <build> make-build build? json->build (id build-id "id") ;integer (derivation build-derivation) ;string | #f (evaluation build-evaluation) ;integer (system build-system) ;string - (status build-status "buildstatus" ) ;integer + (status build-status "buildstatus" ;symbol + integer->build-status) (timestamp build-timestamp) ;integer (products build-products "buildproducts" ;<build-product>* (lambda (products) |