Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add some grey
[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_ns3(){
25   found=$(grep -c "ns-3 found" ./consoleText)
26   if [ $found != 0 ]; then
27     echo "✔"
28   else
29     echo ""
30   fi
31 }
32
33 get_python(){
34   found=$(grep -c "Compile Python bindings .....: ON" ./consoleText)
35   if [ $found != 0 ]; then
36     echo "✔"
37   else
38     echo ""
39   fi
40 }
41
42 if [ -f consoleText ]; then
43   rm consoleText
44 fi
45
46
47 if [ -z $BUILD_URL ]; then
48   BUILD_URL="https://ci.inria.fr/simgrid/job/SimGrid/lastBuild"
49 fi
50
51 #get the list of nodes on jenkins
52 wget --quiet ${BUILD_URL}/consoleText >/dev/null 2>&1
53 nodes=($(sed -n 's/^Triggering SimGrid [^ ]* Debug,//p' ./consoleText| sort))
54 rm consoleText
55
56
57 echo "<br>Description of the nodes - Automatically updated by project_description.sh script - Don't edit here<br><br>
58 <script>
59 function compareVersion(v1, v2) {
60     if (typeof v1 !== 'string') return false;
61     if (typeof v2 !== 'string') return false;
62     v1 = v1.split('.');
63     v2 = v2.split('.');
64     const k = Math.min(v1.length, v2.length);
65     for (let i = 0; i < k; ++ i) {
66         v1[i] = parseInt(v1[i], 10);
67         v2[i] = parseInt(v2[i], 10);
68         if (v1[i] > v2[i]) return 1;
69         if (v1[i] < v2[i]) return -1;        
70     }
71     return v1.length == v2.length ? 0: (v1.length < v2.length ? -1 : 1);
72 }</script>
73 <script>
74 function sortTable(n, type) {
75   var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
76   table = document.getElementById('configuration-matrix');
77   switching = true;
78   //Set the sorting direction to ascending:
79   dir = 'asc'; 
80   /*Make a loop that will continue until
81   no switching has been done:*/
82   while (switching) {
83     //start by saying: no switching is done:
84     switching = false;
85     rows = table.rows;
86     /*Loop through all table rows (except the
87     first, which contains table headers):*/
88     for (i = 1; i < (rows.length - 1); i++) {
89       //start by saying there should be no switching:
90       shouldSwitch = false;
91       /*Get the two elements you want to compare,
92       one from current row and one from the next:*/
93       x = rows[i].getElementsByTagName('TD')[n];
94       y = rows[i + 1].getElementsByTagName('TD')[n];
95       /*check if the two rows should switch place,
96       based on the direction, asc or desc:*/
97       if (dir == 'asc') {
98         if(type == 'version'){
99           shouldSwitch = (compareVersion(x.innerHTML.toLowerCase(), y.innerHTML.toLowerCase()) > 0);
100         }else{
101           shouldSwitch = (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase());
102         }
103       } else if (dir == 'desc') {
104         if(type == 'version'){
105           shouldSwitch = (compareVersion(x.innerHTML.toLowerCase(), y.innerHTML.toLowerCase()) < 0);
106         }else{
107           shouldSwitch = (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase());
108         }
109       }
110       if (shouldSwitch)
111         break;
112     }
113     if (shouldSwitch) {
114       /*If a switch has been marked, make the switch
115       and mark that a switch has been done:*/
116       rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
117       switching = true;
118       //Each time a switch is done, increase this count by 1:
119       switchcount ++;      
120     } else {
121       /*If no switching has been done AND the direction is 'asc',
122       set the direction to 'desc' and run the while loop again.*/
123       if (switchcount == 0 && dir == 'asc') {
124         dir = 'desc';
125         switching = true;
126       }
127     }
128   }
129 }</script>
130 <table id=configuration-matrix> 
131 <tr class=matrix-row>  <td class=matrix-header style=min-width:75px onclick='sortTable(0);'>Name of the Builder</td><td class=matrix-header style=min-width:75px onclick='sortTable(1);'>OS</td><td class=matrix-header style=min-width:75px onclick='sortTable(2);'>Compiler</td><td class=matrix-header style=min-width:75px onclick=\"sortTable(3, 'version');\">Boost</td><td class=matrix-header style=min-width:75px onclick=\"sortTable(4,'version');\">Java</td><td class=matrix-header style=min-width:75px onclick=\"sortTable(5,'version');\">Cmake</td><td class=matrix-header style=min-width:50px onclick='sortTable(6);'>ns-3</td><td class=matrix-header style=min-width:50px onclick='sortTable(7);'>Python</td><td class=matrix-header style=min-width:50px onclick='sortTable(1);'>Debug</td><td class=matrix-header style=min-width:50px onclick='sortTable(1);'>MC</td></tr>"
132
133 for node in "${nodes[@]}"
134 do
135     wget --quiet ${BUILD_URL}/build_mode=Debug,node=${node}/consoleText >/dev/null 2>&1
136     if [ ! -f consoleText ]; then
137       echo "file not existing for node ${node}"
138       exit 1
139     fi
140     boost=$(get_boost)
141     compiler=$(get_compiler)
142     java=$(get_java)
143     cmake=$(get_cmake)
144     ns3=$(get_ns3)
145     py=$(get_python)
146     os=$(grep -m 1 "OS Version" ./consoleText| sed "s/OS Version : \(.*\)/\1/g")
147     
148     color1=""
149     color2=""
150     #in case of success, replace blue by green in status balls
151     wget --quiet https://ci.inria.fr/simgrid/buildStatus/text?job=SimGrid%2Fbuild_mode%3DDebug%2Cnode%3D${node} -O status  >/dev/null 2>&1
152     status=$(cat status)
153     if [ $status == "Success" ]; then
154       color1="&color=green"
155     fi
156     rm status
157     statusmc="<img src=https://ci.inria.fr/simgrid/images/24x24/grey.png>"
158     wget --quiet https://ci.inria.fr/simgrid/buildStatus/text?job=SimGrid%2Fbuild_mode%3DModelChecker%2Cnode%3D${node} -O status >/dev/null 2>&1
159     status=$(cat status)
160     if [ $status ]; then 
161       if [ $status == "Success" ]; then
162         color2="&color=green"
163       fi
164       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}\"/>"
165     fi
166     rm status
167     echo "<tr> <td class=\"matrix-leftcolumn\">$node</td><td class=\"matrix-cell\" style=\"text-align:left\">$os</td><td class=\"matrix-cell\" style=\"text-align:left\">$compiler</td><td class=\"matrix-cell\" style=\"text-align:left\">$boost</td><td class=\"matrix-cell\" style=\"text-align:left\">$java</td><td class=\"matrix-cell\" style=\"text-align:left\">$cmake</td><td class=\"matrix-cell\" style=\"text-align:center\">$ns3</td><td class=\"matrix-cell\" style=\"text-align:center\">$py</td><td class="matrix-cell" style="text-align:center"><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}"/></td><td class="matrix-cell" style="text-align:center">${statusmc}</td></tr>"
168     rm consoleText
169 done
170
171
172 #Travis - get ID of the last jobs with the API
173 BUILD_NUM=$(curl -s 'https://api.travis-ci.org/repos/simgrid/simgrid/builds?limit=1' | grep -o '^\[{"id":[0-9]*,' | grep -o '[0-9]' | tr -d '\n')
174 BUILDS=($(curl -s https://api.travis-ci.org/repos/simgrid/simgrid/builds/${BUILD_NUM} | grep -o '{"id":[0-9]*,' | grep -o '[0-9]*'| tail -n 3))
175
176 for id in "${!BUILDS[@]}"
177 do
178     wget --quiet https://api.travis-ci.org/v3/job/${BUILDS[$id]}/log.txt -O ./consoleText >/dev/null 2>&1
179     sed -i -e "s/\r//g" ./consoleText
180     if [ $id == 0 ]; then
181       node="travis-linux (<a href=\"https://travis-ci.org/simgrid/simgrid/jobs/${BUILDS[$id]}\">log</a>)"
182       os="Ubuntu  <a href=\"https://docs.travis-ci.com/user/reference/xenial/\">16.04 xenial</a>"
183     elif [ $id == 1 ]; then
184       node="travis-mac (<a href=\"https://travis-ci.org/simgrid/simgrid/jobs/${BUILDS[$id]}\">log</a>)"
185       os="Mac OS X <a href=\"https://docs.travis-ci.com/user/reference/osx/\">Mojave (10.14)</a> "
186     elif [ $id == 2 ]; then
187       node="travis-windows (<a href=\"https://travis-ci.org/simgrid/simgrid/jobs/${BUILDS[$id]}\">log</a>)"
188       os="Windows <a href=\"https://docs.travis-ci.com/user/reference/windows/\">10 v17134</a>"
189     fi
190     boost=$(get_boost)
191     compiler=$(get_compiler)
192     java=$(get_java)
193     cmake=$(get_cmake)
194     ns3=$(get_ns3)
195     py=$(get_python)
196     echo "<tr> <td class=\"matrix-leftcolumn\">$node</td><td class=\"matrix-cell\" style=\"text-align:left\">$os</td><td class=\"matrix-cell\" style=\"text-align:left\">$compiler</td><td class=\"matrix-cell\" style=\"text-align:left\">$boost</td><td class=\"matrix-cell\" style=\"text-align:left\">$java</td><td class=\"matrix-cell\" style=\"text-align:left\">$cmake</td><td class=\"matrix-cell\" style=\"text-align:center\">$ns3</td><td class=\"matrix-cell\" style=\"text-align:center\">$py</td><td class=\"matrix-cell\" style=\"text-align:center\"><img src=https://ci.inria.fr/simgrid/images/24x24/grey.png></td><td class=\"matrix-cell\" style=\"text-align:center\"><img src=https://ci.inria.fr/simgrid/images/24x24/grey.png></td></tr>"
197     rm consoleText
198 done
199
200 echo "</table>"