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
|
(define-module (guix-qa-frontpage view branch)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:use-module (ice-9 format)
#:use-module (guix-qa-frontpage manage-builds)
#:use-module (guix-qa-frontpage derivation-changes)
#:use-module (guix-qa-frontpage view util)
#:export (branch-view
master-branch-view))
(define (branch-view branch change-details derivation-changes-counts
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)
""))))
(layout
#:title (simple-format #f "Branch ~A" branch)
#:body
`((main
(h2 "Substitute availability")
(div
,@(map
(lambda (details)
`(table
(thead
(tr
(th (@ (colspan 3))
,(assoc-ref
(assoc-ref details "server")
"url"))))
(tbody
,@(map
(lambda (system-and-target-details)
(let* ((ratio
(/ (assoc-ref system-and-target-details
"known")
(+ (assoc-ref system-and-target-details
"known")
(assoc-ref system-and-target-details
"unknown"))))
(color
(cond ((> ratio 0.80) "green")
((< ratio 0.50) "red")
(else #f)))
(symbol
(cond ((> ratio 0.80)
'(*ENTITY* "#9788"))
((< ratio 0.50)
'(*ENTITY* "#9729"))
(else
'(*ENTITY* "#9925")))))
`(tr
(td
(@ (style "font-family: monospace;"))
,(assoc-ref system-and-target-details
"system"))
(td
,(format #f "~,1f%" (* 100. ratio)))
(td (@ (style ,(string-append
"color: black;"
(if color
(simple-format
#f "background-color: ~A;" color)
""))))
,symbol))))
(vector->list
(assoc-ref details "availability"))))))
(vector->list substitute-availability)))
(h2 "Packages")
(div
(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 branch changes")
(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 derivation-changes-counts
(if (null? derivation-changes-counts)
`((tr
(td (@ (colspan 7))
"No package derivation changes")))
(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 7))
"Comparison unavailable")))))))))))
(define (master-branch-view substitute-availability)
(layout
#:title "Branch master"
#:body
`((main
(h2 "Substitute availability")
(div
,@(map
(lambda (details)
`(table
(thead
(tr
(th (@ (colspan 3))
,(assoc-ref
(assoc-ref details "server")
"url"))))
(tbody
,@(map
(lambda (system-and-target-details)
(let* ((ratio
(/ (assoc-ref system-and-target-details
"known")
(+ (assoc-ref system-and-target-details
"known")
(assoc-ref system-and-target-details
"unknown"))))
(color
(cond ((> ratio 0.80) "green")
((< ratio 0.50) "red")
(else "orange")))
(symbol
(cond ((> ratio 0.80)
'(*ENTITY* "#9788"))
((< ratio 0.50)
'(*ENTITY* "#9729"))
(else
'(*ENTITY* "#9925")))))
`(tr
(td
(@ (style "font-family: monospace;"))
,(assoc-ref system-and-target-details
"system"))
(td
,(format #f "~,1f%" (* 100. ratio)))
(td (@ (style ,(string-append
"color: black;"
(if color
(simple-format
#f "background-color: ~A;" color)
""))))
,symbol))))
(vector->list
(assoc-ref details "availability"))))))
(vector->list substitute-availability)))))))
|