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 2019/03/07 16:25:39 UTC
[ignite-teamcity-bot] branch ignite-11491 updated: IGNITE-11491:
Adapt TC bot to AI CI git proxy: Display actual GitHub Commit in the table
This is an automated email from the ASF dual-hosted git repository.
dpavlov pushed a commit to branch ignite-11491
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git
The following commit(s) were added to refs/heads/ignite-11491 by this push:
new c2df4f8 IGNITE-11491: Adapt TC bot to AI CI git proxy: Display actual GitHub Commit in the table
c2df4f8 is described below
commit c2df4f82c880a4f6a56c565b926ad4141b15505a
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Thu Mar 7 19:17:54 2019 +0300
IGNITE-11491: Adapt TC bot to AI CI git proxy: Display actual GitHub Commit in the table
---
.../org/apache/ignite/ci/github/PullRequest.java | 7 ++++++
.../apache/ignite/ci/tcbot/trigger/BuildLink.java | 23 +++++++++++++++++++
.../ignite/ci/tcbot/trigger/TriggerResult.java | 26 ++++++++++++++++++++++
.../ignite/ci/tcbot/visa/ContributionToCheck.java | 3 +++
.../tcbot/visa/TcBotTriggerAndSignOffService.java | 12 +++++-----
.../apache/ignite/ci/web/rest/TriggerBuilds.java | 7 +++---
ignite-tc-helper-web/src/main/webapp/js/prs-1.1.js | 4 ++++
7 files changed, 74 insertions(+), 8 deletions(-)
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/PullRequest.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/PullRequest.java
index 4437436..1a52921 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/PullRequest.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/PullRequest.java
@@ -19,9 +19,11 @@ package org.apache.ignite.ci.github;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
+import com.google.common.base.Strings;
import com.google.gson.annotations.SerializedName;
import org.apache.ignite.ci.analysis.IVersionedEntity;
import org.apache.ignite.ci.db.Persisted;
+import org.jetbrains.annotations.Nullable;
/**
*
@@ -157,4 +159,9 @@ public class PullRequest implements IVersionedEntity {
return LATEST_VERSION;
}
+ @Nullable public String lastCommitShaShort() {
+ String sha = head().sha();
+
+ return Strings.isNullOrEmpty(sha) ? null : sha.substring(0, 7);
+ }
}
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/trigger/BuildLink.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/trigger/BuildLink.java
new file mode 100644
index 0000000..dfcb43b
--- /dev/null
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/trigger/BuildLink.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ci.tcbot.trigger;
+
+public class BuildLink {
+ String webUrl;
+ String headShaShort;
+}
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/trigger/TriggerResult.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/trigger/TriggerResult.java
new file mode 100644
index 0000000..f809bf9
--- /dev/null
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/trigger/TriggerResult.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ci.tcbot.trigger;
+
+import org.apache.ignite.ci.web.model.SimpleResult;
+
+public class TriggerResult extends SimpleResult {
+ public TriggerResult(String result) {
+ super(result);
+ }
+}
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 ce92d10..c4e1859 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
@@ -38,6 +38,9 @@ package org.apache.ignite.ci.tcbot.visa;
/** Pr html url. */
public String prHtmlUrl;
+ /** Pr head commit hash (first 7 hexes). */
+ public String prHeadCommit;
+
/** Branch Name for team city */
public String tcBranchName;
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 705fe0f..aca9cfb 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
@@ -122,6 +122,7 @@ public class TcBotTriggerAndSignOffService {
/** Helper. */
@Inject ITcBotBgAuth tcBotBgAuth;
+ /** PR chain processor. */
@Inject PrChainsProcessor prChainsProcessor;
/** Config. */
@@ -262,12 +263,11 @@ public class TcBotTriggerAndSignOffService {
try {
PullRequest pr = ghIgn.getPullRequest(Integer.parseInt(prNum));
- String sha = pr.head().sha();
+ if(pr!=null) {
+ String shaShort = pr.lastCommitShaShort();
- if(!Strings.isNullOrEmpty(sha)) {
- String shaShort = sha.substring(0, 7);
-
- jiraRes = "Actual commit: " + shaShort + ". ";
+ if(shaShort!=null)
+ jiraRes = "Actual commit: " + shaShort + ". ";
}
}
catch (NumberFormatException e) {
@@ -387,6 +387,7 @@ public class TcBotTriggerAndSignOffService {
check.prNumber = pr.getNumber();
check.prTitle = pr.getTitle();
check.prHtmlUrl = pr.htmlUrl();
+ check.prHeadCommit = pr.lastCommitShaShort();
check.prTimeUpdate = pr.getTimeUpdate();
GitHubUser user = pr.gitHubUser();
@@ -441,6 +442,7 @@ public class TcBotTriggerAndSignOffService {
contribution.prTitle = ticket.fields.summary;
contribution.prHtmlUrl = "";
+ contribution.prHeadCommit = "";
contribution.prTimeUpdate = ""; //todo ticket updateTime
contribution.prAuthor = "";
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/TriggerBuilds.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/TriggerBuilds.java
index 01764e4..b9a7235 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/TriggerBuilds.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/TriggerBuilds.java
@@ -38,6 +38,7 @@ import org.apache.ignite.ci.jira.pure.IJiraIntegration;
import org.apache.ignite.ci.jira.pure.IJiraIntegrationProvider;
import org.apache.ignite.ci.tcbot.conf.IJiraServerConfig;
import org.apache.ignite.ci.tcbot.conf.ITcBotConfig;
+import org.apache.ignite.ci.tcbot.trigger.TriggerResult;
import org.apache.ignite.ci.teamcity.ignited.ITeamcityIgnitedProvider;
import org.apache.ignite.ci.user.ICredentialsProv;
import org.apache.ignite.ci.tcbot.visa.TcBotTriggerAndSignOffService;
@@ -62,7 +63,7 @@ public class TriggerBuilds {
@GET
@Path("trigger")
- public SimpleResult triggerBuilds(
+ public TriggerResult triggerBuilds(
@Nullable @QueryParam("serverId") String srvCode,
@Nullable @QueryParam("branchName") String branchForTc,
@Nonnull @QueryParam("parentSuiteId") String parentSuiteId,
@@ -78,13 +79,13 @@ public class TriggerBuilds {
injector.getInstance(ITeamcityIgnitedProvider.class).checkAccess(srvCode, prov);
if (isNullOrEmpty(suiteIdList))
- return new SimpleResult("Error: nothing to run.");
+ return new TriggerResult("Error: nothing to run.");
String jiraRes = injector
.getInstance(TcBotTriggerAndSignOffService.class)
.triggerBuildsAndObserve(srvCode, branchForTc, parentSuiteId, suiteIdList, top, observe, ticketId, prNum, prov);
- return new SimpleResult("Tests started." + (!jiraRes.isEmpty() ? "<br>" + jiraRes : ""));
+ return new TriggerResult("Tests started." + (!jiraRes.isEmpty() ? "<br>" + jiraRes : ""));
}
/**
diff --git a/ignite-tc-helper-web/src/main/webapp/js/prs-1.1.js b/ignite-tc-helper-web/src/main/webapp/js/prs-1.1.js
index d9e14e2..28c93a1 100644
--- a/ignite-tc-helper-web/src/main/webapp/js/prs-1.1.js
+++ b/ignite-tc-helper-web/src/main/webapp/js/prs-1.1.js
@@ -114,6 +114,10 @@ function showContributionsTable(result, srvId, suiteId) {
"render": function (data, type, row, meta) {
if (type === 'display' && row.prNumber > 0) {
data = "<a href='" + data + "'>#" + row.prNumber + "</a>";
+
+ if (type === 'display' && isDefinedAndFilled(row.prHeadCommit)) {
+ data += " (" + row.prHeadCommit + ")";
+ }
}
return data;