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 ignite-10243 updated: IGNITE-10243 Cancelled runAll display as valid in PRs table
Date Fri, 16 Nov 2018 11:53:30 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/ignite-10243 by this push:
     new 13af56c  IGNITE-10243 Cancelled runAll display as valid in PRs table
13af56c is described below

commit 13af56c7bc4a664867afa4bd47f010f1c9ed8a45
Author: Dmitriy Pavlov <dpavlov@apache.org>
AuthorDate: Fri Nov 16 14:53:28 2018 +0300

    IGNITE-10243 Cancelled runAll display as valid in PRs table
---
 .../ignite/ci/tcbot/chain/BuildChainProcessor.java |  4 +-
 .../ci/tcbot/visa/ContributionCheckStatus.java     |  6 ++-
 .../tcbot/visa/TcBotTriggerAndSignOffService.java  | 54 ++++++++++++++--------
 .../ci/teamcity/ignited/ITeamcityIgnited.java      |  4 +-
 .../ci/teamcity/ignited/TeamcityIgnitedImpl.java   | 10 ++--
 .../ignited/IgnitedTcInMemoryIntegrationTest.java  | 13 +++---
 6 files changed, 55 insertions(+), 36 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/chain/BuildChainProcessor.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/chain/BuildChainProcessor.java
