/[soft]/build_system/web/autobuild/results.php
ViewVC logotype

Contents of /build_system/web/autobuild/results.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7195 - (show annotations) (download)
Tue Jan 22 11:08:04 2013 UTC (5 years, 9 months ago) by pterjan
File size: 4897 byte(s)
Add build history of packages
1 <html>
2 <head>
3 <?php
4
5 function parse_package($rpm) {
6 if (preg_match("/(.*)-([^-]*-[^-]*mga)[1-9].src.rpm/", $rpm, $matches)) {
7 return Array('package' => $matches[1], 'version' => $matches[2]);
8 } else {
9 return false;
10 }
11 }
12
13 $runs = Array();
14 $handle = opendir('cauldron/x86_64/core/');
15 while (false !== ($entry = readdir($handle))) {
16 if (preg_match("/^....-..-..$/", $entry, $matches)) {
17 array_push($runs, $matches[0]);
18 }
19 }
20 closedir($handle);
21 sort($runs);
22
23 $latest = readlink("cauldron/x86_64/core/latest");
24 $run = $_GET['run'];
25 if (!$run) {
26 $run = $latest;
27 }
28
29 foreach ($runs as $r) {
30 if ($r==$run) {
31 break;
32 }
33 $prev = $r;
34 }
35
36 $packages = Array();
37 if ($handle = opendir('/distrib/bootstrap/distrib/cauldron/SRPMS/core/release/')) {
38 while (false !== ($entry = readdir($handle))) {
39 if ($parsed = parse_package($entry)) {
40 $packages[$parsed['package']] = $entry;
41 }
42 }
43 closedir($handle);
44 }
45
46 $prev_failure = Array();
47 if ($prev) {
48 $base_dir = "cauldron/x86_64/core/$prev";
49 $status_name = "$base_dir/status.core.log";
50 $status_file = fopen($status_name, "r");
51 while (!feof($status_file)) {
52 $line = fgets($status_file);
53 if (preg_match("/^(.*): (.*)$/", $line, $matches)) {
54 $rpm = parse_package($matches[1]);
55 $status = $matches[2];
56 if ($status != "ok" && $status != "unknown" && $status != "not_on_this_arch") {
57 $prev_failure[$rpm['package']] = 1;
58 }
59 }
60 }
61 fclose($status_file);
62 }
63
64 $success = Array();
65 $failure = Array();
66 $fixed = Array();
67 $removed = Array();
68 $broken = Array();
69
70 $base_dir = "cauldron/x86_64/core/$run";
71
72
73 $status_name = "$base_dir/status.core.log";
74 if (!file_exists($status_name)) {
75 echo "Invalid run";
76 exit;
77 }
78
79 $status_file = fopen($status_name, "r");
80 while (!feof($status_file)) {
81 $line = fgets($status_file);
82 if (preg_match("/^(.*): (.*)$/", $line, $matches)) {
83 $rpm = $matches[1];
84 $status = $matches[2];
85 if ($status == "ok") {
86 array_push($success, $rpm);
87 } elseif ($status != "unknown" && $status != "not_on_this_arch"){
88 $failure[$rpm] = $status;
89 $parsed = parse_package($rpm);
90 $package = $parsed['package'];
91 if(!$prev_failure[$package]) {
92 $broken[$rpm] = 1;
93 }
94 if(!$packages[$package]) {
95 $removed[$rpm] = 1;
96 } else {
97 $build_stat = stat("$base_dir/$rpm");
98 $pkg_stat = stat('/distrib/bootstrap/distrib/cauldron/SRPMS/core/release/'.$packages[$package]);
99 if ($pkg_stat['mtime'] > $build_stat['mtime']) {
100 $fixed[$rpm] = 1;
101 }
102 }
103 }
104 }
105 }
106 fclose($status_file);
107
108 sort($success);
109 ksort($failure);
110
111 $nb_failed = count($failure);
112 $nb_success = count($success);
113 $nb_fixed = count($fixed);
114 $nb_removed = count($removed);
115 $nb_tried = $nb_failed + $nb_success;
116 $succes_percent = round($nb_success*1000/$nb_tried)/10;
117 $estimated_percent = round(($nb_success+$nb_fixed)*1000/($nb_tried-$nb_removed))/10;
118
119 echo "<title>$succes_percent% Success</title>\n";
120 echo "</head><body>\n";
121
122 echo "<div style='position:absolute;right:0;top:0;'>";
123 echo "<form><select name='run' onChange='document.location.href=\"".$_SERVER["PHP_SELF"]."?run=\"+this.form.run.value'>";
124 foreach ($runs as $r) {
125 $in_progress = ($r > $latest) ? ' (in progress)' : '';
126 $selected = ($r == $run) ? ' selected' : '';
127 echo "<option value='$r'$selected>$r$in_progress</option>";
128 }
129 echo "</select></form></div>\n";
130 echo "<h1>$succes_percent% Success</h1>\n";
131 echo "$nb_fixed packages have been fixed since this run and $nb_removed have been removed.<br/> If no new package was broken, success rate next time should be $estimated_percent%.<br/>\n";
132 echo "<div style='float:left'><h1>Failed builds ($nb_failed/$nb_tried):</h1><ul style='list-style:none;'>";
133
134 foreach ($failure as $rpm => $error) {
135 $parsed = parse_package($rpm);
136 $history_link = '<a href="history.php?package='.$parsed['package'].'">[h]</a>';
137 $status_html = "";
138 if ($fixed[$rpm]) {
139 $status_html = " <img src='icons/state-fixed.png' title='Fixed!' />";
140 } elseif ($removed[$rpm]) {
141 $status_html = " <img src='icons/state-removed.png' title='Removed' />";
142 } elseif ($broken[$rpm]) {
143 $status_html = " <img src='icons/state-new.png' title='New!' />";
144 }
145 $error_html = $error;
146 if (file_exists("icons/error-$error.png")) {
147 $error_html = "<img src='icons/error-$error.png' title='$error'/>";
148 }
149 if (file_exists("$base_dir/$rpm/")) {
150 echo "<li>$error_html <a href='$base_dir/$rpm/'>$rpm</a> $status_html $history_link</li>\n";
151 } else {
152 echo "<li>$error_html $rpm $status_html $history_link</li>\n";
153 }
154 }
155
156 echo "</ul></div><div style='float:right'><h1>Successful builds ($nb_success/$nb_tried):</h1><ul>";
157
158 foreach ($success as $rpm) {
159 $parsed = parse_package($rpm);
160 $history_link = '<a href="history.php?package='.$parsed['package'].'">[h]</a>';
161 if (file_exists("$base_dir/$rpm/")) {
162 echo "<li><a href='$base_dir/$rpm/'>$rpm</a> $history_link</li>\n";
163 } else {
164 echo "<li>$rpm $history_link</li>\n";
165 }
166 }
167
168 ?>
169 </ul></div>
170 </body>
171 </html>

  ViewVC Help
Powered by ViewVC 1.1.26