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/10 16:28:59 UTC

[ignite-teamcity-bot] 01/01: Steps to get visa adding to UI started

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

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

commit 9802ca4b6a26fe2172c3f6ad742cf289fec32aa1
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Wed Oct 10 19:28:41 2018 +0300

    Steps to get visa adding to UI started
---
 ...onToCheck.java => ContributionCheckStatus.java} | 24 ++----
 .../ignite/ci/tcbot/visa/ContributionToCheck.java  |  3 +
 .../tcbot/visa/TcBotTriggerAndSignOffService.java  | 16 ++++
 .../ignite/ci/web/rest/visa/TcBotVisaService.java  | 17 +++++
 .../src/main/webapp/css/style-1.5.css              | 20 +++++
 ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js | 86 +++++++++++++++-------
 6 files changed, 122 insertions(+), 44 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionToCheck.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionCheckStatus.java
similarity index 67%
copy from ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionToCheck.java
copy to ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionCheckStatus.java
index 1b189ab..538fcc7 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionToCheck.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionCheckStatus.java
@@ -17,24 +17,10 @@
 package org.apache.ignite.ci.tcbot.visa;
 
 /**
- *
+ * Status of contribution check details returned from server
  */
-@SuppressWarnings("PublicField") public class ContributionToCheck {
-    /** Pr number. */
-    public Integer prNumber;
-
-    /** Pr title. */
-    public String prTitle;
-
-    /** Pr author. */
-    public String prAuthor;
-
-    /** Pr author avatar url. */
-    public String prAuthorAvatarUrl;
-
-    /** Pr html url. */
-    public String prHtmlUrl;
-
-    /** Branch Name for team city */
-    public String tcBranchName;
+@SuppressWarnings("PublicField") public class ContributionCheckStatus {
+    public int queuedBuilds;
+    public int runningBuilds;
+    public String finishedRunAllForBranch;
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionToCheck.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionToCheck.java
index 1b189ab..9b625cb 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionToCheck.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionToCheck.java
@@ -37,4 +37,7 @@ package org.apache.ignite.ci.tcbot.visa;
 
     /** Branch Name for team city */
     public String tcBranchName;
+
+    /** JIRA issue without server URL */
+    public String jiraIssueId;
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
index 1a5fd08..3a4365a 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
@@ -207,6 +207,8 @@ public class TcBotTriggerAndSignOffService {
                 check.prAuthorAvatarUrl = user.avatarUrl();
             }
 
+            check.jiraIssueId = Strings.emptyToNull(getTicketId(pr));
+
             return check;
         }).collect(Collectors.toList());
     }
