aboutsummaryrefslogtreecommitdiff
path: root/bffe/view/build.scm
blob: ded00ef851c8a80bcd271664d389b195eab25c66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
(define-module (bffe view build)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-19)
  #:use-module (ice-9 match)
  #:use-module (ice-9 format)
  #:use-module (bffe view util)
  #:use-module ((guix store) #:select (%store-prefix))
  #:export (build))

(define (build title build-details derivation-link-target tag-link-target)
  (layout
   #:title (string-append
            "Build " (assoc-ref build-details "uuid") " — " title)
   #:body
   `((main
      (dl
       (dt "Derivation")
       (dd ,(let* ((derivation-name (assoc-ref build-details "derivation-name"))
                   (derivation-link
                    (derivation-link-target derivation-name
                                            build-details)))
              (if derivation-link
                  `(a (@ (href ,derivation-link))
                      ,derivation-name)
                  derivation-name)))

       (dt "Tags")
       (dd (ul
            ,@(map (lambda (tag)
                     (let* ((key (assoc-ref tag "key"))
                            (value (assoc-ref tag "value"))
                            (link (tag-link-target key value build-details)))
                       (if link
                           `(a (@ (href ,link))
                               (li ,key ": " ,value))
                           `(li ,key ": " ,value))))
                   (vector->list
                    (assoc-ref build-details "tags")))))

       (dt "Submitted at")
       (dd ,(assoc-ref build-details "created-at"))

       (dt "State")
       (dd ,(if (assoc-ref build-details "cancelled")
                "Canceled"
                (if (assoc-ref build-details "processed")
                    (if (string=? (assoc-ref
                                   (assoc-ref build-details "result")
                                   "result")
                                  "success")
                        "Succeeded"
                        "Failed")
                    "Pending")))

       (dt "Priority")
       (dd ,(assoc-ref build-details "priority")))

      ,@(if (assoc-ref build-details "processed")
            `((a (@ (href ,(string-append "/build/"
                                          (assoc-ref build-details "uuid")
                                          "/log")))
                 "View build log"))
            '())))))