ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpav...@apache.org
Subject [ignite-teamcity-bot] branch master updated: Building Web links to queued runAll
Date Thu, 11 Oct 2018 16:02:14 GMT
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 ffd34bc  Building Web links to queued runAll
ffd34bc is described below

commit ffd34bc3542f6fb0cf5092e284455797190ade34
Author: Dmitriy Pavlov <dpavlov@apache.org>
AuthorDate: Thu Oct 11 19:02:12 2018 +0300

    Building Web links to queued runAll
---
 .../main/java/org/apache/ignite/ci/ITeamcity.java  |  5 ----
 .../ci/tcbot/visa/ContributionCheckStatus.java     |  5 ++++
 .../tcbot/visa/TcBotTriggerAndSignOffService.java  | 31 ++++++++++++++++------
 .../ci/teamcity/ignited/ITeamcityIgnited.java      |  5 ++++
 .../ci/teamcity/ignited/TeamcityIgnitedImpl.java   |  9 +++++--
 .../ignite/ci/teamcity/pure/ITeamcityConn.java     | 12 ++++++---
 ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js | 30 +++++++++++++++------
 7 files changed, 70 insertions(+), 27 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/ITeamcity.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/ITeamcity.java
index 9a84b0c..6aa3b60 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/ITeamcity.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/ITeamcity.java
@@ -147,11 +147,6 @@ public interface ITeamcity extends ITeamcityConn {
     }
 
     /**
-     * @return Normalized Host address, ends with '/'.
-     */
-    public String host();
-
-    /**
      * @param build
      * @return
      */
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionCheckStatus.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionCheckStatus.java
index 518cdff..c93b246 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionCheckStatus.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/ContributionCheckStatus.java
@@ -16,6 +16,9 @@
  */
 package org.apache.ignite.ci.tcbot.visa;
 
+import java.util.LinkedList;
+import java.util.List;
+
 /**
  * Status of contribution check details returned from server
  */
@@ -30,4 +33,6 @@ package org.apache.ignite.ci.tcbot.visa;
 
     /** Observations status: Filled if build observer has something sheduled related to {@link
#resolvedBranch} */
     public String observationsStatus;
+
+    public List<String> webLinksQueuedRunAlls = new LinkedList<>();
 }
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 7938bd8..e4c957e 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
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 import javax.annotation.Nonnull;
 import javax.inject.Inject;
 import javax.ws.rs.QueryParam;
@@ -231,18 +232,17 @@ public class TcBotTriggerAndSignOffService {
         }).collect(Collectors.toList());
     }
 
