servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lh...@apache.org
Subject svn commit: r701069 - /servicemix/scripts/builds/webapps/builds/status.jsp
Date Thu, 02 Oct 2008 10:33:55 GMT
Author: lhein
Date: Thu Oct  2 03:33:55 2008
New Revision: 701069

URL: http://svn.apache.org/viewvc?rev=701069&view=rev
Log:
reworked the script to display time of state and also a new state was added SUCCESS with failures

Modified:
    servicemix/scripts/builds/webapps/builds/status.jsp

Modified: servicemix/scripts/builds/webapps/builds/status.jsp
URL: http://svn.apache.org/viewvc/servicemix/scripts/builds/webapps/builds/status.jsp?rev=701069&r1=701068&r2=701069&view=diff
==============================================================================
--- servicemix/scripts/builds/webapps/builds/status.jsp (original)
+++ servicemix/scripts/builds/webapps/builds/status.jsp Thu Oct  2 03:33:55 2008
@@ -31,6 +31,12 @@
       padding-left: 8px;
       padding-right: 8px;
     }
+    .success_with_failed_tests {
+      background-color: orange;
+      color: black;
+      padding-left: 8px;
+      padding-right: 8px;
+    }
 
   </style>
 </head>
@@ -39,14 +45,18 @@
 
 <%!
   String dir = "/mnt/builds/logs/";
+  String failedTestsCheck = "[ERROR] There are test failures.";
 
   String processBuildFile(String uri) {
     // lets check to see if its
+    boolean failedTests = false;
     String file = dir + uri;
     BufferedReader reader = null;
+    File f = new File(file);
+    String durationText = convertToDuration(System.currentTimeMillis() - f.lastModified());
     try {
       System.out.println("Processing: " + file);
-      if (new File(file).lastModified() + 80000 >= System.currentTimeMillis()) {
+      if (f.lastModified() + 80000 >= System.currentTimeMillis()) {
       	  return "<a href='logs/" + uri + "' class='building'>BUILDING</a>";
       }
       reader = new BufferedReader(new FileReader(file));
@@ -55,13 +65,19 @@
         if (line == null) {
           break;
         } else {
-          if (line.contains("BUILD SUCCESSFUL")) {
-            return "<a href='logs/" + uri + "' class='success'>SUCCESS</a>";
+          if (line.contains(failedTestsCheck)) {
+            failedTests = true;
+          } else if (line.contains("BUILD SUCCESSFUL")) {
+            if (failedTests) {
+              return "<a href='logs/" + uri + "' class='success_with_failed_tests'>SUCCESS
(with failures)</a> " + durationText;
+            } else {
+              return "<a href='logs/" + uri + "' class='success'>SUCCESS</a>
" + durationText;
+            }
           }
         }
       }
     } catch (IOException e) {
-      return "<a href='logs/" + uri + "' class='error'>" + e + "</a>";
+      return "<a href='logs/" + uri + "' class='error'>" + e + "</a> " + durationText;
     }
     finally {
       if (reader != null) {
@@ -72,85 +88,110 @@
         }
       }
     }
-    return "<a href='logs/" + uri + "' class='failure'>FAILURE</a>";
+    return "<a href='logs/" + uri + "' class='failure'>FAILURE</a> " + durationText;
+  }
+  
+  String convertToDuration(long millis) {
+    StringBuffer buffer = new StringBuffer();
+    double minutes = millis / (60 * 1000);
+    long roundedMins = Math.round(minutes);
+    if (roundedMins < 60L) {
+      if (roundedMins >= 1) {
+        buffer.append(roundedMins);
+        buffer.append(" minute");
+        if (roundedMins > 1) {
+          buffer.append("s");
+        }
+      } else {
+        buffer.append("less than a minute");
+      }
+    } else {
+      double hours = minutes / 60;
+      long roundedHours = Math.round(hours);
+      if (roundedHours < 24) {
+        buffer.append("about ");
+        buffer.append(roundedHours);
+        buffer.append(" hour");
+        if (roundedHours > 1) {
+          buffer.append("s");
+        }
+      } else {
+        double days = hours / 24;
+        long rounded = Math.round(days);
+        buffer.append("about ");
+        buffer.append(rounded);
+        buffer.append(" day");
+        if (rounded > 1) {
+          buffer.append("s");
+        }
+      }
+    }
+    buffer.append(" ago...");
+      
+    return buffer.toString();
   }
 %>
 
 <table>
   <tr>
     <td>ActiveMQ trunk deploy</td>
-    <td><%= processBuildFile("activemq-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("activemq-deploy.log")%></td>
   </tr>
   <tr>
     <td>Camel trunk deploy</td>
-    <td><%= processBuildFile("camel-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("camel-deploy.log")%></td>
   </tr>
   <tr>
     <td>ServiceMix 3.2 deploy 1</td>
-    <td><%= processBuildFile("servicemix-3.2-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("servicemix-3.2-deploy.log")%></td>
   </tr>
   <tr>
     <td>ServiceMix 3.2 deploy 2</td>
-    <td><%= processBuildFile("servicemix-3.2-deploy-2.log")%>
-    </td>
+    <td><%= processBuildFile("servicemix-3.2-deploy-2.log")%></td>
   </tr>
   <tr>
     <td>ServiceMix 3.3 deploy</td>
-    <td><%= processBuildFile("smx-3.3-trunk-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("smx-3.3-trunk-deploy.log")%></td>
   </tr>
   <tr>
     <td>ServiceMix 4 legal deploy</td>
-    <td><%= processBuildFile("smx4-legal-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("smx4-legal-deploy.log")%></td>
   </tr>
   <tr>
     <td>ServiceMix 4 bundles deploy</td>
-    <td><%= processBuildFile("smx4-bundles-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("smx4-bundles-deploy.log")%></td>
   </tr>
   <tr>
     <td>ServiceMix 4 kernel deploy</td>
-    <td><%= processBuildFile("smx4-kernel-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("smx4-kernel-deploy.log")%></td>
   </tr>
   <tr>
     <td>ServiceMix 4 specs deploy</td>
-    <td><%= processBuildFile("smx4-specs-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("smx4-specs-deploy.log")%></td>
   </tr>
   <tr>
     <td>ServiceMix 4 nmr deploy</td>
-    <td><%= processBuildFile("smx4-nmr-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("smx4-nmr-deploy.log")%></td>
   </tr>
   <tr>
     <td>ServiceMix 4 features deploy</td>
-    <td><%= processBuildFile("smx4-features-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("smx4-features-deploy.log")%></td>
   </tr>
   <tr>
     <td>ServiceMix Components POM</td>
-    <td><%= processBuildFile("smx-components-pom-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("smx-components-pom-deploy.log")%></td>
   </tr>
   <tr>
     <td>ServiceMix Archetypes</td>
-    <td><%= processBuildFile("smx-archetypes-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("smx-archetypes-deploy.log")%></td>
   </tr>
   <tr>
     <td>ServiceMix Maven Plugins POM</td>
-    <td><%= processBuildFile("smx-mvn-plugins-pom-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("smx-mvn-plugins-pom-deploy.log")%></td>
   </tr>
   <tr>
     <td>ServiceMix Utils</td>
-    <td><%= processBuildFile("smx-utils-trunk-deploy.log")%>
-    </td>
+    <td><%= processBuildFile("smx-utils-trunk-deploy.log")%></td>
   </tr>
 </table>
 </body>



Mime
View raw message