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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7195 - (hide annotations) (download)
Tue Jan 22 11:08:04 2013 UTC (11 years, 2 months ago) by pterjan
File size: 4897 byte(s)
Add build history of packages
1 pterjan 6695 <html>
2     <head>
3     <?php
4    
5 pterjan 7195 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 pterjan 6729 $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 pterjan 6695
23 pterjan 6790 $latest = readlink("cauldron/x86_64/core/latest");
24 pterjan 6695 $run = $_GET['run'];
25     if (!$run) {
26 pterjan 6790 $run = $latest;
27 pterjan 6695 }
28    
29 pterjan 6729 foreach ($runs as $r) {
30     if ($r==$run) {
31     break;
32     }
33     $prev = $r;
34     }
35 pterjan 7123
36 pterjan 6729 $packages = Array();
37 pterjan 6695 if ($handle = opendir('/distrib/bootstrap/distrib/cauldron/SRPMS/core/release/')) {
38     while (false !== ($entry = readdir($handle))) {
39 pterjan 7195 if ($parsed = parse_package($entry)) {
40     $packages[$parsed['package']] = $entry;
41 pterjan 6695 }
42     }
43     closedir($handle);
44     }
45    
46 pterjan 6729 $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 pterjan 7195 if (preg_match("/^(.*): (.*)$/", $line, $matches)) {
54     $rpm = parse_package($matches[1]);
55 pterjan 6729 $status = $matches[2];
56     if ($status != "ok" && $status != "unknown" && $status != "not_on_this_arch") {
57 pterjan 7195 $prev_failure[$rpm['package']] = 1;
58 pterjan 6729 }
59     }
60     }
61     fclose($status_file);
62     }
63    
64     $success = Array();
65     $failure = Array();
66     $fixed = Array();
67     $removed = Array();
68 pterjan 7081 $broken = Array();
69 pterjan 6729
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 pterjan 7123
79 pterjan 6729 $status_file = fopen($status_name, "r");
80 pterjan 6695 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 pterjan 6877 $failure[$rpm] = $status;
89 pterjan 7195 $parsed = parse_package($rpm);
90     $package = $parsed['package'];
91 pterjan 7187 if(!$prev_failure[$package]) {
92     $broken[$rpm] = 1;
93     }
94 pterjan 7123 if(!$packages[$package]) {
95 pterjan 6695 $removed[$rpm] = 1;
96 pterjan 7123 } else {
97 pterjan 7124 $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 pterjan 7123 $fixed[$rpm] = 1;
101     }
102 pterjan 6695 }
103     }
104     }
105     }
106     fclose($status_file);
107    
108 pterjan 6696 sort($success);
109 pterjan 6877 ksort($failure);
110 pterjan 6696
111 pterjan 6695 $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 pterjan 6790 echo "<div style='position:absolute;right:0;top:0;'>";
123 pterjan 7184 echo "<form><select name='run' onChange='document.location.href=\"".$_SERVER["PHP_SELF"]."?run=\"+this.form.run.value'>";
124 pterjan 6790 foreach ($runs as $r) {
125 pterjan 7184 $in_progress = ($r > $latest) ? ' (in progress)' : '';
126     $selected = ($r == $run) ? ' selected' : '';
127     echo "<option value='$r'$selected>$r$in_progress</option>";
128 pterjan 6790 }
129 pterjan 7184 echo "</select></form></div>\n";
130 pterjan 6695 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 pterjan 6883 echo "<div style='float:left'><h1>Failed builds ($nb_failed/$nb_tried):</h1><ul style='list-style:none;'>";
133 pterjan 6695
134 pterjan 6877 foreach ($failure as $rpm => $error) {
135 pterjan 7195 $parsed = parse_package($rpm);
136     $history_link = '<a href="history.php?package='.$parsed['package'].'">[h]</a>';
137 pterjan 6882 $status_html = "";
138 pterjan 6695 if ($fixed[$rpm]) {
139 pterjan 6882 $status_html = " <img src='icons/state-fixed.png' title='Fixed!' />";
140 pterjan 6695 } elseif ($removed[$rpm]) {
141 pterjan 6882 $status_html = " <img src='icons/state-removed.png' title='Removed' />";
142 pterjan 7081 } elseif ($broken[$rpm]) {
143 pterjan 6882 $status_html = " <img src='icons/state-new.png' title='New!' />";
144 pterjan 6695 }
145 pterjan 6882 $error_html = $error;
146     if (file_exists("icons/error-$error.png")) {
147     $error_html = "<img src='icons/error-$error.png' title='$error'/>";
148     }
149 pterjan 6865 if (file_exists("$base_dir/$rpm/")) {
150 pterjan 7195 echo "<li>$error_html <a href='$base_dir/$rpm/'>$rpm</a> $status_html $history_link</li>\n";
151 pterjan 6865 } else {
152 pterjan 7195 echo "<li>$error_html $rpm $status_html $history_link</li>\n";
153 pterjan 6865 }
154 pterjan 6695 }
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 pterjan 7195 $parsed = parse_package($rpm);
160     $history_link = '<a href="history.php?package='.$parsed['package'].'">[h]</a>';
161 pterjan 7079 if (file_exists("$base_dir/$rpm/")) {
162 pterjan 7195 echo "<li><a href='$base_dir/$rpm/'>$rpm</a> $history_link</li>\n";
163 pterjan 7079 } else {
164 pterjan 7195 echo "<li>$rpm $history_link</li>\n";
165 pterjan 7079 }
166 pterjan 6695 }
167    
168     ?>
169     </ul></div>
170     </body>
171     </html>

  ViewVC Help
Powered by ViewVC 1.1.30