index 280a40e..974f648 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/chain/BuildChainProcessor.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/chain/BuildChainProcessor.java
@@ -288,7 +288,7 @@ public class BuildChainProcessor {
         final String branch = getBranchOrDefault(buildCompacted.branchName(compactor));
 
         final String buildTypeId = buildCompacted.buildTypeId(compactor);
-        Stream<BuildRefCompacted> hist = teamcityIgnited.getBuildHistoryCompacted(buildTypeId,
branch)
+        Stream<BuildRefCompacted> hist = teamcityIgnited.getAllBuildsCompacted(buildTypeId,
branch)
             .stream()
             .filter(t -> !t.isCancelled(compactor))
             .filter(t -> t.isFinished(compactor));
@@ -320,7 +320,7 @@ public class BuildChainProcessor {
     protected void fillBuildCounts(MultBuildRunCtx outCtx,
         ITeamcityIgnited teamcityIgnited, boolean includeScheduledInfo) {
         if (includeScheduledInfo && !outCtx.hasScheduledBuildsInfo()) {
-            final List<BuildRefCompacted> runAllBuilds = teamcityIgnited.getBuildHistoryCompacted(outCtx.buildTypeId(),
outCtx.branchName());
+            final List<BuildRefCompacted> runAllBuilds = teamcityIgnited.getAllBuildsCompacted(outCtx.buildTypeId(),
outCtx.branchName());
 
             long cntRunning = runAllBuilds
                     .stream()
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 c93b246..62dfc3f 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
@@ -25,9 +25,13 @@ import java.util.List;
 @SuppressWarnings("PublicField") public class ContributionCheckStatus {
     public int queuedBuilds;
     public int runningBuilds;
-    /** Branch with finished run all results, null if run all is running or in case there
was no run alls at all. */
+
+    /** Branch with finished/cancelled run all results, null if run all is running or in
case there was no run alls at all. */
     public String branchWithFinishedRunAll;
 
+    /** Run all finished for brach {@link #branchWithFinishedRunAll}. Determines trigger
button color. */
+    public Boolean runAllFinished;
+
     /** Resolved run all branch: Some branch probably with finished or queued builds in in,
or default pull/nnnn/head. */
     public String resolvedBranch;
 
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 8de540d..ab2bc56 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
@@ -41,6 +41,7 @@ import org.apache.ignite.ci.observer.BuildObserver;
 import org.apache.ignite.ci.tcmodel.hist.BuildRef;
 import org.apache.ignite.ci.observer.BuildsInfo;
 import org.apache.ignite.ci.tcmodel.result.Build;
+import org.apache.ignite.ci.teamcity.ignited.BuildRefCompacted;
 import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
 import org.apache.ignite.ci.teamcity.ignited.ITeamcityIgnited;
 import org.apache.ignite.ci.teamcity.ignited.ITeamcityIgnitedProvider;
@@ -78,7 +79,7 @@ public class TcBotTriggerAndSignOffService {
     @Inject private VisasHistoryStorage visasHistoryStorage;
 
     /** */
-    @Inject IStringCompactor strCompactor;
+    @Inject IStringCompactor compactor;
 
     /** Helper. */
     @Inject ITcHelper tcHelper;
@@ -310,17 +311,16 @@ public class TcBotTriggerAndSignOffService {
         }).collect(Collectors.toList());
     }
 
-    @Nonnull private List<BuildRef> findRunAllsForPr(String suiteId, String prId, ITeamcityIgnited
server) {
+    @Nonnull private List<BuildRefCompacted> findRunAllsForPr(String suiteId, String
prId, ITeamcityIgnited srv) {
 
         String branchName = branchForTcA(prId);
-        List<BuildRef> buildHist = server.getBuildHistory(suiteId, branchName);
+        List<BuildRefCompacted> buildHist = srv.getAllBuildsCompacted(suiteId, branchName);
 
         if (!buildHist.isEmpty())
             return buildHist;
 
-
         //todo multibranch requestst
-        buildHist = server.getBuildHistory(suiteId, branchForTcB(prId));
+        buildHist = srv.getAllBuildsCompacted(suiteId, branchForTcB(prId));
 
         if (!buildHist.isEmpty())
             return buildHist;
@@ -348,29 +348,43 @@ public class TcBotTriggerAndSignOffService {
 
         ITeamcityIgnited teamcity = teamcityIgnitedProvider.server(srvId, prov);
 
-        List<BuildRef> allRunAlls = findRunAllsForPr(suiteId, prId, teamcity);
+        List<BuildRefCompacted> allRunAlls = findRunAllsForPr(suiteId, prId, teamcity);
 
-        boolean finishedRunAllPresent = allRunAlls.stream().filter(BuildRef::isNotCancelled).anyMatch(BuildRef::isFinished);
+        List<BuildRefCompacted> finishedOrCancelled = allRunAlls.stream()
+            .filter(t -> t.isFinished(compactor)).collect(Collectors.toList());
 
-        status.branchWithFinishedRunAll = finishedRunAllPresent ? allRunAlls.get(0).branchName
: null;
+        if (!finishedOrCancelled.isEmpty()) {
+            BuildRefCompacted buildRefCompacted = finishedOrCancelled.get(0);
 
-        if (status.branchWithFinishedRunAll == null) {
-            if (!allRunAlls.isEmpty())
-                status.resolvedBranch = allRunAlls.get(0).branchName;
-            else
-                status.resolvedBranch = branchForTcA(prId);
+            status.runAllFinished = !buildRefCompacted.isCancelled(compactor);
+            status.branchWithFinishedRunAll = buildRefCompacted.branchName(compactor);
         }
-        else
-            //todo take into account running/queued
+        else {
+            status.branchWithFinishedRunAll = null;
+            status.runAllFinished = false;
+        }
+
+        if (status.branchWithFinishedRunAll != null)
             status.resolvedBranch = status.branchWithFinishedRunAll;
+            //todo take into account running/queued
+        else
+            status.resolvedBranch = !allRunAlls.isEmpty() ? allRunAlls.get(0).branchName(compactor)
: branchForTcA(prId);
 
         String observationsStatus = observer.get().getObservationStatus(srvId, status.resolvedBranch);
 
         status.observationsStatus  = Strings.emptyToNull(observationsStatus);
 
-        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:
+        List<BuildRefCompacted> queuedRunAlls = allRunAlls.stream()
+            .filter(t -> t.isNotCancelled(compactor))
+            .filter(t -> t.isQueued(compactor))
+            .collect(Collectors.toList());
+
+        List<BuildRefCompacted> runninRunAlls = allRunAlls.stream()
+            .filter(t -> t.isNotCancelled(compactor))
+            .filter(t -> t.isRunning(compactor))
+            .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())
@@ -384,7 +398,7 @@ public class TcBotTriggerAndSignOffService {
      * @param teamcity Teamcity.
      * @param ref Reference.
      */
-    @NotNull public String getWebLinkToQueued(ITeamcityIgnited teamcity, BuildRef ref) {
-        return teamcity.host() + "viewQueued.html?itemId=" + ref.getId();
+    @NotNull public String getWebLinkToQueued(ITeamcityIgnited teamcity, BuildRefCompacted
ref) {
+        return teamcity.host() + "viewQueued.html?itemId=" + ref.id();
     }
 }
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 7a4faf4..c6291d8 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
@@ -48,7 +48,7 @@ public interface ITeamcityIgnited {
      * @param branchName Branch name.
      * @return list of builds in history, includes all statuses: queued, running, etc
      */
-    public List<BuildRefCompacted> getBuildHistoryCompacted(
+    public List<BuildRefCompacted> getAllBuildsCompacted(
             @Nullable String buildTypeId,
             @Nullable String branchName);
 
@@ -59,7 +59,7 @@ public interface ITeamcityIgnited {
      * @param branchName Branch name.
      * @return list of builds in history, includes all statuses: queued, running, etc
      */
-    public List<BuildRef> getBuildHistory(
+    public List<BuildRef> getAllBuildsHistory(
         @Nullable String buildTypeId,
         @Nullable String branchName);
 
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 607f41c..d2ed26d 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
@@ -120,7 +120,7 @@ public class TeamcityIgnitedImpl implements ITeamcityIgnited {
     }
 
     /** {@inheritDoc} */
-    public List<BuildRefCompacted> getFinishedBuildsCompacted(
+    @Override public List<BuildRefCompacted> getFinishedBuildsCompacted(
         @Nullable String buildTypeId,
         @Nullable String branchName,
         @Nullable Date sinceDate,
@@ -130,7 +130,7 @@ public class TeamcityIgnitedImpl implements ITeamcityIgnited {
         final int invalidVal = -3;
         final int unknownStatus = compactor.getStringId(STATUS_UNKNOWN);
 
-        List<BuildRefCompacted> buildRefs = getBuildHistoryCompacted(buildTypeId, branchName)
+        List<BuildRefCompacted> buildRefs = getAllBuildsCompacted(buildTypeId, branchName)
             .stream().filter(b -> b.status() != unknownStatus).collect(Collectors.toList());
 
         int idSince = 0;
@@ -268,7 +268,7 @@ public class TeamcityIgnitedImpl implements ITeamcityIgnited {
 
     /** {@inheritDoc} */
     @AutoProfiling
-    @Override public List<BuildRef> getBuildHistory(
+    @Override public List<BuildRef> getAllBuildsHistory(
             @Nullable String buildTypeId,
             @Nullable String branchName) {
         ensureActualizeRequested();
@@ -282,7 +282,7 @@ public class TeamcityIgnitedImpl implements ITeamcityIgnited {
 
     /** {@inheritDoc} */
     @AutoProfiling
-    @Override public List<BuildRefCompacted> getBuildHistoryCompacted(
+    @Override public List<BuildRefCompacted> getAllBuildsCompacted(
             @Nullable String buildTypeId,
             @Nullable String branchName) {
         ensureActualizeRequested();
@@ -295,7 +295,7 @@ public class TeamcityIgnitedImpl implements ITeamcityIgnited {
     /** {@inheritDoc} */
     @AutoProfiling
     @Override @NotNull public List<Integer> getLastNBuildsFromHistory(String btId,
String branchForTc, int cnt) {
-        List<BuildRefCompacted> hist = getBuildHistoryCompacted(btId, branchForTc);
+        List<BuildRefCompacted> hist = getAllBuildsCompacted(btId, branchForTc);
 
         List<Integer> chains = hist.stream()
             .filter(ref -> !ref.isFakeStub())
diff --git a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
index 489cebc..5c2c41a 100644
--- a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
+++ b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
@@ -138,20 +138,21 @@ public class IgnitedTcInMemoryIntegrationTest {
         });
 
         ITeamcityIgnited srv = injector.getInstance(ITeamcityIgnitedProvider.class).server(APACHE,
creds());
+        IStringCompactor compactor = injector.getInstance(IStringCompactor.class);
 
         String buildTypeId = "IgniteTests24Java8_RunAll";
         String branchName = "<default>";
-        List<BuildRef> hist = srv.getBuildHistory(buildTypeId, branchName);
+        List<BuildRefCompacted> hist = srv.getAllBuildsCompacted(buildTypeId, branchName);
         //todo mult branches including pull/4926/head
 
         assertTrue(!hist.isEmpty());
 
-        for (BuildRef h : hist) {
+        for (BuildRefCompacted h : hist) {
             System.out.println(h);
 
-            assertEquals(buildTypeId, h.suiteId());
+            assertEquals(buildTypeId, h.buildTypeId(compactor));
 
-            assertEquals("refs/heads/master", h.branchName());
+            assertEquals("refs/heads/master", h.branchName(compactor));
         }
 
         ignite.cache(STRINGS_CACHE).forEach(
@@ -212,7 +213,7 @@ public class IgnitedTcInMemoryIntegrationTest {
         teamcityIgnited.fullReindex();
         String buildTypeId = "IgniteTests24Java8_RunAll";
         String branchName = "<default>";
-        List<String> statues = srv.getBuildHistory(buildTypeId, branchName).stream().map(BuildRef::state).distinct().collect(Collectors.toList());
+        List<String> statues = srv.getAllBuildsHistory(buildTypeId, branchName).stream().map(BuildRef::state).distinct().collect(Collectors.toList());
         System.out.println("Before " + statues);
 
         for (int i = queuedBuildIdx; i < tcBuilds.size(); i++)
@@ -221,7 +222,7 @@ public class IgnitedTcInMemoryIntegrationTest {
         teamcityIgnited.actualizeRecentBuildRefs();
 
 
-        List<BuildRef> hist = srv.getBuildHistory(buildTypeId, branchName);
+        List<BuildRef> hist = srv.getAllBuildsHistory(buildTypeId, branchName);
 
         assertTrue(!hist.isEmpty());
 


Mime
View raw message