Logo AND Algorithmique Numérique Distribuée

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