-    @Nonnull private List<BuildRef> findRunAllsForPr(String srvId, ICredentialsProv
prov, String suiteId, String prId) {
-        ITeamcityIgnited srv = teamcityIgnitedProvider.server(srvId, prov);
+    @Nonnull private List<BuildRef> findRunAllsForPr(String suiteId, String prId, ITeamcityIgnited
server) {
 
         String branchName = branchForTcA(prId);
-        List<BuildRef> buildHist = srv.getBuildHistory(suiteId, branchName);
+        List<BuildRef> buildHist = server.getBuildHistory(suiteId, branchName);
 
         if (!buildHist.isEmpty())
             return buildHist;
 
 
         //todo multibranch requestst
-        buildHist = srv.getBuildHistory(suiteId, branchForTcB(prId));
+        buildHist = server.getBuildHistory(suiteId, branchForTcB(prId));
 
         if (!buildHist.isEmpty())
             return buildHist;
@@ -268,7 +268,9 @@ public class TcBotTriggerAndSignOffService {
         String prId) {
         ContributionCheckStatus status = new ContributionCheckStatus();
 
-        List<BuildRef> allRunAlls = findRunAllsForPr(srvId, prov, suiteId, prId);
+        ITeamcityIgnited teamcity = teamcityIgnitedProvider.server(srvId, prov);
+
+        List<BuildRef> allRunAlls = findRunAllsForPr(suiteId, prId, teamcity);
 
         boolean finishedRunAllPresent = allRunAlls.stream().filter(BuildRef::isNotCancelled).anyMatch(BuildRef::isFinished);
 
@@ -288,10 +290,23 @@ public class TcBotTriggerAndSignOffService {
 
         status.observationsStatus  = Strings.emptyToNull(observationsStatus);
 
-        //todo take into accounts not only run alls:
-        status.queuedBuilds = (int)allRunAlls.stream().filter(BuildRef::isNotCancelled).filter(BuildRef::isQueued).count();
-        status.runningBuilds = (int)allRunAlls.stream().filter(BuildRef::isNotCancelled).filter(BuildRef::isRunning).count();
+        List<BuildRef> queuedRunAlls = allRunAlls.stream().filter(BuildRef::isNotCancelled).filter(BuildRef::isQueued).collect(Collectors.toList());
+        List<BuildRef> runninRunAlls = allRunAlls.stream().filter(BuildRef::isNotCancelled).filter(BuildRef::isRunning).collect(Collectors.toList());
+        status.queuedBuilds = queuedRunAlls.size();//todo take into accounts not only run
alls:
+        status.runningBuilds = runninRunAlls.size();
+
+        status.webLinksQueuedRunAlls = Stream.concat(queuedRunAlls.stream(), runninRunAlls.stream())
+            .map(ref -> getWebLinkToQueued(teamcity, ref)).collect(Collectors.toList());
 
         return status;
     }
+
+    //later may move it to BuildRef webUrl
+    /**
+     * @param teamcity Teamcity.
+     * @param ref Reference.
+     */
+    @NotNull public String getWebLinkToQueued(ITeamcityIgnited teamcity, BuildRef ref) {
+        return teamcity.host() + "viewQueued.html?itemId=" + ref.getId();
+    }
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/ITeamcityIgnited.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/ITeamcityIgnited.java
index aacb2d7..470d5d1 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/ITeamcityIgnited.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/ITeamcityIgnited.java
@@ -26,6 +26,11 @@ import org.apache.ignite.ci.tcmodel.result.Build;
  */
 public interface ITeamcityIgnited {
     /**
+     * @return Normalized Host address, ends with '/'.
+     */
+    public String host();
+
+    /**
      * @param buildTypeId Build type identifier.
      * @param branchName Branch name.
      * @return list of builds in history, includes all statuses: queued, running, etc
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/TeamcityIgnitedImpl.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/TeamcityIgnitedImpl.java
index fba2f1a..746ef38 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/TeamcityIgnitedImpl.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/TeamcityIgnitedImpl.java
@@ -27,13 +27,14 @@ import org.apache.ignite.ci.di.MonitoredTask;
 import org.apache.ignite.ci.di.scheduler.IScheduler;
 import org.apache.ignite.ci.tcmodel.hist.BuildRef;
 import org.apache.ignite.ci.tcmodel.result.Build;
+import org.apache.ignite.ci.teamcity.pure.ITeamcityConn;
 
 public class TeamcityIgnitedImpl implements ITeamcityIgnited {
     /** Server id. */
     private String srvId;
 
     /** Pure HTTP Connection API. */
-    private ITeamcity conn;
+    private ITeamcityConn conn;
 
 
     /** Scheduler. */
@@ -45,7 +46,7 @@ public class TeamcityIgnitedImpl implements ITeamcityIgnited {
     private long srvIdMaskHigh;
 
 
-    public void init(String srvId, ITeamcity conn) {
+    public void init(String srvId, ITeamcityConn conn) {
         this.srvId = srvId;
         this.conn = conn;
 
@@ -53,6 +54,10 @@ public class TeamcityIgnitedImpl implements ITeamcityIgnited {
         buildRefDao.init(); //todo init somehow in auto
     }
 
+    /** {@inheritDoc} */
+    @Override public String host() {
+        return conn.host();
+    }
 
     /** {@inheritDoc} */
     @AutoProfiling
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/pure/ITeamcityConn.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/pure/ITeamcityConn.java
index 9494bd5..516bd5a 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/pure/ITeamcityConn.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/pure/ITeamcityConn.java
@@ -24,16 +24,20 @@ import org.apache.ignite.ci.tcmodel.hist.BuildRef;
 import org.apache.ignite.ci.tcmodel.result.Build;
 
 /**
- * Pure Teamcity Connection
- * API for calling methods from REST service:
- * https://confluence.jetbrains.com/display/TCD10/REST+API
+ * Pure Teamcity Connection API for calling methods from REST service: https://confluence.jetbrains.com/display/TCD10/REST+API
  */
 public interface ITeamcityConn {
+    /**
+     * @return Normalized Host address, ends with '/'.
+     */
+    public String host();
+
     public List<BuildRef> getBuildRefs(String fullUrl, AtomicReference<String>
nextPage);
 
     /**
      * Trigger build.
-     *  @param buildTypeId Build identifier.
+     *
+     * @param buildTypeId Build identifier.
      * @param branchName Branch name.
      * @param cleanRebuild Rebuild all dependencies.
      * @param queueAtTop Put at the top of the build queue.
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 c8e24e4..321e5d3 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
@@ -93,7 +93,7 @@ function showContributionsTable(result, srvId, suiteId) {
                 "render": function (data, type, row, meta) {
                     let prId = data;
                     if (type === 'display' && isDefinedAndFilled(data)) {
-                        data = "<a id='link_" + prId + "' href='" +
+                        data = "<a id='showReportlink_" + prId + "' href='" +
                             prShowHref(srvId, suiteId, data) +
                             "'>" +
                             "<button id='show_" + prId + "'>Open " + data + "head</button></a>";
@@ -151,8 +151,6 @@ function formatContributionDetails(row, srvId, suiteId) {
     if(!isDefinedAndFilled(row))
         return;
 
-    console.log("format " + row + ": " + srvId);
-
     let prId = row.prNumber;
     var res = "";
     res += "<div class='formgroup'>";
@@ -178,10 +176,10 @@ function formatContributionDetails(row, srvId, suiteId) {
 
     //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" +
+        "            <td></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>";
 
     //action row 2
@@ -190,6 +188,14 @@ function formatContributionDetails(row, srvId, suiteId) {
         "            <td id='triggerAndObserveBuildFor" + prId + "' colspan='3' align='center'>d</td>\n"
+
         "           </tr>";
 
+    //References
+    res += "        <tr>\n" +
+        "            <td>Edit PR: " + "<a href='" + row.prHtmlUrl + "'>#" + row.prNumber
+ "</a>" + "</td>\n" +
+        "            <td id='viewQueuedBuildsFor" + prId + "'></td>\n" +
+        "            <td></td>\n" +
+        "            <td></td>\n" +
+        "        </tr>";
+
     res += "    </table>";
 
     res += "</div>";
@@ -248,8 +254,16 @@ function showContributionStatus(status, prId, row, srvId, suiteId) {
         "\"" + srvId + "\", " +
         "\"" + suiteId + "\", " +
         ");";
+
+    var linksToRunningBuilds = "";
+    for (let i = 0; i < status.webLinksQueuedRunAlls.length; i++) {
+        const l = status.webLinksQueuedRunAlls[i];
+        linksToRunningBuilds += "<a href=" + l + ">View queued at TC</a> "
+    }
+    $('#viewQueuedBuildsFor' + prId).html(linksToRunningBuilds);
+
     if (buildIsCompleted) {
-        tdForPr.html("<a id='link_" + prId + "' href='" + prShowHref(srvId, suiteId, finishedBranch)
+ "'>" +
+        tdForPr.html("<a id='showReportlink_" + prId + "' href='" + prShowHref(srvId,
suiteId, finishedBranch) + "'>" +
             "<button id='show_" + prId + "'>Show " + finishedBranch + " report</button></a>");
 
         if (hasJiraIssue) {


Mime
View raw message