Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
authorDario Sestito <darios@symbian.org>
Wed, 26 May 2010 17:48:56 +0100 (2010-05-26)
changeset 1050 34dcbee2af5e
parent 1049 106264ed9735
child 1051 044ab1b95cae
Fix: Diamonds summary build info should be more related to the raptor build breakdown from the UH parser
common/build.postbuild.xml
common/diamonds/config.xml.ftl
common/diamonds/sf-run-analysis-diamonds.xml.ftl
common/tools/uh2diamonds.pl
--- a/common/build.postbuild.xml	Wed May 26 20:05:06 2010 +0100
+++ b/common/build.postbuild.xml	Wed May 26 17:48:56 2010 +0100
@@ -618,14 +618,26 @@
             <arg value="${build.log.dir}/analysis/${build.id}_what_results.csv"/>
         </exec>
     </target>
-
-    <target name="sf-run-analysis-diamonds">      
-      <fmpp sourceFile="${sf.common.config.dir}/diamonds/sf-run-analysis-diamonds.xml.ftl" outputFile="${build.drive}/output/logs/sf-run-analysis-diamonds.xml">
-        <data expandProperties="yes">
-          ant: antProperties()
-          raptor_summary: csv(${build.log.dir}/raptorbits/summary.csv,{separator:',',headers:[category,subcategory,severity,config,component,mmp,phase,recipe,file,line]})
-        </data>
-      </fmpp>
+    
+    <target name="sf-run-analysis-diamonds">
+      <if>
+        <istrue value="${sf.spec.publish.enable}"/>
+        <then>
+          <echo>[SF-RUN-ANALYSIS-DIAMONDS]</echo>
+          <echo message="Translate \output\logs\html\index.html into a Diamonds file"/>
+          <exec executable="perl" dir="${build.drive}">
+            <arg value="${sf.common.config.dir}/tools/uh2diamonds.pl"/>
+          </exec>
+          <echo message="Send ${build.log.dir}/diamonds_uh.xml to Diamonds"/>
+          <exec executable="python">
+		    <arg value="${sf.common.config.dir}/tools/brag/send_xml_to_diamonds.py"/>
+		    <arg value="-u"/>
+		    <arg value="http://${diamonds.host}${diamonds.build.id}"/>
+		    <arg value="-f"/>
+		    <arg value="${build.log.dir}/diamonds_uh.xml"/>
+		  </exec>
+        </then>
+      </if>
     </target>
     
     <target name="sf-links-to-diamonds">
--- a/common/diamonds/config.xml.ftl	Wed May 26 20:05:06 2010 +0100
+++ b/common/diamonds/config.xml.ftl	Wed May 26 17:48:56 2010 +0100
@@ -39,14 +39,6 @@
         <stage name="release" start="publish-variants" end="final" />
     </stages>
     <targets>
-    	<!-- note: replaced by sf-diamonds-envinfo -->
-        <!-- target name="diamonds" template-file="tool.xml.ftl" 
-            logfile="${ant['temp.build.dir']}/build/doc/ivy/tool-dependencies-${ant['build.type']}.xml" ant-properties="true"/ -->
-        
-        <!-- note: replaced by sf-run-analysis-diamonds -->
-        <!-- target name="compile-main" template-file="compile.xml.ftl"
-            logfile="${ant['diamonds.compile.summary']}" ant-properties="true"/ -->
-                    
         <target name="ido-codescanner" template-file="codescanner.xml.ftl"
             logfile="${ant['ido.codescanner.output.dir']}/problemIndex.xml"/>
 
@@ -64,18 +56,10 @@
         <target name="render-validate-policy" template-file="validate-policy-log.xml.ftl" 
             logfile="${ant['validate.policy.log']}"/>
         </#if>
-
-        <!-- note: replaced by sf-diamonds-envinfo -->
-        <!-- defer will store all the converted output file and sends only if there any other
-            stage / target starts to send some data to diamonds -->
-        <!-- target name="check-tool-dependencies" template-file="tool.xml.ftl" 
-            logfile="${ant['temp.build.dir']}/build/doc/ivy/tool-dependencies-${ant['build.type']}.xml" ant-properties="true"
-            defer="true"/ -->
             
         <!-- SF specific -->
         <target name="sf-diamonds-tag-build"/>
         <target name="sf-diamondize-bom"/>
