aboutsummaryrefslogtreecommitdiff
path: root/guix-qa-frontpage/view/issue.scm
blob: 133e0a689051e9bac43ab087cc1d5021989d1993 (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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
(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)
  #:export (issue-view))

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

  (define* (package-derivations-comparison-link system
                                                #:key build-change)
    (let ((revisions
           (assoc-ref change-details "revisions")))
      (string-append
       (simple-format #f "https://data.qa.guix.gnu.org/compare/package-derivations?base_commit=~A&target_commit=~A&system=~A&target=none"
                      (assoc-ref (assoc-ref revisions "base")
                                 "commit")
                      (assoc-ref (assoc-ref revisions "target")
                                 "commit")
                      system)
       (if build-change
           (simple-format #f "&build_change=~A" build-change)
           ""))))

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

  (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))))

       (table
        (@ (style "border-collapse: collapse;"))
        (thead
         (tr
          (th (@ (rowspan 3)) "System")
          (th (@ (colspan 8)) "Package build status")
          (th))
         (tr
          (th (@ (colspan 4)) "Base")
          (th (@ (colspan 4)
                 (style "border-left-width: 0.1em; border-left-style: solid; border-left-color: black"))
              "With patches applied")
          (th))
         (tr
          ,@(let ((header-style
                   "font-size: 80%; min-width: 3.5rem;"))
              `((th (@ (style ,header-style))
                    "Succeeding")
                (th (@ (style ,header-style))
                    "Failing")
                (th (@ (style ,header-style))
                    "Blocked")
                (th (@ (style ,header-style))
                    "Unknown")
                (th (@ (style
                           ,(string-append
                             header-style
                             " border-left-width: 0.125em; border-left-style: solid; border-left-color: black;")))
                    "Succeeding")
                (th (@ (style ,header-style))
                    "Failing")
                (th (@ (style ,header-style))
                    "Blocked")
                (th (@ (style ,header-style))
                    "Unknown")
                (th)))))
        (tbody
         ,@(if (and comparison-details
                    (not (assq-ref comparison-details 'exception))
                    derivation-changes-counts)
               (if (null? derivation-changes-counts)
                   `((tr
                      (td (@ (colspan 10))
                          "No package derivation changes"
                          (br)
                          (small "(for the following systems: "
                                 ,@(drop-right
                                    (append-map
                                     (lambda (system)
                                       `((span (@ (style "font-family: monospace;"))
                                               ,system)
                                         ", "))
                                     %systems-to-submit-builds-for)
                                    1)
                                 ")"))))
                   (map
                    (match-lambda
                      ((system . counts)
                       (define (count side status)
                         (assoc-ref (assoc-ref
                                     counts
                                     side)
                                    status))
                       `(tr
                         (td (@ (class "monospace")) ,system)
                         ,@(map (lambda (status)
                                  `(td ,(count 'base status)))
                                '(succeeding failing blocked unknown))
                         (td ,@(if (and (>= (count 'target 'succeeding)
                                            (count 'base 'succeeding))
                                        (> (count 'target 'succeeding)
                                           0))
                                   `((@ (class "good")))
                                   '())
                             ,(count 'target 'succeeding))
                         ,(if (> (count 'target 'failing)
                                 (count 'base 'failing))
                              `(td (@ (class "bad"))
                                   ,(count 'target 'failing))
                              `(td ,(count 'target 'failing)))
                         ,(if (> (count 'target 'blocked)
                                 (count 'base 'blocked))
                              `(td (@ (class "bad"))
                                   ,(count 'target 'blocked))
                              `(td ,(count 'target 'blocked)))
                         ,(if (> (count 'target 'unknown)
                                 (count 'base 'unknown))
                              `(td (@ (class "bad"))
                                   ,(count 'target 'unknown))
                              `(td ,(count 'target 'unknown)))
                         (td (a (@ (href
                                    ,(package-derivations-comparison-link system)))
                                "View comparison")))))
                    derivation-changes-counts))
               `((tr
                  (td (@ (colspan 10)
                         (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 "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)))))))))