Merge
authorLouis Henry Nayegon <louisn@symbian.org>
Wed, 30 Sep 2009 18:03:10 +0100
changeset 549 6405be0d716a
parent 548 8e942a905022 (current diff)
parent 547 19f9d5fc6406 (diff)
child 551 cd084e6d144e
Merge
--- a/common/build.postbuild.xml	Wed Sep 30 18:01:30 2009 +0100
+++ b/common/build.postbuild.xml	Wed Sep 30 18:03:10 2009 +0100
@@ -304,8 +304,8 @@
           </fileset>
         </path>
         <sequential>
-		  <propertyregex override="yes" property="preprocessedlogfile" input="@{logfile}" regexp=".*[\\/](.*)_compile\.log" replace="\1_compile_preprocessed.log"/>
-	      <echo message="Preprocessing @{logfile}..."/>
+          <propertyregex override="yes" property="preprocessedlogfile" input="@{logfile}" regexp=".*[\\/](.*)_compile\.log" replace="\1_compile_preprocessed.log"/>
+          <echo message="Preprocessing @{logfile}..."/>
           <exec executable="perl" dir="${sf.common.config.dir}/tools/raptor" failonerror="false" input="@{logfile}" output="${build.log.dir}/analysis/${preprocessedlogfile}" error="${build.log.dir}/analysis/${build.id}_preprocess.log" append="true">
             <arg value="${sf.common.config.dir}/tools/raptor/preprocess_log.pl"/>
           </exec>
@@ -321,7 +321,6 @@
         </path>
         <sequential>
           <echo message="Extracting whatlog info from @{whatlogfile}..."/>
-          <echo message="Exec: [${sf.common.config.dir}/tools/raptor] perl ${sf.common.config.dir}/tools/raptor/parse.pl --releaseable --log=@{whatlogfile} --basedir=${build.log.dir} --append"/>
           <exec executable="perl" dir="${sf.common.config.dir}/tools/raptor" failonerror="false" output="${build.log.dir}/analysis/${build.id}_whatlog.log" append="true">
             <arg value="${sf.common.config.dir}/tools/raptor/parse.pl"/>
             <arg value="--releaseable"/>
@@ -342,7 +341,6 @@
         <sequential>
           <echo message="Extracting error info from @{raptorlogfile}..."/>
           <propertyregex override="yes" property="raptorconfig" input="@{raptorlogfile}" regexp=".*[\\/].*__(.*)\.whatlog_(single|multiple)_thread.*" replace="\1" casesensitive="false" defaultValue="noconfig"/>
-          <echo message="Exec: [${sf.common.config.dir}/tools/raptor] perl ${sf.common.config.dir}/tools/raptor/parse.pl --error --warning --unreciped --recipe --config=${raptorconfig} --log=@{raptorlogfile} --basedir=${build.log.dir}/raptorbits --append"/>
           <exec executable="perl" dir="${sf.common.config.dir}/tools/raptor" failonerror="false" output="${build.log.dir}/analysis/${build.id}_raptorparse.log" append="true">
             <arg value="${sf.common.config.dir}/tools/raptor/parse.pl"/>
             <arg value="--error"/>
@@ -352,12 +350,11 @@
             <arg value="--config=${raptorconfig}"/>
             <arg value="--log=@{raptorlogfile}"/>
             <arg value="--basedir=${build.log.dir}/raptorbits"/>
-            <arg value="--append"/>
           </exec>
         </sequential>
       </for>
       
-      <echo message="Exec: [${sf.common.config.dir}/tools/raptor] perl ${sf.common.config.dir}/tools/raptor/summarize.pl --raptorbitsdir=${build.log.dir}/raptorbits --outputdir=${build.log.dir}"/>
+      <echo message="Summarizing Raptor data"/>
       <exec executable="perl" dir="${sf.common.config.dir}/tools/raptor" failonerror="false" output="${build.log.dir}/analysis/${build.id}_raptorparse.log" append="true">
         <arg value="${sf.common.config.dir}/tools/raptor/summarize.pl"/>
         <arg value="--raptorbitsdir=${build.log.dir}/raptorbits"/>
@@ -377,6 +374,15 @@
           </exec>
         </sequential>
       </for>
