aboutsummaryrefslogtreecommitdiff
path: root/guix-qa-frontpage/view/issue.scm
blob: 68ed8f11b405f43189bc185d87ebbaf9b03973fa (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
(define-module (guix-qa-frontpage view issue)
  #:use-module (srfi srfi-1)
  #:use-module (ice-9 match)
  #:use-module (web uri)
  #:use-module (guix-qa-frontpage issue)
  #:use-module (guix-qa-frontpage manage-builds)
  #:use-module (guix-qa-frontpage guix-data-service)
  #:use-module (guix-qa-frontpage derivation-changes)
  #:use-module (guix-qa-frontpage view util)
  #:use-module (guix-qa-frontpage view shared)
  #:export (issue-view
            issue-package-changes-view))

(define (issue-view issue-number series mumi-tags
                    comparison-link
                    derivation-changes
                    builds-missing?
                    change-details comparison-details
                    systems-with-low-substitute-availability)

  (define tagged-as-moreinfo?
    (member "moreinfo" mumi-tags))

  (define derivation-changes-counts
    (assq-ref derivation-changes 'counts))

  (layout
   #:title (simple-format #f "Issue ~A" issue-number)
   #:head
   '((style "
td.good {
  padding: 0.05rem 0.65rem;
  font-weight: bold;

  border: 0.3rem dashed green;
}

td.bad {
  padding: 0.05rem 0.65rem;
  font-weight: bold;

  border: 0.3rem dashed red;
}

.tag {
    display: inline-block;
    padding: 0.25em 0.4em;
    margin-left: 0.25em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
    background-color: var(--color-accent);
}
"))
   #:body
   `((main
      (div
       (@ (class "large-screen-float-right"))
       (h3 "Links")
       (ul
        (li
         (a (@ (href ,(simple-format #f "https://issues.guix.gnu.org/~A"
                                     issue-number)))
            "View issue on issues.guix.gnu.org"))
        (li
         (a (@ (href
                ,(let ((branch-name
                        (simple-format #f "issue-~A" issue-number))
                       (base-tag
                        (simple-format #f "base-for-issue-~A" issue-number)))
                   (simple-format
                    #f
                    "~A/log/?h=~A&qt=range&q=~A..~A"
                    "https://git.guix-patches.cbaines.net/guix-patches"
                    branch-name base-tag branch-name))))
            "View Git branch"))
        (li
         (a (@ (href ,(assoc-ref series "web_url")))
            "View series on Patchwork"))
        ,@(if comparison-link
              `((li
                 (a (@ (href ,comparison-link))
                    "View Guix Data Service comparison")))
              '())
        (li
         (a (@ (href
                ,(string-append
                  "mailto:control@debbugs.gnu.org?"
                  "subject="
                  (uri-encode
                   (simple-format #f "tag ~A moreinfo" issue-number))
                  "&body="
                  (uri-encode
                   (string-append
                    (simple-format #f "tags ~A ~A moreinfo"
                                   issue-number
                                   (if tagged-as-moreinfo?
                                       "-"
                                       "+"))
                    "\nquit\n")))))
            ,(if tagged-as-moreinfo?
                 "Remove moreinfo tag"
                 "Mark as moreinfo")))))

      (h2 ,(assoc-ref series "name")
          ,@(map
             (lambda (tag)
               `(span (@ (class "tag"))
                      ,tag))
             (or mumi-tags '())))

      (ul
       ,@(map
          (lambda (patch)
            `(li ,(assoc-ref patch "name")))
          (assoc-ref series "patches")))

      (div
       (h3 "Lint warnings")
       (table
        (thead
         (tr
          (th "Change")
          (th "Linter")
          (th "Message")))
        (tbody
         ,@(if (and comparison-details
                    (not (assq-ref comparison-details 'exception)))
               (if (eq? (vector-length (assoc-ref comparison-details "lint_warnings"))
                        0)
                   `((tr
                      (td (@ (colspan 3))
                          "No lint warning changes"
                          (br)
                          (small "(for lint checkers that don't require the network)"))))
                   (append-map
                    (lambda (package-warnings)
                      (filter-map
                       (lambda (warning)
                         (let ((checker (assoc-ref warning "checker")))
                           (if (string=? (assoc-ref checker "name")
                                         "derivation")
                               #f
                               `(tr
                                 (td (@ (style ,(string-join
                                                 `("border-left-width: 0.35em;"
                                                   "border-left-style: solid;"
                                                   ,(string-append
                                                     "border-left-color: "
                                                     (if (string=? (assoc-ref warning "change")
                                                                   "new")
                                                         "red"
                                                         "green"))))))
                                     ,(assoc-ref warning "change"))
                                 (td
                                  (span (@ (class "monospace")
                                           (style "display: block;"))
                                        ,(assoc-ref checker "name"))
                                  (p (@ (style "font-size: small;"))
                                     ,(assoc-ref checker "description")))
                                 (td ,(assoc-ref warning "message"))))))
                       (vector->list
                        (assoc-ref package-warnings "warnings"))))
                    (vector->list
                     (assoc-ref comparison-details "lint_warnings"))))
               `((tr
                  (td (@ (colspan 3)
                         (class "bad"))
                      "Comparison unavailable"
                      ,@(or (and=>
                             (assq-ref comparison-details 'exception)
                             (lambda (exception)
                               (and=>
                                (assq-ref comparison-details 'invalid_query_parameters)
                                (lambda (invalid-params)
                                  (let ((target-commit
                                         (assoc-ref invalid-params "target_commit")))
                                    (cond
                                     (target-commit
                                      (let ((error (assq-ref target-commit 'error))
                                            (value (assq-ref target-commit 'value)))
                                        `((p
                                           ,(cond
                                             ((eq? error 'yet-to-process-revision)
                                              "Yet to process ")
                                             ((eq? error 'failed-to-process-revision)
                                              "Failed to process ")
                                             (else
                                              "Unknown issue with "))
                                           (a (@ (href ,(string-append
                                                         "https://data.qa.guix.gnu.org/revision/"
                                                         value)))
                                              "revision")))))
                                     (else
                                      #f)))))))
                            '()))))))))

      (div
       (h3 "Package changes")

       ,@(if (or (not builds-missing?)
                 (eq? #f systems-with-low-substitute-availability)
                 (null? systems-with-low-substitute-availability)
                 (not comparison-details)
                 (assq-ref comparison-details 'exception)
                 (null? derivation-changes-counts))
             '()
             ;; TODO: Only show (and apply) this if it relates to these
             ;; changes. So just look at the systems relevant to the changes.
             `((p (@ (style ,(string-join
                              '("text-align: center;"
                                "font-weight: bold;"
                                "padding: 1rem;"
                                "max-width: 46rem;"
                                "border-width: 0.35em;"
                                "border-style: dashed;"
                                "border-color: red"))))
                  "Builds for this patch series not yet submitted as "
                  (a (@ (href "/branch/master"))
                     "master branch substitute availability")
                  " is low for: "
                  ,@(append-map
                     (lambda (system)
                       `((span (@ (style "font-family: monospace; white-space: nowrap;"))
                               ,system
                               " ")))
                     systems-with-low-substitute-availability))))

       ,(package-changes-summary-table
         (let ((revisions (assoc-ref change-details "revisions")))
           `((base . ,(assoc-ref (assoc-ref revisions "base")
                                 "commit"))
             (target . ,(assoc-ref (assoc-ref revisions "target")
                                   "commit"))))
         derivation-changes-counts
         (string-append "/issue/" issue-number)))

      (div
       (h3 "Review checklist")
       (p "This is just to help anyone reviewing the changes.")

       ,@(map
          (match-lambda
            ((id label)
             `(div
               (input (@ (type "checkbox")
                         (id ,id)))
               (label (@ (for ,id)) ,label))))
          '(("lint-warnings" "Lint warnings")
            ("license" "License")
            ("package-builds" "Package builds")
            ("package-tests" "Package tests")
            ("synopsis-and-description" "Synopsis and description")
            ("commit-messages" "Commit messages")))

       (div
        (label (@ (for "notes")) "Notes")
        (textarea (@ (id "notes")))))

      (div
       (h3 "Badges (work in progress)")
       (img
        (@ (src ,(simple-format #f "/issue/~A/status-badge-medium.svg"
                                issue-number)))))))))

(define (issue-package-changes-view issue-number
                                    derivation-changes
                                    query-parameters)
  (package-changes-view
   (simple-format #f "Issue ~A" issue-number)
   derivation-changes
   query-parameters))