You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2018/10/11 12:04:51 UTC

[ignite-teamcity-bot] branch master updated: UI for simple PR navigation: Button Trigger build and comment JIRA after finish

This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git


The following commit(s) were added to refs/heads/master by this push:
     new 6fc1b4b  UI for simple PR navigation: Button Trigger build and comment JIRA after finish
6fc1b4b is described below

commit 6fc1b4b2861fd7c285fdc9f77e14e48875410c33
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Thu Oct 11 15:04:49 2018 +0300

    UI for simple PR navigation: Button Trigger build and comment JIRA after finish
---
 .../org/apache/ignite/ci/runners/BuildHistory.java |   2 +
 .../ignite/ci/runners/BuildMetricsHistory.java     |   1 +
 .../org/apache/ignite/ci/web/rest/Metrics.java     |   2 +
 ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js | 154 +++++++++++++--------
 4 files changed, 105 insertions(+), 54 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/runners/BuildHistory.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/runners/BuildHistory.java
index b71a30d..4dfbc32 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/runners/BuildHistory.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/runners/BuildHistory.java
@@ -23,6 +23,8 @@ import org.apache.ignite.ci.analysis.FullChainRunCtx;
 /**
  *
  */
+
+@Deprecated
 public class BuildHistory {
     public Map<String, FullChainRunCtx> map = new TreeMap<>();
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/runners/BuildMetricsHistory.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/runners/BuildMetricsHistory.java
index b70b7f4..d63c7c7 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/runners/BuildMetricsHistory.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/runners/BuildMetricsHistory.java
@@ -25,6 +25,7 @@ import java.util.stream.Stream;
 import org.apache.ignite.ci.analysis.FullChainRunCtx;
 import org.apache.ignite.ci.analysis.SuiteInBranch;
 
+@Deprecated
 public class BuildMetricsHistory {
     private Map<SuiteInBranch, BuildHistory> map = new TreeMap<>();
     private LinkedHashSet<SuiteInBranch> keys = new LinkedHashSet<>();
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/Metrics.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/Metrics.java
index 1afb02a..af804b3 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/Metrics.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/Metrics.java
@@ -70,6 +70,8 @@ public class Metrics {
     @Context
     private HttpServletRequest req;
 
+
+    @Deprecated
     public void collectHistory(BuildMetricsHistory history,
         IAnalyticsEnabledTeamcity teamcity, String id, String branch)  {
 
diff --git a/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js b/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js
index 92816ec..0779358 100644
--- a/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js
+++ b/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js
@@ -137,6 +137,7 @@ function showStageResult(stageNum, prId, passed, failed) {
     stageOneStatus.html(html);
 }
 
+
 /* Formatting function for row details - modify as you need */
 function formatContributionDetails(row, srvId, suiteId) {
     //  row  is the original data object for the row
@@ -148,85 +149,130 @@ function formatContributionDetails(row, srvId, suiteId) {
     res += "<div class='formgroup'>";
     res += "<table cellpadding='5' cellspacing='0' border='0' style='padding-left:50px;'>\n";
 
-    //icon of stage
-    res += "<tr>\n" +
-        "                <th><span class='visaStage' id='visaStage_1_" + prId + "'></span></th>\n" +
-        "                <th><span class='visaStage' id='visaStage_2_" + prId + "'></span></th>\n" +
-        "                <th><span class='visaStage' id='visaStage_3_" + prId + "'></span></th>\n" +
-         "                <th><span class='visaStage' id='visaStage_4_" + prId + "'></span></th>\n" +
-        //todo validityCheck;"                <th><span class='visaStage' id='visaStage_5_" + prId + "'></span></th>\n" +
-        "            </tr>\n";
-
     //caption of stage
     res += "<tr>\n" +
-        "                <td>PR with issue name</td>\n" +
-        "                <td>Build is triggered</td>\n" +
+        "                <td>PR naming</td>\n" +
+        "                <td>Build Queued</td>\n" +
         "                <td>Results ready</td>\n" +
         "                <td>JIRA comment</td>\n" +
         //todo  "                <td>Validity check</td>\n" +
         "            </tr>\n";
 
+    //icon of stage
+    res += "<tr>\n" +
+        "                <th title='PR should have valid naming starting with issue name'><span class='visaStage' id='visaStage_1_" + prId + "'></span></th>\n" +
+        "                <th title='Run All should be triggered'><span class='visaStage' id='visaStage_2_" + prId + "'></span></th>\n" +
+        "                <th><span class='visaStage' id='visaStage_3_" + prId + "'></span></th>\n" +
+         "               <th><span class='visaStage' id='visaStage_4_" + prId + "'></span></th>\n" +
+        //todo validityCheck;"                <th><span class='visaStage' id='visaStage_5_" + prId + "'></span></th>\n" +
+        "            </tr>\n";
+
     //action for stage
     res += "        <tr>\n" +
         "            <td>Edit PR: " + "<a href='" + row.prHtmlUrl + "'>#" + row.prNumber + "</a>" + "</td>\n" +
         "               <td id='triggerBuildFor" + prId + "'>Loading builds...</td>\n" +
         "               <td id='showResultFor" + prId + "'>Loading builds...</td>\n" +
         "               <td id='commentJiraFor" + prId + "'></td>\n" +
-        "        </tr>" +
-        "    </table>";
+        "        </tr>";
+
+    //action row 2
+    res += "        <tr>\n" +
+        "            <td></td>\n" +
+        "            <td id='triggerAndObserveBuildFor" + prId + "' colspan='3' align='center'>d</td>\n" +
+        "           </tr>";
+
+    res += "    </table>";
 
     res += "</div>";
 
 
     $.ajax({
-        url: "rest/visa/contributionStatus?serverId=" + srvId +
+        url: "rest/visa/contributionStatus" +
+            "?serverId=" + srvId +
             "&suiteId=" + suiteId +
             "&prId=" + prId,
         success:
             function (result) {
-                let finishedBranch = result.branchWithFinishedRunAll;
-                let tdForPr = $('#showResultFor' + prId);
-                let buildIsCompleted = isDefinedAndFilled(finishedBranch);
-                let hasJiraIssue = isDefinedAndFilled(row.jiraIssueId);
-                if (buildIsCompleted) {
-                    tdForPr.html("<a id='link_" + prId + "' href='" + prShowHref(srvId, suiteId, finishedBranch) +  "'>" +
-                        "<button id='show_" + prId + "'>Show " + finishedBranch + " report</button></a>");
-
-                    if (hasJiraIssue)
-                        {
-                            let jiraBtn;
-                            jiraBtn = "<button onclick='" +
-                                "commentJira(" +
-                                "\"" + srvId + "\", " +
-                                "\"" + suiteId + "\", " +
-                                "\"" + finishedBranch + "\", " +
-                                "\"" + row.jiraIssueId + "\"" +
-                                ")'>Comment JIRA</button>";
-                            $('#commentJiraFor' + prId).html(jiraBtn);
-                        }
-                } else {
-                    tdForPr.html("No builds, please trigger " + suiteId);
-                }
+                showContributionStatus(result, prId, row, srvId, suiteId);
+            }
+    });
+    return res;
+}
 
-                let hasQueued = result.queuedBuilds > 0 || result.runningBuilds > 0;
 
-                showStageResult(1, prId, hasJiraIssue, !hasJiraIssue);
-                let noNeedToTrigger = hasQueued || buildIsCompleted;
-                showStageResult(2, prId, noNeedToTrigger, false);
-                showStageResult(3, prId, buildIsCompleted, false);
+function showContributionStatus(status, prId, row, srvId, suiteId) {
+    let finishedBranch = status.branchWithFinishedRunAll;
+    let tdForPr = $('#showResultFor' + prId);
+    let buildIsCompleted = isDefinedAndFilled(finishedBranch);
+    let hasJiraIssue = isDefinedAndFilled(row.jiraIssueId);
+    let hasQueued = status.queuedBuilds > 0 || status.runningBuilds > 0;
+    if (buildIsCompleted) {
+        tdForPr.html("<a id='link_" + prId + "' href='" + prShowHref(srvId, suiteId, finishedBranch) + "'>" +
+            "<button id='show_" + prId + "'>Show " + finishedBranch + " report</button></a>");
 
-                if(isDefinedAndFilled(result.resolvedBranch)) {
-                    var trig ="";
-                    trig+= "<button onClick='triggerBuilds(\"" + srvId + "\", \"" + suiteId + "\", \"" +
-                        result.resolvedBranch + "\", false, false)'" ;
+        if (hasJiraIssue) {
+            let jiraBtn = "<button onclick='" +
+                "commentJira(" +
+                "\"" + srvId + "\", " +
+                "\"" + suiteId + "\", " +
+                "\"" + finishedBranch + "\", " +
+                "\"" + row.jiraIssueId + "\"" +
+                ")'";
 
-                    if(noNeedToTrigger) {
-                        trig+=" class='disabledbtn'";
-                    }
-                    trig+=">Trigger build</button>";
-                    $('#triggerBuildFor' + prId).html(trig);
-                }
+            if (hasQueued) {
+                jiraBtn += " class='disabledbtn' title='Has queued builds'";
             }
-    });
-    return res;
+            jiraBtn += ">Comment JIRA</button>";
+
+            $('#commentJiraFor' + prId).html(jiraBtn);
+        }
+    } else {
+        tdForPr.html("No builds, please trigger " + suiteId);
+    }
+
+
+    showStageResult(1, prId, hasJiraIssue, !hasJiraIssue);
+    let noNeedToTrigger = hasQueued || buildIsCompleted;
+    showStageResult(2, prId, noNeedToTrigger, false);
+    showStageResult(3, prId, buildIsCompleted, false);
+
+    if (isDefinedAndFilled(status.resolvedBranch)) {
+        var jiraOptional = hasJiraIssue ? row.jiraIssueId : "";
+        // triggerBuilds(serverId, suiteIdList, branchName, top, observe, ticketId)  defined in test fails
+        var trig = "<button onClick='" +
+            "triggerBuilds(" +
+            "\"" + srvId + "\", " +
+            "\"" + suiteId + "\", " +
+            "\"" + status.resolvedBranch + "\"," +
+            " false," +
+            " true," +
+            "\"" + jiraOptional + "\")'";
+
+        if (noNeedToTrigger) {
+            trig += " class='disabledbtn'";
+        }
+
+        trig += ">Trigger build</button>";
+        $("#triggerBuildFor" + prId).html(trig);
+    }
+
+    if (hasJiraIssue && isDefinedAndFilled(status.resolvedBranch)) {
+        // triggerBuilds(serverId, suiteIdList, branchName, top, observe, ticketId)  defined in test fails
+        var trigAndObs = "<button onClick='" +
+            "triggerBuilds(" +
+            "\"" + srvId + "\", " +
+            "\"" + suiteId + "\", " +
+            "\"" + status.resolvedBranch + "\"," +
+            " false," +
+            " false," +
+            "\"" + jiraOptional + "\")'";
+
+        if (noNeedToTrigger) {
+            trigAndObs += " class='disabledbtn'";
+        }
+
+        trigAndObs += ">Trigger build and comment JIRA after finish</button>";
+
+        $('#triggerAndObserveBuildFor' + prId).html(trigAndObs);
+    }
 }
\ No newline at end of file