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: IGNITE-11880: Configurable tags by build parameters/suite IDS & names (#125)
Date Thu, 30 May 2019 16:24:58 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 ce0fbcf  IGNITE-11880:  Configurable tags by build parameters/suite IDS & names
(#125)
ce0fbcf is described below

commit ce0fbcf28d9b5ef33192d8c2baf2fb1aabbca652
Author: Dmitriy Pavlov <dpavlov@apache.org>
AuthorDate: Thu May 30 19:24:54 2019 +0300

    IGNITE-11880:  Configurable tags by build parameters/suite IDS & names (#125)
---
 .../main/java/org/apache/ignite/ci/ITeamcity.java  |  6 +++
 .../ignite/ci/analysis/SingleBuildRunCtx.java      | 45 +++++++++++++++++++---
 .../ignite/ci/tcbot/conf/ITcServerConfig.java      |  9 ++---
 .../ignite/ci/tcbot/conf/NotificationChannel.java  |  2 +-
 .../ignite/ci/tcbot/conf/NotificationsConfig.java  |  2 +-
 .../ignite/ci/tcbot/conf/ParameterValueSpec.java   | 39 +++++++++++++------
 .../ignite/ci/tcbot/conf/TcServerConfig.java       |  9 -----
 .../ci/teamcity/ignited/runhist/RunHistSync.java   | 21 +++++-----
 .../org/apache/ignite/ci/web/model/Version.java    |  2 +-
 9 files changed, 90 insertions(+), 45 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 d935bb4..5757239 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
@@ -49,6 +49,12 @@ public interface ITeamcity extends ITeamcityConn {
     /** Default list of properties to be skipped in saving in FAT builds. */
     public Set<String> AVOID_SAVE_PROPERTIES = Sets.newHashSet(TCBOT_TRIGGER_TIME,
"build.query.loginTs");
 
+    /** Fake property for addressing 'Suite id'. */
+    public String SUITE_ID_PROPERTY = "_suiteId";
+
+    /** Fake property for addressing 'Suite Name'. */
+    public String SUITE_NAME_PROPERTY = "_suiteName";
+
     CompletableFuture<File> unzipFirstFile(CompletableFuture<File> fut);
 
     CompletableFuture<File> downloadBuildLogZip(int id);
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/analysis/SingleBuildRunCtx.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/analysis/SingleBuildRunCtx.java
index 80dbdbe..7970606 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/analysis/SingleBuildRunCtx.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/analysis/SingleBuildRunCtx.java
@@ -29,11 +29,12 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.Future;
+import java.util.regex.Pattern;
 import java.util.stream.Stream;
 import javax.annotation.Nonnull;
+import org.apache.ignite.ci.ITeamcity;
 import org.apache.ignite.ci.tcbot.conf.BuildParameterSpec;
 import org.apache.ignite.ci.tcbot.conf.ITcServerConfig;
-import org.apache.ignite.ci.tcbot.conf.ParameterValueSpec;
 import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrenceFull;
 import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
 import org.apache.ignite.ci.teamcity.ignited.buildtype.ParametersCompacted;
@@ -261,8 +262,11 @@ public class SingleBuildRunCtx implements ISuiteResults {
             }).sum();
     }
 
-    public void addTag(String label) {
-        this.tags.add(label);
+    public void addTag(@Nullable String lb) {
+        if(Strings.isNullOrEmpty(lb))
+            return;
+
+        this.tags.add(lb);
     }
 
     public Set<String> tags() {
@@ -275,16 +279,47 @@ public class SingleBuildRunCtx implements ISuiteResults {
             if (!parm.isFilled())
                 continue;
 
-            String propVal = parameters.getProperty(compactor, parm.name());
+            String propVal = getPropertyOrSpecialValue(parameters, compactor, parm.name());
 
             if (Strings.isNullOrEmpty(propVal))
                 continue;
 
             parm.selection().stream()
-                .filter(v -> Objects.equals(v.value(), propVal))
+                .filter(pvs -> {
+                    String valRegExp = pvs.valueRegExp();
+
+                    if(!Strings.isNullOrEmpty(valRegExp))
+                        return Pattern.compile(valRegExp).matcher(propVal).find();
+
+                    String exactVal = pvs.value();
+
+                    if(!Strings.isNullOrEmpty(exactVal))
+                        return Objects.equals(exactVal, propVal);
+
+                    return false;
+                })
                 .findAny()
                 .ifPresent(v -> addTag(v.label()));
 
         }
     }
+
+    /**
+     * @param parameters Parameters from build.
+     * @param compactor Compactor.
+     * @param parmKey Parmeters key.
+     */
+    public String getPropertyOrSpecialValue(ParametersCompacted parameters, IStringCompactor
compactor,
+        String parmKey) {
+
+        String propVal;
+        if (ITeamcity.SUITE_ID_PROPERTY.equals(parmKey))
+            propVal = suiteId();
+        else if (ITeamcity.SUITE_NAME_PROPERTY.equals(parmKey))
+            propVal = suiteName();
+        else
+            propVal = parameters.getProperty(compactor, parmKey);
+
+        return propVal;
+    }
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcServerConfig.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcServerConfig.java
index e370501..e55d18a 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcServerConfig.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcServerConfig.java
@@ -45,12 +45,9 @@ public interface ITcServerConfig {
     @NotNull public String defaultTrackedBranch();
 
     /**
-     * @return set of build parameters codes, which could be used for filtering builds in
RunHist/Invocations.
-     */
-    @NotNull public Collection<String> filteringParametersKeys();
-
-    /**
-     * @return set of build parameters, which could be used for filtering builds in RunHist/Invocations.
+     * Provides build parameters, whichi could be used for filtering builds in RunHist/Invocations
and tagging in UI.
+     *
+     * @return set of build parameters specifications.
      */
     @NotNull public Collection<BuildParameterSpec> filteringParameters();
 
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/NotificationChannel.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/NotificationChannel.java
index f70a3e6..87f6e8a 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/NotificationChannel.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/NotificationChannel.java
@@ -24,7 +24,7 @@ import java.util.HashSet;
  *
  */
 public class NotificationChannel implements INotificationChannel {
-    /** Email. */
+    /** (Destionation) Email. */
     private String email;
 
     /** Slack. */
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/NotificationsConfig.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/NotificationsConfig.java
index 4f2ada4..32cd235 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/NotificationsConfig.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/NotificationsConfig.java
@@ -34,7 +34,7 @@ import static com.google.common.base.Strings.isNullOrEmpty;
  * Notifications Config
  */
 public class NotificationsConfig {
-    /** Email. */
+    /** (Source) Email. */
     private EmailSettings email = new EmailSettings();
 
     /** Slack auth token. Not encoded using Password encoder */
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ParameterValueSpec.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ParameterValueSpec.java
index f8032aa..e5b1ee0 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ParameterValueSpec.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ParameterValueSpec.java
@@ -17,7 +17,7 @@
 
 package org.apache.ignite.ci.tcbot.conf;
 
-import com.google.common.base.Objects;
+import java.util.Objects;
 
 /**
  * Some parameter value, which label may be used in UI.
@@ -25,26 +25,43 @@ import com.google.common.base.Objects;
 public class ParameterValueSpec {
     private String value;
     private String label;
+    private String valueRegExp;
 
+    /**
+     * Exact value, which can be present in a build.
+     */
     public String value() {
         return value;
     }
 
+    /**
+     * @return label/tag to be associated with build or shown in selection.
+     */
     public String label() {
         return label;
     }
 
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        ParameterValueSpec that = (ParameterValueSpec) o;
-        return Objects.equal(value, that.value) &&
-                Objects.equal(label, that.label);
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+        if (o == null || getClass() != o.getClass())
+            return false;
+        ParameterValueSpec spec = (ParameterValueSpec)o;
+        return Objects.equals(value, spec.value) &&
+            Objects.equals(label, spec.label) &&
+            Objects.equals(valueRegExp, spec.valueRegExp);
     }
 
-    @Override
-    public int hashCode() {
-        return Objects.hashCode(value, label);
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        return Objects.hash(value, label, valueRegExp);
+    }
+
+    /**
+     *
+     */
+    public String valueRegExp() {
+        return this.valueRegExp;
     }
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/TcServerConfig.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/TcServerConfig.java
index 60b9821..118319d 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/TcServerConfig.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/TcServerConfig.java
@@ -22,7 +22,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
-import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
 import org.apache.ignite.ci.HelperConfig;
 import org.jetbrains.annotations.NotNull;
@@ -115,14 +114,6 @@ public class TcServerConfig implements ITcServerConfig {
     }
 
     /** {@inheritDoc} */
-    @Override public Collection<String> filteringParametersKeys() {
-        if (filteringParameters == null || filteringParameters.isEmpty())
-            return Collections.emptySet();
-
-        return filteringParameters.stream().map(BuildParameterSpec::name).collect(Collectors.toSet());
-    }
-
-    /** {@inheritDoc} */
     @NotNull @Override public Collection<BuildParameterSpec> filteringParameters()
{
         if (filteringParameters == null || filteringParameters.isEmpty())
             return Collections.emptySet();
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/runhist/RunHistSync.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/runhist/RunHistSync.java
index 2c62389..199f8d3 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/runhist/RunHistSync.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/runhist/RunHistSync.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.ci.teamcity.ignited.runhist;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -38,9 +37,9 @@ import org.apache.ignite.ci.di.AutoProfiling;
 import org.apache.ignite.ci.di.MonitoredTask;
 import org.apache.ignite.ci.di.scheduler.IScheduler;
 import org.apache.ignite.ci.tcbot.TcBotSystemProperties;
+import org.apache.ignite.ci.tcbot.conf.BuildParameterSpec;
 import org.apache.ignite.ci.tcbot.conf.ChainAtServerTracked;
 import org.apache.ignite.ci.tcbot.conf.ITcBotConfig;
-import org.apache.ignite.ci.tcbot.conf.ITcServerConfig;
 import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
 import org.apache.ignite.ci.teamcity.ignited.ITeamcityIgnited;
 import org.apache.ignite.ci.teamcity.ignited.buildref.BuildRefDao;
@@ -109,9 +108,9 @@ public class RunHistSync {
         if (histDao.buildWasProcessed(srvId, build.id()))
             return;
 
-        Set<Integer> allTriggeringBuildParameters = getFilteringParameters(srvCode);
+        Set<Integer> allImportantBuildParameters = getFilteringParameters(srvCode);
 
-        BiPredicate<Integer, Integer> parmFilter = (k, v) -> allTriggeringBuildParameters.contains(k);
+        BiPredicate<Integer, Integer> parmFilter = (k, v) -> allImportantBuildParameters.contains(k);
         boolean saveNow = false;
 
         int branchNameNormalized = compactor.getStringId(normalizeBranch(build.branchName(compactor)));
@@ -156,20 +155,20 @@ public class RunHistSync {
     }
 
     @NotNull public Set<Integer> getFilteringParameters(String srvCode) {
-        Set<String> triggerParameters = cfg.getTrackedBranches().getBranches().stream().flatMap(
+        Set<String> importantParameters = cfg.getTrackedBranches().getBranches().stream().flatMap(
             b -> b.getChainsStream()
                 .filter(ChainAtServerTracked::isTriggerBuild)
                 .filter(chain -> Objects.equals(chain.getServerId(), srvCode))
                 .flatMap(ChainAtServerTracked::buildParametersKeys)
         ).collect(Collectors.toSet());
 
-        ITcServerConfig tcCfg = cfg.getTeamcityConfig(srvCode);
+        cfg.getTeamcityConfig(srvCode)
+            .filteringParameters()
+            .stream()
+            .map(BuildParameterSpec::name)
+            .forEach(importantParameters::add);
 
-        Collection<String> filtering = tcCfg.filteringParametersKeys();
-
-        triggerParameters.addAll(filtering);
-
-        return triggerParameters.stream().map(k -> compactor.getStringId(k)).collect(Collectors.toSet());
+        return importantParameters.stream().map(k -> compactor.getStringId(k)).collect(Collectors.toSet());
     }
 
     @MonitoredTask(name = "Save Builds To History(srv, runner)", nameExtArgsIndexes = {0,
1})
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/Version.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/Version.java
index 49c0d72..c89b122 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/Version.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/Version.java
@@ -28,7 +28,7 @@ package org.apache.ignite.ci.web.model;
     public static final String GITHUB_REF = "https://github.com/apache/ignite-teamcity-bot";
 
     /** TC Bot Version. */
-    public static final String VERSION = "20190529";
+    public static final String VERSION = "20190530";
 
     /** Java version, where Web App is running. */
     public String javaVer;


Mime
View raw message