Refactoring: better method name
[ci.git] / hbuild / web / diff-rss.xsl
bloba7f2758ebc897d934013e930504d3918b52d256c
1 <!--
2 - Copyright (c) 2018 Vojtech Horky
3 - All rights reserved.
5 - Redistribution and use in source and binary forms, with or without
6 - modification, are permitted provided that the following conditions
7 - are met:
9 - - Redistributions of source code must retain the above copyright
10 - notice, this list of conditions and the following disclaimer.
11 - - Redistributions in binary form must reproduce the above copyright
12 - notice, this list of conditions and the following disclaimer in the
13 - documentation and/or other materials provided with the distribution.
14 - - The name of the author may not be used to endorse or promote products
15 - derived from this software without specific prior written permission.
17 - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 - IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 -->
28 <xsl:stylesheet version="1.0"
29 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
30 xmlns="http://www.w3.org/2005/Atom"
31 xmlns:xhtml="http://www.w3.org/1999/xhtml">
33 <xsl:import href="common.xsl" />
35 <xsl:param name="BASE_URL" select="'http://ci.helenos.org/'" />
36 <xsl:param name="RSS_TAG_PREFIX" select="'ci.helenos.org'" />
37 <xsl:param name="PREVIOUS_REPORTS" select="''" />
40 <xsl:variable name="PREVIOUS_REPORT">
41 <xsl:choose>
42 <xsl:when test="substring-before(normalize-space($PREVIOUS_REPORTS), ' ') = ''">
43 <xsl:value-of select="normalize-space($PREVIOUS_REPORTS)" />
44 </xsl:when>
45 <xsl:otherwise>
46 <xsl:value-of select="substring-before(normalize-space($PREVIOUS_REPORTS), ' ')" />
47 </xsl:otherwise>
48 </xsl:choose>
49 </xsl:variable>
52 <xsl:output method="xml" indent="yes" />
55 <xsl:template match="/" xmlns="http://www.w3.org/2005/Atom">
56 <feed version="2.0" xmlns:xhtml="http://www.w3.org/1999/xhtml">
57 <title>HelenOS nightly builds difference results</title>
58 <description></description>
59 <link href="{$BASE_URL}" />
61 <xsl:if test="normalize-space($PREVIOUS_REPORTS) != ''">
62 <xsl:call-template name="SHOW_DIFF">
63 <xsl:with-param name="FIRST" select="/" />
64 <xsl:with-param name="SECOND" select="document($PREVIOUS_REPORT)" />
65 </xsl:call-template>
66 <xsl:call-template name="MAKE_DIFFS">
67 <xsl:with-param name="BUILDS" select="normalize-space($PREVIOUS_REPORTS)" />
68 </xsl:call-template>
69 </xsl:if>
70 </feed>
71 </xsl:template>
74 <xsl:template name="MAKE_DIFFS">
75 <xsl:param name="BUILDS" />
76 <xsl:variable name="FIRST">
77 <xsl:choose>
78 <xsl:when test="substring-before($BUILDS, ' ') = ''">
79 <xsl:value-of select="$BUILDS" />
80 </xsl:when>
81 <xsl:otherwise>
82 <xsl:value-of select="substring-before($BUILDS, ' ')" />
83 </xsl:otherwise>
84 </xsl:choose>
85 </xsl:variable>
86 <xsl:variable name="REMAINING" select="substring-after($BUILDS, ' ')" />
88 <xsl:if test="$REMAINING != ''" >
89 <xsl:variable name="SECOND">
90 <xsl:choose>
91 <xsl:when test="substring-before($REMAINING, ' ') = ''">
92 <xsl:value-of select="$REMAINING" />
93 </xsl:when>
94 <xsl:otherwise>
95 <xsl:value-of select="substring-before($REMAINING, ' ')" />
96 </xsl:otherwise>
97 </xsl:choose>
98 </xsl:variable>
99 <xsl:call-template name="SHOW_DIFF">
100 <xsl:with-param name="FIRST" select="document($FIRST)" />
101 <xsl:with-param name="SECOND" select="document($SECOND)" />
102 </xsl:call-template>
103 <xsl:call-template name="MAKE_DIFFS">
104 <xsl:with-param name="BUILDS" select="$REMAINING" />
105 </xsl:call-template>
106 </xsl:if>
107 </xsl:template>
109 <xsl:template name="SHOW_DIFF" xmlns="http://www.w3.org/2005/Atom">
110 <xsl:param name="FIRST" />
111 <xsl:param name="SECOND" />
113 <xsl:call-template name="MAKE_ENTRY">
114 <xsl:with-param name="BEFORE" select="$SECOND" />
115 <xsl:with-param name="AFTER" select="$FIRST" />
116 </xsl:call-template>
117 </xsl:template>
120 <xsl:template name="GET_FILENAME">
121 <xsl:param name="ID" />
123 <xsl:value-of select="$WEB_ROOT_ABSOLUTE_FILE_PATH" />
124 <xsl:text>/build-</xsl:text>
125 <xsl:value-of select="$ID" />
126 <xsl:text>/report.xml</xsl:text>
127 </xsl:template>
131 <xsl:template name="MAKE_ENTRY" xmlns="http://www.w3.org/2005/Atom" xmlns:xhtml="http://www.w3.org/1999/xhtml">
132 <xsl:param name="BEFORE" />
133 <xsl:param name="AFTER" />
135 <xsl:variable name="FAILURES_SINCE_LAST_BUILD">
136 <xsl:call-template name="FIND_NEW_FAILURES">
137 <xsl:with-param name="BEFORE" select="$BEFORE" />
138 <xsl:with-param name="AFTER" select="$AFTER" />
139 </xsl:call-template>
140 </xsl:variable>
142 <xsl:variable name="FIXES_SINCE_LAST_BUILD">
143 <xsl:call-template name="FIND_NEW_FIXES">
144 <xsl:with-param name="BEFORE" select="$BEFORE" />
145 <xsl:with-param name="AFTER" select="$AFTER" />
146 </xsl:call-template>
147 </xsl:variable>
149 <xsl:variable name="PERSISTING_FAILURES">
150 <xsl:call-template name="FIND_PERMANENT_FAILURES">
151 <xsl:with-param name="BEFORE" select="$BEFORE" />
152 <xsl:with-param name="AFTER" select="$AFTER" />
153 </xsl:call-template>
154 </xsl:variable>
156 <xsl:variable name="SUMMARY">
157 <xsl:call-template name="MAKE_SUMMARY">
158 <xsl:with-param name="REGRESSION_LIST" select="$FAILURES_SINCE_LAST_BUILD" />
159 <xsl:with-param name="IMPROVEMENT_LIST" select="$FIXES_SINCE_LAST_BUILD" />
160 </xsl:call-template>
161 </xsl:variable>
163 <entry>
164 <title>Build <xsl:value-of select="$AFTER/build/@number" /> (<xsl:value-of select="$SUMMARY" />)</title>
165 <link>
166 <xsl:attribute name="href">
167 <xsl:value-of select="$BASE_URL" />
168 <xsl:text>build-</xsl:text>
169 <xsl:value-of select="$AFTER/build/@number" />
170 <xsl:text>/</xsl:text>
171 </xsl:attribute>
172 </link>
173 <updated><xsl:value-of select="$AFTER/build/buildinfo/@started" /></updated>
174 <id>tag:<xsl:value-of select="$RSS_TAG_PREFIX" />,build-diff-<xsl:value-of select="$BEFORE/build/@number" />-<xsl:value-of select="$AFTER/build/@number" /></id>
175 <content type="xhtml">
176 <xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">
177 <xhtml:h1>HelenOS nightly build <xsl:value-of select="$AFTER/build/@number" /> (<xsl:value-of select="$SUMMARY" />)</xhtml:h1>
178 <xhtml:h2>Broken since build <xsl:value-of select="$BEFORE/build/@number" /></xhtml:h2>
179 <xsl:choose>
180 <xsl:when test="normalize-space($FAILURES_SINCE_LAST_BUILD) = ''">
181 <xhtml:p>No change.</xhtml:p>
182 </xsl:when>
183 <xsl:otherwise>
184 <xhtml:ul>
185 <xsl:call-template name="MAKE_LIST">
186 <xsl:with-param name="ROOT" select="$AFTER" />
187 <xsl:with-param name="LOGS" select="normalize-space($FAILURES_SINCE_LAST_BUILD)" />
188 </xsl:call-template>
189 </xhtml:ul>
190 </xsl:otherwise>
191 </xsl:choose>
193 <xhtml:h2>Fixed since build <xsl:value-of select="$BEFORE/build/@number" /></xhtml:h2>
194 <xsl:choose>
195 <xsl:when test="normalize-space($FIXES_SINCE_LAST_BUILD) = ''">
196 <xhtml:p>No change.</xhtml:p>
197 </xsl:when>
198 <xsl:otherwise>
199 <xhtml:ul>
200 <!-- Remove the link here -->
201 <xsl:call-template name="MAKE_LIST">
202 <xsl:with-param name="ROOT" select="$BEFORE" />
203 <xsl:with-param name="LOGS" select="normalize-space($FIXES_SINCE_LAST_BUILD)" />
204 </xsl:call-template>
205 </xhtml:ul>
206 </xsl:otherwise>
207 </xsl:choose>
209 <xhtml:h2>Still failing</xhtml:h2>
210 <xsl:choose>
211 <xsl:when test="normalize-space($PERSISTING_FAILURES) = ''">
212 <xhtml:p>No other failures.</xhtml:p>
213 </xsl:when>
214 <xsl:otherwise>
215 <xhtml:ul>
216 <!-- Remove the link here -->
217 <xsl:call-template name="MAKE_LIST">
218 <xsl:with-param name="ROOT" select="$AFTER" />
219 <xsl:with-param name="LOGS" select="normalize-space($PERSISTING_FAILURES)" />
220 </xsl:call-template>
221 </xhtml:ul>
222 </xsl:otherwise>
223 </xsl:choose>
224 </xhtml:div>
225 </content>
226 </entry>
227 </xsl:template>
229 <xsl:template name="FIND_NEW_FAILURES">
230 <xsl:param name="BEFORE" />
231 <xsl:param name="AFTER" />
232 <xsl:for-each select="$AFTER/build/*[@result = 'fail']">
233 <xsl:sort />
234 <xsl:variable name="AFTER_LOG" select="./@log" />
235 <xsl:variable name="BEFORE_NODE" select="$BEFORE/build/*[@log=$AFTER_LOG][1]" />
236 <xsl:if test="not($BEFORE_NODE)">
237 <xsl:value-of select="$AFTER_LOG" />
238 <xsl:text> </xsl:text>
239 </xsl:if>
240 </xsl:for-each>
241 <xsl:for-each select="$BEFORE/build/*[@result != 'fail']">
242 <xsl:sort />
243 <xsl:variable name="BEFORE_RESULT" select="./@result" />
244 <xsl:variable name="BEFORE_LOG" select="./@log" />
245 <xsl:variable name="AFTER_NODE" select="$AFTER/build/*[@log=$BEFORE_LOG][1]" />
246 <xsl:variable name="AFTER_RESULT" select="$AFTER_NODE/@result" />
247 <xsl:if test="$AFTER_RESULT = 'fail'">
248 <xsl:value-of select="$BEFORE_LOG" />
249 <xsl:text> </xsl:text>
250 </xsl:if>
251 <xsl:if test="($AFTER_RESULT = 'skip') and ($BEFORE_RESULT = 'ok')">
252 <xsl:value-of select="$BEFORE_LOG" />
253 <xsl:text> </xsl:text>
254 </xsl:if>
255 </xsl:for-each>
256 </xsl:template>
258 <xsl:template name="FIND_NEW_FIXES">
259 <xsl:param name="BEFORE" />
260 <xsl:param name="AFTER" />
261 <xsl:for-each select="$AFTER/build/*[@result = 'ok']">
262 <xsl:sort />
263 <xsl:variable name="AFTER_RESULT" select="./@result" />
264 <xsl:variable name="AFTER_LOG" select="./@log" />
265 <xsl:variable name="BEFORE_NODE" select="$BEFORE/build/*[@log=$AFTER_LOG][1]" />
266 <xsl:variable name="BEFORE_RESULT" select="$BEFORE_NODE/@result" />
267 <xsl:if test="$BEFORE_RESULT = 'fail'">
268 <xsl:value-of select="$AFTER_LOG" />
269 <xsl:text> </xsl:text>
270 </xsl:if>
271 </xsl:for-each>
272 </xsl:template>
274 <xsl:template name="FIND_PERMANENT_FAILURES">
275 <xsl:param name="BEFORE" />
276 <xsl:param name="AFTER" />
277 <xsl:for-each select="$BEFORE/build/*[@result != 'ok']">
278 <xsl:sort select="name()" />
279 <xsl:sort select="@package" />
280 <xsl:sort select="@arch" />
281 <xsl:sort select="@scenario" />
282 <xsl:variable name="BEFORE_RESULT" select="./@result" />
283 <xsl:variable name="BEFORE_LOG" select="./@log" />
284 <xsl:variable name="AFTER_NODE" select="$AFTER/build/*[@log=$BEFORE_LOG][1]" />
285 <xsl:variable name="AFTER_RESULT" select="$AFTER_NODE/@result" />
286 <xsl:if test="($AFTER_RESULT != 'ok') and not(($BEFORE_RESULT = 'skip') and ($AFTER_RESULT = 'fail'))">
287 <xsl:value-of select="$BEFORE_LOG" />
288 <xsl:text> </xsl:text>
289 </xsl:if>
290 </xsl:for-each>
291 </xsl:template>
296 <xsl:template name="MAKE_LIST">
297 <xsl:param name="ROOT" />
298 <xsl:param name="LOGS" />
300 <xsl:variable name="FIRST">
301 <xsl:choose>
302 <xsl:when test="substring-before($LOGS, ' ') = ''">
303 <xsl:value-of select="$LOGS" />
304 </xsl:when>
305 <xsl:otherwise>
306 <xsl:value-of select="substring-before($LOGS, ' ')" />
307 </xsl:otherwise>
308 </xsl:choose>
309 </xsl:variable>
310 <xsl:variable name="REMAINING" select="substring-after($LOGS, ' ')" />
312 <xsl:variable name="NODE" select="$ROOT/build/*[@log=$FIRST][1]" />
314 <xsl:variable name="TEXT">
315 <xsl:apply-templates select="$NODE" mode="failure-list" />
316 </xsl:variable>
318 <xhtml:li>
319 <xhtml:a>
320 <xsl:attribute name="href">
321 <xsl:value-of select="$BASE_URL" />
322 <xsl:text>build-</xsl:text>
323 <xsl:value-of select="$ROOT/build/@number" />
324 <xsl:text>/</xsl:text>
325 <xsl:value-of select="$NODE/@log" />
326 </xsl:attribute>
327 <xsl:value-of select="$TEXT" />
328 </xhtml:a>
329 </xhtml:li>
331 <xsl:if test="$REMAINING != ''" >
332 <xsl:call-template name="MAKE_LIST">
333 <xsl:with-param name="ROOT" select="$ROOT" />
334 <xsl:with-param name="LOGS" select="$REMAINING" />
335 </xsl:call-template>
336 </xsl:if>
337 </xsl:template>
340 <xsl:template match="browsable-sources-global" mode="failure-list">
341 <xsl:text>Browsable sources.</xsl:text>
342 </xsl:template>
344 <xsl:template match="checkout" mode="failure-list">
345 <xsl:text>Checkout of </xsl:text>
346 <xsl:value-of select="@repository" />
347 <xsl:text>.</xsl:text>
348 </xsl:template>
350 <xsl:template match="harbour-build" mode="failure-list">
351 <xsl:text>Harbour build of </xsl:text>
352 <xsl:value-of select="@package" />
353 <xsl:text> for </xsl:text>
354 <xsl:value-of select="@arch" />
355 <xsl:text>.</xsl:text>
356 </xsl:template>
358 <xsl:template match="harbour-fetch" mode="failure-list">
359 <xsl:text>Harbour fetch for </xsl:text>
360 <xsl:value-of select="@package" />
361 <xsl:text>.</xsl:text>
362 </xsl:template>
364 <xsl:template match="helenos-build" mode="failure-list">
365 <xsl:text>HelenOS build for </xsl:text>
366 <xsl:value-of select="@arch" />
367 <xsl:text>.</xsl:text>
368 </xsl:template>
370 <xsl:template match="helenos-extra-build" mode="failure-list">
371 <xsl:text>HelenOS extra build with </xsl:text>
372 <xsl:value-of select="@harbours" />
373 <xsl:text> for </xsl:text>
374 <xsl:value-of select="@arch" />
375 <xsl:text>.</xsl:text>
376 </xsl:template>
378 <xsl:template match="sycek-style-check" mode="failure-list">
379 <xsl:text>Sycek C style check.</xsl:text>
380 </xsl:template>
382 <xsl:template match="test" mode="failure-list">
383 <xsl:text>Automated test </xsl:text>
384 <xsl:value-of select="@scenario" />
385 <xsl:text> on </xsl:text>
386 <xsl:value-of select="@arch" />
387 <xsl:text>.</xsl:text>
388 </xsl:template>
390 <xsl:template match="tool-build" mode="failure-list">
391 <xsl:text>Build of </xsl:text>
392 <xsl:value-of select="@tool" />
393 <xsl:text> tool.</xsl:text>
394 </xsl:template>
397 <xsl:template match="*" mode="failure-list">
398 <xsl:value-of select="name()" />
399 <xsl:text>.</xsl:text>
400 </xsl:template>
403 <xsl:template name="MAKE_SUMMARY">
404 <xsl:param name="REGRESSION_LIST" select="''" />
405 <xsl:param name="IMPROVEMENT_LIST" select="''" />
407 <xsl:variable name="REGRESSION_COUNT">
408 <xsl:call-template name="COUNT_ITEMS">
409 <xsl:with-param name="LIST" select="normalize-space($REGRESSION_LIST)" />
410 </xsl:call-template>
411 </xsl:variable>
413 <xsl:variable name="IMPROVEMENT_COUNT">
414 <xsl:call-template name="COUNT_ITEMS">
415 <xsl:with-param name="LIST" select="normalize-space($IMPROVEMENT_LIST)" />
416 </xsl:call-template>
417 </xsl:variable>
419 <!--
420 <xsl:text>[</xsl:text>
421 <xsl:value-of select="$REGRESSION_COUNT" />
422 <xsl:text>:</xsl:text>
423 <xsl:value-of select="$IMPROVEMENT_COUNT" />
424 <xsl:text>]</xsl:text>
427 <xsl:variable name="REGRESSION_TEXT">
428 <xsl:choose>
429 <xsl:when test="$REGRESSION_COUNT = 1">
430 <xsl:text>1 regression</xsl:text>
431 </xsl:when>
432 <xsl:otherwise>
433 <xsl:value-of select="$REGRESSION_COUNT" />
434 <xsl:text> regressions</xsl:text>
435 </xsl:otherwise>
436 </xsl:choose>
437 </xsl:variable>
439 <xsl:variable name="IMPROVEMENT_TEXT">
440 <xsl:choose>
441 <xsl:when test="$IMPROVEMENT_COUNT = 1">
442 <xsl:text>1 fix</xsl:text>
443 </xsl:when>
444 <xsl:otherwise>
445 <xsl:value-of select="$IMPROVEMENT_COUNT" />
446 <xsl:text> fixes</xsl:text>
447 </xsl:otherwise>
448 </xsl:choose>
449 </xsl:variable>
451 <xsl:choose>
452 <xsl:when test="$REGRESSION_COUNT + $IMPROVEMENT_COUNT = 0">
453 <xsl:text>no change</xsl:text>
454 </xsl:when>
455 <xsl:when test="$REGRESSION_COUNT = 0">
456 <xsl:value-of select="$IMPROVEMENT_TEXT" />
457 </xsl:when>
458 <xsl:when test="$IMPROVEMENT_COUNT = 0">
459 <xsl:value-of select="$REGRESSION_TEXT" />
460 </xsl:when>
461 <xsl:otherwise>
462 <xsl:value-of select="$REGRESSION_TEXT" />
463 <xsl:text>, </xsl:text>
464 <xsl:value-of select="$IMPROVEMENT_TEXT" />
465 </xsl:otherwise>
466 </xsl:choose>
467 </xsl:template>
469 <xsl:template name="COUNT_ITEMS">
470 <xsl:param name="LIST" select="''" />
472 <xsl:variable name="FIRST">
473 <xsl:choose>
474 <xsl:when test="substring-before($LIST, ' ') = ''">
475 <xsl:value-of select="$LIST" />
476 </xsl:when>
477 <xsl:otherwise>
478 <xsl:value-of select="substring-before($LIST, ' ')" />
479 </xsl:otherwise>
480 </xsl:choose>
481 </xsl:variable>
483 <xsl:variable name="REMAINING" select="substring-after($LIST, ' ')" />
485 <xsl:variable name="REMAINING_COUNT">
486 <xsl:choose>
487 <xsl:when test="$REMAINING = ''">0</xsl:when>
488 <xsl:otherwise>
489 <xsl:call-template name="COUNT_ITEMS">
490 <xsl:with-param name="LIST" select="$REMAINING" />
491 </xsl:call-template>
492 </xsl:otherwise>
493 </xsl:choose>
494 </xsl:variable>
496 <xsl:variable name="RESULT">
497 <xsl:choose>
498 <xsl:when test="$FIRST = ''">0</xsl:when>
499 <xsl:otherwise><xsl:value-of select="1 + $REMAINING_COUNT" /></xsl:otherwise>
500 </xsl:choose>
501 </xsl:variable>
503 <xsl:value-of select="$RESULT" />
504 </xsl:template>
506 </xsl:stylesheet>