aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-01-23 18:28:25 +0100
committerLudovic Courtès <ludo@gnu.org>2018-01-23 18:29:38 +0100
commitd7306a4f48a666a008091bfeb94d1fdb32b46948 (patch)
treefe51e0c044da64e19908eccf59119ca7048dd3c0 /src
parentfe0a98315d76dee63a0c0990c8b99ec0154d8a50 (diff)
downloadcuirass-d7306a4f48a666a008091bfeb94d1fdb32b46948.tar
cuirass-d7306a4f48a666a008091bfeb94d1fdb32b46948.tar.gz
base: Update build status and start/stop time according to build log.
Now the database is updated as things are built, rather than after the whole batch of derivation builds has completed. * src/cuirass/base.scm (handle-build-event): Call 'db-update-build-status!'. (build-packages)[register]: Set #:starttime and #:stoptime to 0. Set #:status to 'scheduled'. Define 'build-ids' and use it to determine the overall result.
Diffstat (limited to 'src')
-rw-r--r--src/cuirass/base.scm35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/cuirass/base.scm b/src/cuirass/base.scm
index c63c082..e08df58 100644
--- a/src/cuirass/base.scm
+++ b/src/cuirass/base.scm
@@ -270,17 +270,20 @@ and so on. "
(define* (handle-build-event db event
#:key (log-port (current-error-port)))
- "Handle EVENT, a build event sexp as produced by 'build-event-output-port'."
- ;; TODO: Update DB according to EVENT.
+ "Handle EVENT, a build event sexp as produced by 'build-event-output-port',
+updating DB accordingly."
(match event
(('build-started drv _ ...)
- (log-message "build started: '~a'" drv))
+ (log-message "build started: '~a'" drv)
+ (db-update-build-status! db drv (build-status started)))
(('build-remote drv host _ ...)
(log-message "'~a' offloaded to '~a'" drv host))
(('build-succeeded drv _ ...)
- (log-message "build succeeded: '~a'" drv))
+ (log-message "build succeeded: '~a'" drv)
+ (db-update-build-status! db drv (build-status succeeded)))
(('build-failed drv _ ...)
- (log-message "build failed: '~a'" drv))
+ (log-message "build failed: '~a'" drv)
+ (db-update-build-status! db drv (build-status failed)))
(('substituter-started item _ ...)
(log-message "substituter started: '~a'" item))
(('substituter-succeeded item _ ...)
@@ -306,18 +309,17 @@ and so on. "
(let ((build `((#:derivation . ,drv)
(#:eval-id . ,eval-id)
(#:log . ,log)
- (#:status .
- ,(match (length outputs)
- (0 (build-status failed))
- (_ (build-status succeeded))))
+ (#:status . ,(build-status scheduled))
(#:outputs . ,outputs)
- ;;; XXX: For now, we do not know start/stop build time.
(#:timestamp . ,cur-time)
- (#:starttime . ,cur-time)
- (#:stoptime . ,cur-time))))
+ (#:starttime . 0)
+ (#:stoptime . 0))))
(db-add-build db build)
build)))
+ (define build-ids
+ (map register jobs))
+
;; Pass all the jobs at once so we benefit from as much parallelism as
;; possible (we must be using #:keep-going? #t). Swallow build logs (the
;; daemon keeps them anyway), and swallow build errors.
@@ -334,12 +336,11 @@ and so on. "
(assq-ref job #:derivation))
jobs))))
- ;; Register the results in the database.
- ;; XXX: The 'build-derivations' call is blocking so we end updating the
- ;; database potentially long after things have been built.
- (let* ((results (map register jobs))
+ (let* ((results (filter-map db-get-build build-ids))
(status (map (cut assq-ref <> #:status) results))
- (success (length (filter zero? status)))
+ (success (count (lambda (status)
+ (= status (build-status succeeded)))
+ status))
(outputs (map (cut assq-ref <> #:outputs) results))
(outs (filter-map (cut assoc-ref <> "out") outputs))
(fail (- (length jobs) success)))