+
+      <!-- Cook the raptor analysis further to produce something in the right format for the BRAG system -->
+      <exec executable="perl" output="${build.log.dir}/summary/Raptor_BRAG.xml" logError="yes">
+        <arg value="${sf.common.config.dir}/tools/brag/raptorToBRAG.pl"/>
+        <arg value="--raptorsummary"/>
+        <arg value="${build.log.dir}/raptorbits/summary.csv"/>
+      </exec>
+      <!-- And copy the XSL so the output can be transformed by a browser -->
+      <copy file="${sf.common.config.dir}/tools/brag/brag.xsl" toDir="${build.log.dir}/summary/"/>
     </target>
 
     <target name="sf-run-analysis-yarp">          
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/brag/brag.xsl	Wed Sep 30 18:03:10 2009 +0100
@@ -0,0 +1,60 @@
+<xsl:stylesheet version="1.0"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	xmlns:fn="http://www.w3.org/2005/xpath-functions"
+	>
+<xsl:template match="/">
+	<html>
+	<link href="http://developer.symbian.org/css/reset.css" rel="stylesheet" type="text/css" />
+	<link href="http://developer.symbian.org/css/portal-merged.css" rel="stylesheet" type="text/css" />
+	<link href="http://developer.symbian.org/css/iefix.css" rel="stylesheet" type="text/css" />
+	<head><title>Build Status</title></head>
+	<body>
+	<h2>Build Status</h2>
+	<table border="1">
+
+	<xsl:for-each select="stage">
+		<tr>
+		<th>Stage: <xsl:value-of select="@name"/></th>
+		</tr>
+		<xsl:for-each select="step">
+			<tr>
+			<td>Step: <xsl:value-of select="@name"/></td>
+			</tr>
+			<xsl:for-each select="failures">
+				<tr>
+				<td>Failures: <xsl:value-of select="@level"/></td>
+				<td>Number: <xsl:value-of select="count(failure)"/></td>
+				</tr>
+			</xsl:for-each>
+		</xsl:for-each>
+	</xsl:for-each>
+
+	</table>
+
+	<xsl:variable name="criticalCount" select="count(stage/step/failures[@level='critical']/failure)"/>
+	<xsl:variable name="majorCount" select="count(stage/step/failures[@level='major']/failure)"/>
+	<xsl:variable name="minorCount" select="count(stage/step/failures[@level='minor']/failure)"/>
+	<xsl:variable name="unknownCount" select="count(stage/step/failures[@level!='critical' and @level!='major' and @level!='minor']/failure)"/>
+
+	<p>Total number of critical errors = <xsl:value-of select="$criticalCount"/></p>
+	<p>Total number of major errors = <xsl:value-of select="$majorCount"/></p>
+	<p>Total number of minor errors = <xsl:value-of select="$minorCount"/></p>
+	<p>Total number of unknown errors = <xsl:value-of select="$unknownCount"/></p>
+
+	<h2>
+	Final BRAG staus: 
+	<xsl:choose>
+		<xsl:when test="$criticalCount != 0">BLACK</xsl:when>
+		<xsl:when test="$majorCount != 0">RED</xsl:when>
+		<xsl:when test="$minorCount != 0">AMBER</xsl:when>
+		<xsl:when test="$unknownCount != 0">GREEN</xsl:when>
+		<xsl:otherwise>GOLD!</xsl:otherwise>
+	</xsl:choose>
+	</h2>
+
+	</body>
+	</html>
+</xsl:template>
+
+</xsl:stylesheet>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/brag/raptorToBRAG.pl	Wed Sep 30 18:03:10 2009 +0100
@@ -0,0 +1,181 @@
+#!perl -w
+#
+# Copyright (c) 2009 Symbian Foundation Ltd
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Symbian Foundation Ltd - initial contribution.
+#
+# Contributors:
+#
+# Description:
+# Generate the BRAG-compatible XML summary of the Raptor log from the CSV output of the raptor parser
+
+use strict;
+
+use Getopt::Long;
+use Text::CSV;
+
+
+my $raptorSummary;
+my $help = 0;
+GetOptions((
+	'raptorsummary=s' => \$raptorSummary,
+	'help!' => \$help
+));
+
+$help = 1 if (!$raptorSummary);
+if ($help)
+{
+	print "Generate an XML summary of the Raptor build from a summary.csv file\n";
+	print "Usage: perl summarize.pl --raptorsummary=CSV\n";
+	exit(0);
+}
+
+# Start to build structure to be output as XML (same format as XML::Parser would create for us)
+my $xmlNewline = bless { Text => "\n" }, "Characters";
+my $data = [bless {name => "build", Kids => [ $xmlNewline ] }, "stage"];
+# Get a shortcut reference to the bit we will use a lot
+my $buildStage = $data->[0];
+
+# READ SUMMARY.CSV FILE
+open(CSV, $raptorSummary);
+my $csv = Text::CSV->new();
+while (my $line = <CSV>)
+{
+	chomp $line;
+	
+	unless ($csv->parse($line))
+	{
+		my $err = $csv->error_input();
+		warn "Failed to parse $raptorSummary line line $. as CSV '$line': $err  Skipping\n";
+		next;
+	}
+	
+	my @keys = qw{category subcategory severity config component phase recipe file linenum};
+	my @values = $csv->fields();
+	unless (scalar @keys == scalar @keys)
+	{
+		warn "WARNING: line does not match expected format at $raptorSummary line $.. Skipping\n";
+		next;
+	}
+	
+	my $failure = {};
+	@{$failure}{@keys} = @values;
+	
+	if (!$failure->{category})
+	{
+		warn "WARNING: summary line without a category at $raptorSummary line $.. Skipping\n";
+		next;
+	}
+	
+	if ($failure->{category} =~ m{^recipe_failure$}i and !$failure->{component})
+	{
+		warn "WARNING: recipe_failure with component field empty at $raptorSummary line $.. Skipping\n";
+		next;
+	}
+	$failure->{subcategory} ||= 'uncategorized';
+	$failure->{severity} ||= 'unknown';
+	
+	# Look through the steps to see if we already have one to match this config
+	my $step;
+	foreach (@{$buildStage->{Kids}})
+	{
+		next unless ref $_ eq "step";
+		if ($_->{name} eq $failure->{config})
+		{
+			$step = $_;
+			last;
+		}
+	}
+	unless ($step)
+	{
+		# First item found in this step - create step entry
+		$step = bless { name => $failure->{config}, Kids => [ $xmlNewline ] }, "step";
+		push @{$buildStage->{Kids}}, $step, $xmlNewline;
+	}
+	
+	# Look through the sets of failures in this step to see if we hve one which matches this severity
+	my $failureSet;
+	foreach (@{$step->{Kids}})
+	{
+		next unless ref $_ eq "failures";
+		if ($_->{level} eq $failure->{severity})
+		{
+			$failureSet = $_;
+			last;
+		}
+	}
+	unless ($failureSet)
+	{
+		# First item found at this severity - create failures entry
+		$failureSet = bless { level => $failure->{severity}, Kids => [ $xmlNewline ] }, "failures";
+		push @{$step->{Kids}}, $failureSet, $xmlNewline;
+	}
+
+	# Now create the failure itself, and add it to this failure set
+	my $failureItem = bless { href => "", Kids => [ bless { Text => $failure->{subcategory} }, "Characters" ] }, "failure";
+	push @{$failureSet->{Kids}}, $failureItem, $xmlNewline;
+}
+close(CSV);
+
+# Print XML
+print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+print "<?xml-stylesheet type='text/xsl' href='brag.xsl'?>\n";
+printTree($data->[0]);
+print "\n";
+
+exit(0);
+
+sub printTree
+{
+	my $tree = shift or die;
+	die unless ref $tree;
+
+	my $tagName = ref $tree;
+	$tagName =~ s{^main::}{};
+	if ($tagName eq "Characters")
+	{
+		print $tree->{Text};
+		return;
+	}
+	
+	print "<$tagName";
+
+	foreach my $attr (
+		sort {
+			my $order = "name level start stop href";
+			my $ixA = index $order, $a;
+			my $ixB = index $order, $b;
+			die "$a $b" if $ixA + $ixB == -2;
+			$ixA - $ixB;
+		}
+		grep {
+			! ref $tree->{$_}
+		}
+		keys %$tree)
+	{
+		print " $attr=\"$tree->{$attr}\"";
+	}
+
+	my $children = $tree->{Kids} || [];
+	if (scalar @$children)
+	{
+		print ">";
+		foreach my $child (@$children)
+		{
+			printTree($child);
+		}
+		print "</$tagName";
+	}
+	else
+	{
+		print "/"
+	}
+
+	print ">";
+}
+