svn: /web/php-rmtools/trunk/client/ include/BuildVC.php include/MakeLogParser.php include/MakeLogParserVC.php include/Tools.php script/snap.php
template/mail_notification.tpl.php
| From: | Pierre Joye | Date: | Mon, 25 Apr 2011 20:16:39 +0000 |
| Subject: | svn: /web/php-rmtools/trunk/client/ include/BuildVC.php include/MakeLogParser.php include/MakeLogParserVC.php include/Tools.php script/snap.php template/mail_notification.tpl.php |
||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-10878@lists.php.net to get a copy of this message | ||
pajoye Mon, 25 Apr 2011 20:16:39 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=310478
Log:
- add mail notification (errors only for now)
Changed paths:
U web/php-rmtools/trunk/client/include/BuildVC.php
U web/php-rmtools/trunk/client/include/MakeLogParser.php
U web/php-rmtools/trunk/client/include/MakeLogParserVC.php
U web/php-rmtools/trunk/client/include/Tools.php
U web/php-rmtools/trunk/client/script/snap.php
A web/php-rmtools/trunk/client/template/mail_notification.tpl.php
Modified: web/php-rmtools/trunk/client/include/BuildVC.php
===================================================================
--- web/php-rmtools/trunk/client/include/BuildVC.php 2011-04-25 16:51:12 UTC (rev 310477)
+++ web/php-rmtools/trunk/client/include/BuildVC.php 2011-04-25 20:16:39 UTC (rev 310478)
@@ -14,13 +14,15 @@
public $archive_path = false;
public $debug_path = false;
public $devel_path = false;
+
+ public $compiler_log_parser;
public $stats;
function __construct(Branch $branch, $build_name)
{
$this->branch = $branch;
$this->build_name = $build_name;
- $this->obj_dir = $this->branch->config->getBuildDir();
+ $this->obj_dir = $this->branch->config->getBuildDir() . '/' .
$this->build_name;
$this->compiler = $this->branch->config->getCompiler();
$this->architecture = $this->branch->config->getArchitecture();
@@ -81,8 +83,8 @@
function configure($extra = false)
{
$args = $this->branch->config->getConfigureOptions($this->build_name) . ($extra ?:
$extra);
- $cmd = 'configure ' . $args . ' --enable-object-out-dir=' . $this->obj_dir
. '/' . $this->build_name;
- mkdir($this->obj_dir . '/' . $this->build_name);
+ $cmd = 'configure ' . $args . ' --enable-object-out-dir=' .
$this->obj_dir;
+ mkdir($this->obj_dir . '/' . $this->build_name, 0655, true);
$ret = exec_single_log($cmd, $this->build_dir, $this->env);
if (!$ret) {
throw new \Exception('Configure failed');
@@ -145,7 +147,9 @@
$tmpfile = $this->obj_dir . '/' . 'make.txt';
file_put_contents($tmpfile, $this->log_make);
$parser->parse($tmpfile, $this->build_dir);
+ unlink($tmpfile);
$this->stats = $parser->stats;
+ $this->compiler_log_parser = $parser;
return $parser->toHtml($this->build_name);
}
@@ -156,9 +160,8 @@
function clean()
{
- $dir = $this->obj_dir . '/' . $this->build_name;
- //rmdir_rf($this->obj_dir . '/' . $this->build_name);
- echo "rm $dir\n";
+ $dir = $this->obj_dir;
+ rmdir_rf($this->obj_dir);
}
function getLogs()
Modified: web/php-rmtools/trunk/client/include/MakeLogParser.php
===================================================================
--- web/php-rmtools/trunk/client/include/MakeLogParser.php 2011-04-25 16:51:12 UTC (rev 310477)
+++ web/php-rmtools/trunk/client/include/MakeLogParser.php 2011-04-25 20:16:39 UTC (rev 310478)
@@ -4,6 +4,7 @@
class MakeLogParser {
public $log;
+ public $stats;
function toHtml($title)
{
@@ -14,4 +15,19 @@
ob_end_clean();
return $html;
}
+
+ function getErrors()
+ {
+ if ($this->stats['error'] > 0) {
+ $res = array();
+ foreach ($this->log as $e) {
+ if ($e['level'] == 'error' || $e['level'] == 'fatal')
{
+ $res[] = $e;
+ }
+ }
+ return $res;
+ } else {
+ return NULL;
+ }
+ }
}
Modified: web/php-rmtools/trunk/client/include/MakeLogParserVC.php
===================================================================
--- web/php-rmtools/trunk/client/include/MakeLogParserVC.php 2011-04-25 16:51:12 UTC (rev 310477)
+++ web/php-rmtools/trunk/client/include/MakeLogParserVC.php 2011-04-25 20:16:39 UTC (rev 310478)
@@ -3,9 +3,6 @@
include __DIR__ . '/MakeLogParser.php';
class MakeLogParserVc extends MakeLogParser {
- public $log;
- public $stats;
-
function parse($path, $root_src_dir)
{
$this->stats = array('warning' => 0, 'error' => 0);
@@ -135,6 +132,10 @@
$row['file'] = str_ireplace($root_src_dir, '', $row['file']);
$row['section'] = strtolower(dirname($row['file']));
$row['file'] = str_ireplace($row['section'] . '\\', '',
$row['file']);
+ if ($row['level'] == 'fatal') {
+ $row['level'] = 'error';
+ }
+
if (isset($this->stats[$row['level']])) {
$this->stats[$row['level']]++;
}
Modified: web/php-rmtools/trunk/client/include/Tools.php
===================================================================
--- web/php-rmtools/trunk/client/include/Tools.php 2011-04-25 16:51:12 UTC (rev 310477)
+++ web/php-rmtools/trunk/client/include/Tools.php 2011-04-25 20:16:39 UTC (rev 310478)
@@ -186,3 +186,38 @@
}
\curl_multi_close($mh);
}
+
+function send_error_notification($build_entries, $previous_revision, $current_revision, $url_log)
+{
+ $errors = '';
+ $params = NULL;
+ $headers = 'From: noreply@php.net' . "\r\n" .
+ 'Reply-To: noreply@php.net' . "\r\n" .
+ 'X-Mailer: rmtools/php.net';
+
+ foreach ($build_entries as $build_name => $entries) {
+ $errors .= 'Build ' . $build_name . ":\n";
+ foreach ($entries as $e) {
+ $errors .= implode(', ', $e) . "\n";
+ }
+ $errors .= "\n\n";
+ }
+ $to = 'pierre.php@gmail.com';
+ $subject = '[rmtools] Build error between r' . $previous_revision . ' and ' .
$current_revision;
+
+ ob_start();
+ include __DIR__ . '/../template/mail_notification.tpl.php';
+ $body = ob_get_contents();
+ ob_end_clean();
+ echo $mail . "\n";
+
+ if (substr($to, -7) === 'php.net') {
+ $params = '-fnoreply@php.net';
+ }
+
+ if($params == null){
+ return mail($to, $subject, $body, $headers);
+ }else{
+ return mail($to, $subject, $body, $headers, $params);
+ }
+}
Modified: web/php-rmtools/trunk/client/script/snap.php
===================================================================
--- web/php-rmtools/trunk/client/script/snap.php 2011-04-25 16:51:12 UTC (rev 310477)
+++ web/php-rmtools/trunk/client/script/snap.php 2011-04-25 20:16:39 UTC (rev 310478)
@@ -21,6 +21,9 @@
$branch_name = $branch->config->getName();
$branch_name_short = $branch->config->getBranch();
+echo "Running <$config_path>\n";
+echo " \t$branch_name\n";
+
if ($force || $branch->hasNewRevision()) {
$last_rev = $branch->getLastRevisionId();
if ($force || $last_rev != $branch->getLastRevisionExported()) {
@@ -49,6 +52,9 @@
$builds = $branch->getBuildList('windows');
+ $has_build_errors = false;
+ $build_errors = array();
+
foreach ($builds as $build_name) {
$build_src_path = realpath($build_dir_parent) . DIRECTORY_SEPARATOR . $build_name;
$log = rm\exec_single_log('mklink /J ' . $build_src_path . ' ' .
$src_original_path);
@@ -86,6 +92,7 @@
copy(__DIR__ . '/../template/log_style.css', $toupload_dir .
'/logs/log_style.css');
$stats = $build->getStats();
+
$json_filename = $build_name . '.json';
$json_data = array(
@@ -94,6 +101,13 @@
'has_debug_pkg' => file_exists($build->debug_path),
'has_devel_pkg' => file_exists($build->devel_path),
);
+
+ if ($stats['error'] > 0) {
+ $has_build_errors = true;
+ $build_errors[$build_name] = $build->compiler_log_parser->getErrors();
+ $json_data['build_error'] = $build_errors[$build_name];
+ }
+
$json = json_encode($json_data);
file_put_contents($toupload_dir . '/' . $json_filename, $json);
@@ -108,4 +122,8 @@
echo "no new revision.\n";
}
+if ($has_build_errors) {
+ rm\send_error_notification($build_errors, $prev_revision, $current_revision, 'http://windows.php.net/downloads/snaps/'
. $branch_name . '/r' . $last_rev);
+}
+
echo "Done.\n";
Added: web/php-rmtools/trunk/client/template/mail_notification.tpl.php
===================================================================
--- web/php-rmtools/trunk/client/template/mail_notification.tpl.php (rev 0)
+++ web/php-rmtools/trunk/client/template/mail_notification.tpl.php 2011-04-25 20:16:39 UTC (rev
310478)
@@ -0,0 +1,12 @@
+This is an automatic mail from the rmtoool's build bots.
+
+New build errors have been introduced between <?php echo $previous_revision; ?>
+and <?php echo $current_revision; ?>.
+
+The errors are:
+
+<?php echo $errors ?>
+
+Full logs are available at (htmlized versions too):
+
+<?php echo $url_log ?>