Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
2b6389ebe86aebb239bc2d61488dc81036c94b5e
[simgrid.git] / tools / jenkins / project_description.sh
1 #!/usr/bin/env bash
2
3 get_boost(){
4     BOOST=$(grep -m 1 "Boost version:" ./consoleText | sed  "s/.*-- Boost version: \([a-zA-Z0-9\.]*\)/\1/g")
5     if [ -z "$BOOST" ]
6     then
7       BOOST=$(grep -m 1 "Found Boost:" ./consoleText | sed  "s/.*-- Found Boost:.*found suitable version \"\([a-zA-Z0-9\.]*\)\",.*/\1/g")
8     fi
9   echo "$BOOST"
10 }
11
12 get_compiler(){
13     grep -m 1 "The C compiler identification" ./consoleText | sed  "s/.*-- The C compiler identification is \([a-zA-Z0-9\.]*\)/\1/g"
14 }
15
16 get_java(){
17     grep -m 1 "Found Java:" ./consoleText | sed "s/.*-- Found Java.*found suitable version \"\([a-zA-Z0-9\.]*\)\",.*/\1/g"
18 }
19
20 get_cmake(){
21     grep -m 1 "Cmake version" ./consoleText| sed "s/.*-- Cmake version \([a-zA-Z0-9\.]*\)/\1/g"
22 }
23
24 get_eigen3(){
25   found=$(grep -c "Found Eigen3:" ./consoleText)
26   if [ "$found" != 0 ]; then
27     echo "✔"
28   else
29     echo ""
30   fi
31 }
32
33 get_ns3(){
34   grep -m 1 "ns-3 found (v3.[0-9]*; incl:" ./consoleText | sed "s/.*-- ns-3 found .v\(3.[0-9]*\); incl:.*/\1/g"
35 }
36
37 get_python(){
38   found=$(grep -c "Compile Python bindings .....: ON" ./consoleText)
39   if [ "$found" != 0 ]; then
40     grep -m 1 "Found Python3" ./consoleText| sed "s/.*-- Found Python3.*found version \"\([a-zA-Z0-9\.]*\)\".*/\1/g"
41   else
42     echo ""
43   fi
44 }
45
46 if [ -f consoleText ]; then
47   rm consoleText
48 fi
49
50
51 if [ -z "$BUILD_URL" ]; then
52   BUILD_URL="https://ci.inria.fr/simgrid/job/SimGrid/lastBuild"
53 fi
54
55 #get the list of nodes on jenkins
56 wget --quiet ${BUILD_URL}/consoleText >/dev/null 2>&1
57 nodes=($(sed -n 's/^Triggering SimGrid [^ ]* Debug,//p' ./consoleText| sort))
58 rm consoleText
59
60 cat <<EOF
61 <br>Description of the nodes - Automatically updated by project_description.sh script - Don't edit here<br><br>
62 <script>
63 function compareVersion(v1, v2) {
64     if (typeof v1 !== 'string') return false;
65     if (typeof v2 !== 'string') return false;
66     v1 = v1.split('.');
67     v2 = v2.split('.');
68     const k = Math.min(v1.length, v2.length);
69     for (let i = 0; i < k; ++ i) {
70         v1[i] = parseInt(v1[i], 10);
71         v2[i] = parseInt(v2[i], 10);
72         if (v1[i] > v2[i]) return 1;
73         if (v1[i] < v2[i]) return -1;
74     }
75     return v1.length == v2.length ? 0: (v1.length < v2.length ? -1 : 1);
76 }</script>
77 <script>
78 function sortTable(n, type) {
79   var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
80   table = document.getElementById('configuration-matrix');
81   switching = true;
82   //Set the sorting direction to ascending:
83   dir = 'asc';
84   /*Make a loop that will continue until
85   no switching has been done:*/
86   while (switching) {
87     //start by saying: no switching is done:
88     switching = false;
89     rows = table.rows;
90     /*Loop through all table rows (except the
91     first, which contains table headers):*/
92     for (i = 1; i < (rows.length - 1); i++) {
93       //start by saying there should be no switching:
94       shouldSwitch = false;
95       /*Get the two elements you want to compare,
96       one from current row and one from the next:*/
97       x = rows[i].getElementsByTagName('TD')[n];
98       y = rows[i + 1].getElementsByTagName('TD')[n];
99       /*check if the two rows should switch place,
100       based on the direction, asc or desc:*/
101       if (dir == 'asc') {
102         if(type == 'version'){
103           shouldSwitch = (compareVersion(x.innerHTML.toLowerCase(), y.innerHTML.toLowerCase()) > 0);
104         }else{
105           shouldSwitch = (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase());
106         }
107       } else if (dir == 'desc') {
108         if(type == 'version'){
109           shouldSwitch = (compareVersion(x.innerHTML.toLowerCase(), y.innerHTML.toLowerCase()) < 0);
110         }else{
111           shouldSwitch = (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase());
112         }
113       }
114       if (shouldSwitch)
115         break;
116     }
117     if (shouldSwitch) {
118       /*If a switch has been marked, make the switch
119       and mark that a switch has been done:*/
120       rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
121       switching = true;
122       //Each time a switch is done, increase this count by 1:
123       switchcount ++;
124     } else {
125       /*If no switching has been done AND the direction is 'asc',
126       set the direction to 'desc' and run the while loop again.*/
127       if (switchcount == 0 && dir == 'asc') {
128         dir = 'desc';
129         switching = true;
130       }
131     }
132   }
133 }
134 </script>
135 <table id=configuration-matrix>
136   <tr class=matrix-row>
137     <td class=matrix-header style=min-width:75px onclick='sortTable($((col=0)));'>Name of the Builder</td>
138     <td class=matrix-header style=min-width:75px onclick='sortTable($((++col)));'>OS</td>
139     <td class=matrix-header style=min-width:50px onclick='sortTable($((++col,0)));'>Debug</td>
140     <td class=matrix-header style=min-width:50px onclick='sortTable($((++col,0)));'>MC</td>
141     <td class=matrix-header style=min-width:75px onclick='sortTable($((++col)));'>Compiler</td>
142     <td class=matrix-header style=min-width:75px onclick="sortTable($((++col)),'version');">Boost</td>
143     <td class=matrix-header style=min-width:75px onclick="sortTable($((++col)),'version');">Java</td>
144     <td class=matrix-header style=min-width:75px onclick="sortTable($((++col)),'version');">Cmake</td>
145     <td class=matrix-header style=min-width:50px onclick='sortTable($((++col)));'>Eigen3</td>
146     <td class=matrix-header style=min-width:50px onclick="sortTable($((++col)),'version');">ns-3</td>
147     <td class=matrix-header style=min-width:50px onclick="sortTable($((++col)),'version');">Python</td>
148   </tr>
149 EOF
150
151 declare -A icons
152 icons=(
153     [success]="img src=https://ci.inria.fr/simgrid/images/24x24/blue.png"
154     [failure]="img src=https://ci.inria.fr/simgrid/images/24x24/red.png"
155     [disabled]="img src=https://ci.inria.fr/simgrid/images/24x24/disabled.png"
156 )
157
158 for node in "${nodes[@]}"
159 do
160     wget --quiet --output-document=consoleText \
161          ${BUILD_URL}/build_mode=Debug,node=${node}/consoleText \
162          ${BUILD_URL}/build_mode=ModelChecker,node=${node}/consoleText \
163          >/dev/null 2>&1
164     if [ ! -f consoleText ]; then
165       echo "file not existing for node ${node}"
166       exit 1
167     fi
168     boost=$(get_boost)
169     compiler=$(get_compiler)
170     java=$(get_java)
171     cmake=$(get_cmake)
172     eigen3=$(get_eigen3)
173     ns3=$(get_ns3)
174     py=$(get_python)
175     os=$(grep -m 1 "OS Version" ./consoleText| sed "s/OS Version : \(.*\)/\1/g")
176
177     color1=""
178     color2=""
179     #in case of success, replace blue by green in status balls
180     wget --quiet https://ci.inria.fr/simgrid/buildStatus/text?job=SimGrid%2Fbuild_mode%3DDebug%2Cnode%3D"${node}" -O status  >/dev/null 2>&1
181
182     status=$(cat status)
183     if [ "$status" == "Success" ]; then
184       color1="&color=green"
185     fi
186     rm status
187     statusdebug="<a href=\"build_mode=Debug,node=${node}/\"><img src=\"https://ci.inria.fr/simgrid/job/SimGrid/build_mode=Debug,node=${node}/badge/icon?style=ball-24x24${color1}\"/>"
188
189     statusmc="<${icons[disabled]}>"
190     wget --quiet https://ci.inria.fr/simgrid/buildStatus/text?job=SimGrid%2Fbuild_mode%3DModelChecker%2Cnode%3D"${node}" -O status >/dev/null 2>&1
191     status=$(cat status)
192     if [ "$status" ]; then
193       if [ "$status" == "Success" ]; then
194         color2="&color=green"
195       fi
196       statusmc="<a href=\"build_mode=ModelChecker,node=${node}/\"><img src=\"https://ci.inria.fr/simgrid/job/SimGrid/build_mode=ModelChecker,node=${node}/badge/icon?style=ball-24x24${color2}\"/>"
197     fi
198     rm status
199
200     cat <<EOF
201   <tr>
202     <td class="matrix-leftcolumn">$node</td>
203     <td class="matrix-cell" style="text-align:left">$os</td>
204     <td class="matrix-cell" style="text-align:center">${statusdebug}</td>
205     <td class="matrix-cell" style="text-align:center">${statusmc}</td>
206     <td class="matrix-cell" style="text-align:left">$compiler</td>
207     <td class="matrix-cell" style="text-align:left">$boost</td>
208     <td class="matrix-cell" style="text-align:left">$java</td>
209     <td class="matrix-cell" style="text-align:left">$cmake</td>
210     <td class="matrix-cell" style="text-align:center">$eigen3</td>
211     <td class="matrix-cell" style="text-align:left">$ns3</td>
212     <td class="matrix-cell" style="text-align:left">$py</td>
213   </tr>
214 EOF
215     rm consoleText
216 done
217
218
219 #Appveyor - get ID of the last job with the API
220 BUILD_ID=$(curl -s "https://ci.appveyor.com/api/projects/mquinson/simgrid" | grep -o '\[{"jobId":"[a-zA-Z0-9]*",' | sed "s/\[{\"jobId\":\"//" | sed "s/\",//")
221 wget --quiet https://ci.appveyor.com/api/buildjobs/"$BUILD_ID"/log -O ./consoleText >/dev/null 2>&1
222 sed -i -e "s/\r//g" ./consoleText
223 node="<a href=\"https://ci.appveyor.com/project/mquinson/simgrid\">appveyor</a>"
224 os="Windows Server 2012 - VS2015 + mingw64 5.3.0"
225 boost=$(get_boost)
226 compiler=$(get_compiler)
227 java=$(get_java)
228 cmake=$(get_cmake)
229 eigen3=$(get_eigen3)
230 ns3=$(get_ns3)
231 py=$(get_python)
232 success=$(grep -m 1 "Build success" ./consoleText)
233 ball="${icons[failure]}"
234 if [ -n "$success" ]; then
235   ball="${icons[success]}"
236 fi
237 cat <<EOF
238   <tr>
239     <td class="matrix-leftcolumn">$node</td>
240     <td class="matrix-cell" style="text-align:left">$os</td>
241     <td class="matrix-cell" style="text-align:center"><${ball}></td>
242     <td class="matrix-cell" style="text-align:center"><${icons[disabled]}></td>
243     <td class="matrix-cell" style="text-align:left">$compiler</td>
244     <td class="matrix-cell" style="text-align:left">$boost</td>
245     <td class="matrix-cell" style="text-align:left">$java</td>
246     <td class="matrix-cell" style="text-align:left">$cmake</td>
247     <td class="matrix-cell" style="text-align:center">$eigen3</td>
248     <td class="matrix-cell" style="text-align:left">$ns3</td>
249     <td class="matrix-cell" style="text-align:left">$py</td>
250   </tr>
251 EOF
252 rm consoleText
253
254 echo "</table>"