-        <target name="sf-run-analysis-diamonds"/>
     </targets>
 </logger>
 </configuration>
\ No newline at end of file
--- a/common/diamonds/sf-run-analysis-diamonds.xml.ftl	Wed May 26 20:05:06 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<diamonds-build>
-  <schema>14</schema>
-  
-<#assign raptor_errors=0/>
-<#assign raptor_warnings=0/>
-<#list raptor_summary as raptor_item>
-<#if raptor_item.category = "raptor_error">
-  <#assign raptor_errors=raptor_errors+1 />
-<#elseif raptor_item.category = "raptor_warning">
-  <#assign raptor_warnings=raptor_warnings+1 />
-</#if>
-</#list>
-
-  <faults>
-    <total severity="Raptor Errors">${raptor_errors}</total>
-    <total severity="Raptor Warnings">${raptor_warnings}</total>
-    <total severity="Recipes Failed">${ant['sf.job.totalyarperrors']}</total>
-  </faults>
-</diamonds-build>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/uh2diamonds.pl	Wed May 26 17:48:56 2010 +0100
@@ -0,0 +1,90 @@
+# 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:
+# Translates uh report (index.html) to a Diamonds file
+
+use strict;
+
+use Getopt::Long;
+
+my $input = "\\output\\logs\\html\\index.html";
+my $output = "\\output\\logs\\diamonds_uh.xml";
+my $help = 0;
+GetOptions((
+	'in=s' => \$input,
+	'out=s' => \$output,
+	'help!' => \$help
+));
+
+if ($help)
+{
+	print "Translates uh report (index.html) to a Diamonds file\n";
+	print "Usage: perl uh2diamonds.pl [--in=UHINDEX] [--out=XMLFILE]\n";
+	print "\n";
+	print "UHINDEX is optional, its default is \\output\\logs\\html\\index.html\n";
+	print "XMLFILE is optional, its default is \\output\\logs\\diamonds_uh.xml\n";
+	exit(0);
+}
+
+my $critical = 0;
+my $major = 0;
+my $minor = 0;
+my $unknown = 0;
+my $missing = 0;
+
+open(INDEX, $input) or die "Can't open $input for reading";
+while (<INDEX>)
+{
+	my $line = $_;
+	if ($line =~ m,<tr><td><a href='.*'>\w+</a></td><td>(\d+)</td><td>(\d+)</td><td>(\d+)</td><td>(\d+)</td></tr>,)
+	{
+		$critical += $1;
+		$major += $2;
+		$minor += $3;
+		$unknown += $4;
+	}
+	elsif($line =~ m,<tr><td><a href='.+'>.+</a></td><td>(\d+)</td><td>(\d+)</td><td>(\d+)</td><td>(\d+)</td><td>(\d+)</td></tr>,)
+	{
+		$critical += $1;
+		$major += $2;
+		$minor += $3;
+		$unknown += $4;
+		$missing += $5;
+	}
+}
+close(INDEX);
+
+my $xml_content = <<_EOX;
+
+<?xml version=\"1.0\" encoding=\"utf-8\"?>
+<diamonds-build>
+  <schema>14</schema>
+  <faults>
+    <total severity=\"Raptor Build Critical\">$critical</total>
+    <total severity=\"Raptor Build Major\">$major</total>
+    <total severity=\"Raptor Build Minor\">$minor</total>
+    <total severity=\"Raptor Build Unknown\">$unknown</total>
+    <total severity=\"Missing Artifacts\">$missing</total>
+  </faults>
+</diamonds-build>
+_EOX
+
+if (open(XML, ">$output"))
+{
+	print XML $xml_content;
+	close(XML);
+	print "Wrote Diamonds file: $output\n";
+}
+else
+{
+	warn "Could not write to file: $output\n";
+}
\ No newline at end of file