Test in VM OCR improvements
[ci.git] / hbuild / web / common.xsl
blob67469b59254f60fa21c81ed34189dbab9ad6703c
1 <!--
2 - Copyright (c) 2017 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/1999/xhtml">
32 <xsl:output method="html" indent="yes" />
34 <xsl:param name="CONFIG_RESOURCE_DIR" select="''" />
35 <xsl:param name="CONFIG_RSS_PATH" select="''" />
37 <xsl:template name="HTML_PAGE">
38 <xsl:param name="TITLE" />
39 <xsl:param name="EXTRA_HEAD" select="''" />
40 <xsl:param name="BODY" />
41 <html>
42 <head>
43 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
44 <title><xsl:value-of select="$TITLE" /></title>
45 <script type="text/javascript" src="{$CONFIG_RESOURCE_DIR}jquery-2.1.4.min.js"></script>
46 <link rel="stylesheet" href="{$CONFIG_RESOURCE_DIR}main.css" type="text/css" />
47 <xsl:if test="$CONFIG_RSS_PATH != ''">
48 <link rel="alternate" href="{$CONFIG_RSS_PATH}" type="application/rss+xml" title="Last builds" />
49 </xsl:if>
50 <xsl:copy-of select="$EXTRA_HEAD" />
51 </head>
52 <body>
53 <xsl:copy-of select="$BODY" />
54 </body>
55 </html>
56 </xsl:template>
59 <xsl:template match="build" mode="html-summary-table">
60 <table class="summary">
61 <thead>
62 <tr>
63 <th width="*">Task</th>
64 <th style="width:8em">Success</th>
65 <th width="width:40em">Details (total = ok + failed + skipped)</th>
66 </tr>
67 </thead>
68 <tbody>
69 <xsl:call-template name="html-summary-table-row">
70 <xsl:with-param name="task" select="'checkout'" />
71 <xsl:with-param name="title" select="'Repository checkouts'" />
72 </xsl:call-template>
73 <xsl:call-template name="html-summary-table-row">
74 <xsl:with-param name="task" select="'helenos-build'" />
75 <xsl:with-param name="title" select="'HelenOS builds'" />
76 </xsl:call-template>
77 <xsl:call-template name="html-summary-table-row">
78 <xsl:with-param name="task" select="'harbour-fetch'" />
79 <xsl:with-param name="title" select="'Tarball fetches for Coastline'" />
80 </xsl:call-template>
81 <xsl:call-template name="html-summary-table-row">
82 <xsl:with-param name="task" select="'harbour-build'" />
83 <xsl:with-param name="title" select="'Coastline builds'" />
84 </xsl:call-template>
85 <xsl:call-template name="html-summary-table-row">
86 <xsl:with-param name="task" select="'test'" />
87 <xsl:with-param name="title" select="'Testing scenarios'" />
88 </xsl:call-template>
89 </tbody>
90 </table>
91 </xsl:template>
94 <xsl:template name="html-summary-table-row">
95 <xsl:param name="task" />
96 <xsl:param name="title" />
97 <xsl:variable name="taskOk" select="count(*[name()=$task and @result='ok'])" />
98 <xsl:variable name="taskFail" select="count(*[name()=$task and @result='fail'])" />
99 <xsl:variable name="taskSkip" select="count(*[name()=$task and @result='skip'])" />
100 <xsl:variable name="taskAll" select="count(*[name()=$task])" />
101 <xsl:variable name="percents">
102 <xsl:choose>
103 <xsl:when test="$taskAll = 0">
104 <xsl:text>-</xsl:text>
105 </xsl:when>
106 <xsl:otherwise>
107 <xsl:value-of select="round(100 * $taskOk div $taskAll)" /><xsl:text> %</xsl:text>
108 </xsl:otherwise>
109 </xsl:choose>
110 </xsl:variable>
111 <xsl:variable name="trClass">
112 <xsl:choose>
113 <xsl:when test="$taskAll = 0">
114 <xsl:text>results-none</xsl:text>
115 </xsl:when>
116 <xsl:otherwise>
117 <xsl:text>results-</xsl:text>
118 <xsl:value-of select="10 * floor(10 * $taskOk div $taskAll)" />
119 </xsl:otherwise>
120 </xsl:choose>
121 </xsl:variable>
122 <tr>
123 <xsl:attribute name="class">
124 <xsl:value-of select="$trClass" />
125 </xsl:attribute>
126 <td>
127 <xsl:value-of select="$title" />
128 </td>
129 <td>
130 <xsl:value-of select="$percents" />
131 </td>
132 <td>
133 <xsl:value-of select="$taskAll" />
134 <xsl:text> = </xsl:text>
135 <xsl:value-of select="$taskOk" />
136 <xsl:text> + </xsl:text>
137 <xsl:value-of select="$taskFail" />
138 <xsl:text> + </xsl:text>
139 <xsl:value-of select="$taskSkip" />
140 </td>
141 </tr>
142 </xsl:template>
144 </xsl:stylesheet>