Logo AND Algorithmique Numérique Distribuée

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