@@ -235,4 +237,18 @@ public class TcBotTriggerAndSignOffService {
     String branchForTcB(String prId) {
         return "pull/" + prId + "/merge";
     }
+
+    /**
+     * @param srvId Server id.
+     * @param prov Prov.
+     * @param suiteId Suite id.
+     * @param prId Pr id.
+     */
+    public ContributionCheckStatus contributionStatus(String srvId, ICredentialsProv prov, String suiteId, String prId) {
+        ContributionCheckStatus status = new ContributionCheckStatus();
+
+        status.finishedRunAllForBranch = findBranchForPr(srvId, prov, suiteId, prId);
+
+        return status;
+    }
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/visa/TcBotVisaService.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/visa/TcBotVisaService.java
index bb2c71f..a78ee90 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/visa/TcBotVisaService.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/visa/TcBotVisaService.java
@@ -26,6 +26,7 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
+import org.apache.ignite.ci.tcbot.visa.ContributionCheckStatus;
 import org.apache.ignite.ci.user.ICredentialsProv;
 import org.apache.ignite.ci.tcbot.visa.ContributionToCheck;
 import org.apache.ignite.ci.tcbot.visa.TcBotTriggerAndSignOffService;
@@ -59,6 +60,22 @@ public class TcBotVisaService {
     }
 
     @GET
+    @Path("contributionStatus")
+    public ContributionCheckStatus contributionStatus(@Nullable @QueryParam("serverId") String srvId,
+        @Nonnull @QueryParam("suiteId") String suiteId,
+        @QueryParam("prId") String prId) {
+        ICredentialsProv prov = ICredentialsProv.get(req);
+        if (!prov.hasAccess(srvId))
+            throw ServiceUnauthorizedException.noCreds(srvId);
+
+        TcBotTriggerAndSignOffService instance = CtxListener.getInjector(ctx)
+            .getInstance(TcBotTriggerAndSignOffService.class);
+
+        return instance.contributionStatus(srvId, prov, suiteId, prId);
+    }
+
+    @Deprecated
+    @GET
     @Path("findBranchForPr")
     public SimpleResult findBranchForPr(@Nullable @QueryParam("serverId") String srvId,
         @Nonnull @QueryParam("suiteId") String suiteId,
diff --git a/ignite-tc-helper-web/src/main/webapp/css/style-1.5.css b/ignite-tc-helper-web/src/main/webapp/css/style-1.5.css
index f059b3b..af7c7b7 100644
--- a/ignite-tc-helper-web/src/main/webapp/css/style-1.5.css
+++ b/ignite-tc-helper-web/src/main/webapp/css/style-1.5.css
@@ -135,6 +135,26 @@ form, .formgroup {
     width: 100px;
     min-height: 100px;
     height: 100px;
+	border-radius: 3px;
+}
+
+.visaStage {
+	float: left;
+	background: #b4b4b4;
+	height: 30px;
+	width: 30px;
+	color: #FFF;
+	font-weight: bold;
+	font-family: sans-serif;
+	font-size: 15px;
+	vertical-align: middle;
+	display: inline-block;
+	margin: 5px;
+	box-shadow: 3px 2px 6px -2px rgba(0,0,0,0.64);
+	border: 1px solid #FFF;
+	border-radius: 15px;
+	transition: ease-in 0.175s;
+	text-align: center;
 }
 
 html {
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 dc34fb4..06e0f4d 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
@@ -9,6 +9,7 @@ function drawTable(srvId, suiteId, element) {
         "                <th>Loading</th>\n" +
         "                <th>...</th>\n" +
         "                <th>.</th>\n" +
+        "                <th>.</th>\n" +
         "            </tr>\n" +
         "            </thead>\n" +
         "        </table>\n");
@@ -83,6 +84,10 @@ function showContributionsTable(result, srvId, suiteId) {
 
             },
             {
+                "data": "jiraIssueId",
+                title: "JIRA Issue"
+            },
+            {
                 "data": "tcBranchName",
                 title: "Resolved Branch Name",
                 "render": function (data, type, row, meta) {
@@ -118,47 +123,78 @@ function showContributionsTable(result, srvId, suiteId) {
     });
 }
 
-function showButtonForPr(srvId, suiteId, prId, branchName) {
-    var showRunRes = "<a id='link_" + prId + "' href='" +
-        prShowHref(srvId, suiteId, branchName) +
-        "'>" +
-        "<button id='show_" + prId + "'>Show " + branchName + " branch report</button></a>";
-
-    return showRunRes;
+function showStageResult(stageNum, prId, passed, failed) {
+    let stageOneStatus = $('#visaStage_' + stageNum + '_' + prId);
+    let html;
+    if (passed) {
+        html = "&#x2714;";
+        stageOneStatus.css('background', '#12AD5E');
+    } else {
+        html = "&#x274C;";
+        if(failed)
+        stageOneStatus.css('background', 'red');
+    }
+    stageOneStatus.html(html);
 }
 
 /* Formatting function for row details - modify as you need */
-function formatContributionDetails(rowData, srvId, suiteId) {
+function formatContributionDetails(row, srvId, suiteId) {
     // `rowData` is the original data object for the row
 
-    let prId = rowData.prNumber;
+    let prId = row.prNumber;
     var res = "";
-    res+="<div class='formgroup'>";
-    res+="<table cellpadding='5' cellspacing='0' border='0' style='padding-left:50px;'>\n" +
-        "        <tr>\n" +
-        "            <td>PR number:</td>\n" +
-        "            <td>" + rowData.prNumber + "</td>\n" +
+    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>Results ready</td>\n" +
+        "                <td>JIRA comment</td>\n" +
+        //todo  "                <td>Validity check</td>\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" +
         "        </tr>" +
-        "        <tr>\n" +
-        "            <td>Show Run All Results:</td>\n" +
-        "            <td id='branchFor_" + prId + "'>Loading builds...</td>\n" +
-        "        </tr>\n" +
         "    </table>";
-    res+="</div>";
+    res += "</div>";
+
+
     $.ajax({
-        url: "rest/visa/findBranchForPr?serverId=" + srvId +
+        url: "rest/visa/contributionStatus?serverId=" + srvId +
             "&suiteId=" + suiteId +
             "&prId=" + prId,
         success:
             function (result) {
-                // console.log("Contribution " + prId + " bransh: " + result + " ");
-                let branchName = result.result;
-                let tdForPr = $('#branchFor_' + prId);
-                if (isDefinedAndFilled(branchName)) {
-                    tdForPr.html(showButtonForPr(srvId, suiteId, prId, branchName));
+                let branchName = result.finishedRunAllForBranch;
+                let tdForPr = $('#showResultFor' + prId);
+                let buildIsCompleted = isDefinedAndFilled(branchName);
+                if (buildIsCompleted) {
+                    tdForPr.html("<a id='link_" + prId + "' href='" + prShowHref(srvId, suiteId, branchName) +  "'>" +
+                        "<button id='show_" + prId + "'>Show " + branchName + " report</button></a>");
                 } else {
                     tdForPr.html("No builds, please trigger " + suiteId);
                 }
+
+
+                let jiraIssue = isDefinedAndFilled(row.jiraIssueId);
+                showStageResult(1, prId, jiraIssue, !jiraIssue);
+                showStageResult(2, prId, buildIsCompleted, false);
+                showStageResult(3, prId, buildIsCompleted, false);
             }
     });
     return res;