[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Ludovic Courtès |
Date: |
Tue, 23 Jan 2018 12:31:57 -0500 (EST) |
branch: master
commit b0f1a438ff1230ca98f06eda32443740c7bc8776
Author: Ludovic Courtès <address@hidden>
Date: Tue Jan 23 17:37:08 2018 +0100
Add a 'build-status' enumeration.
* src/cuirass/utils.scm (define-enumeration): New macro.
* src/cuirass/database.scm (build-status): New macro.
* src/cuirass/base.scm (build-packages)[hydra-build-status]: Remove.
Use the 'build-status' macro instead.
---
src/cuirass/base.scm | 13 ++-----------
src/cuirass/database.scm | 9 +++++++++
src/cuirass/utils.scm | 14 ++++++++++++--
3 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/src/cuirass/base.scm b/src/cuirass/base.scm
index 155330d..c63c082 100644
--- a/src/cuirass/base.scm
+++ b/src/cuirass/base.scm
@@ -290,15 +290,6 @@ and so on. "
(define (build-packages store db jobs)
"Build JOBS and return a list of Build results."
-
- (define hydra-build-status
- ;; Build status as expected by hydra compatible API's.
- '((succeeded . 0)
- (failed . 1)
- (failed-dependency . 2)
- (failed-other . 3)
- (cancelled . 4)))
-
(define (register job)
(let* ((name (assq-ref job #:job-name))
(drv (assq-ref job #:derivation))
@@ -317,8 +308,8 @@ and so on. "
(#:log . ,log)
(#:status .
,(match (length outputs)
- (0 (assq-ref hydra-build-status 'failed))
- (_ (assq-ref hydra-build-status 'succeeded))))
+ (0 (build-status failed))
+ (_ (build-status succeeded))))
(#:outputs . ,outputs)
;;; XXX: For now, we do not know start/stop build time.
(#:timestamp . ,cur-time)
diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index 901cdf6..f50d746 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -37,6 +37,7 @@
db-add-evaluation
db-add-derivation
db-get-derivation
+ build-status
db-add-build
db-get-build
db-get-builds
@@ -197,6 +198,14 @@ string."
(define SQLITE_CONSTRAINT_PRIMARYKEY
(logior SQLITE_CONSTRAINT (ash 6 8)))
+(define-enumeration build-status
+ ;; Build status as expected by Hydra's API.
+ (succeeded 0)
+ (failed 1)
+ (failed-dependency 2)
+ (failed-other 3)
+ (cancelled 4))
+
(define (db-add-build db build)
"Store BUILD in database DB. BUILD eventual outputs are stored
in the OUTPUTS table."
diff --git a/src/cuirass/utils.scm b/src/cuirass/utils.scm
index a932674..9f432a6 100644
--- a/src/cuirass/utils.scm
+++ b/src/cuirass/utils.scm
@@ -1,5 +1,5 @@
;;; utils.scm -- helper procedures
-;;; Copyright © 2012, 2013, 2016 Ludovic Courtès <address@hidden>
+;;; Copyright © 2012, 2013, 2016, 2018 Ludovic Courtès <address@hidden>
;;; Copyright © 2015 David Thompson <address@hidden>
;;; Copyright © 2016 Mathieu Lirzin <address@hidden>
;;;
@@ -24,7 +24,8 @@
#:use-module (json)
#:export (alist?
object->json-scm
- object->json-string))
+ object->json-string
+ define-enumeration))
(define (alist? obj)
"Return #t if OBJ is an alist."
@@ -47,3 +48,12 @@
(define* (object->json-string object #:key pretty)
"Return OBJECT as a JSON object."
(scm->json-string (object->json-scm object) #:pretty pretty))
+
+(define-syntax-rule (define-enumeration name (symbol value) ...)
+ "Define an 'enum' type with the given SYMBOL/VALUE pairs. NAME is defined a
+macro that accepts one of these symbols and expands to the corresponding
+value."
+ (define-syntax name
+ (syntax-rules (symbol ...)
+ ((_ symbol) value)
+ ...)))
- master updated (f92ad70 -> f1b3a12), Ludovic Courtès, 2018/01/23
- [no subject], Ludovic Courtès, 2018/01/23
- [no subject], Ludovic Courtès, 2018/01/23
- [no subject], Ludovic Courtès, 2018/01/23
- [no subject], Ludovic Courtès, 2018/01/23
- [no subject],
Ludovic Courtès <=
- [no subject], Ludovic Courtès, 2018/01/23