Skip to content
Permalink
Browse files
IGNITE-11491 Display build GitHub Commit for the finished build (#113)
  • Loading branch information
dspavlov committed Mar 7, 2019
1 parent 26a9b0c commit 3e12562109002715116c8dd72405ec37774fcf35
Showing 6 changed files with 47 additions and 4 deletions.
@@ -31,6 +31,7 @@
@Persisted
public class PullRequest implements IVersionedEntity {
public static final String OPEN = "open";
public static final int INCLUDE_SHORT_VER = 7;
/** Latest version. */
private static final int LATEST_VERSION = 7;

@@ -162,6 +163,6 @@ public GitHubBranch head() {
@Nullable public String lastCommitShaShort() {
String sha = head().sha();

return Strings.isNullOrEmpty(sha) ? null : sha.substring(0, 7);
return Strings.isNullOrEmpty(sha) ? null : sha.substring(0, INCLUDE_SHORT_VER);
}
}
@@ -36,6 +36,9 @@
/** Branch with finished/cancelled suite results, null if suite is running or in case there was no run suite at all. */
public String branchWithFinishedSuite;

/** Finished suite commit hash short. */
public String finishedSuiteCommit;

/** Suite finished for brach {@link #branchWithFinishedSuite}. Determines trigger button color. */
public Boolean suiteIsFinished;

@@ -60,6 +60,7 @@
import org.apache.ignite.ci.teamcity.ignited.SyncMode;
import org.apache.ignite.ci.teamcity.ignited.buildtype.BuildTypeCompacted;
import org.apache.ignite.ci.teamcity.ignited.buildtype.BuildTypeRefCompacted;
import org.apache.ignite.ci.teamcity.ignited.change.ChangeCompacted;
import org.apache.ignite.ci.teamcity.ignited.fatbuild.FatBuildCompacted;
import org.apache.ignite.ci.user.ICredentialsProv;
import org.apache.ignite.ci.web.model.ContributionKey;
@@ -604,9 +605,33 @@ public ContributionCheckStatus contributionStatus(String srvId, String suiteId,

status.suiteIsFinished = !buildRefCompacted.isCancelled(compactor);
status.branchWithFinishedSuite = buildRefCompacted.branchName(compactor);

FatBuildCompacted fatBuild = teamcity.getFatBuild(buildRefCompacted.id(), SyncMode.NONE);

int changeMax = -1;
int[] changes = fatBuild.changes();
for (int i = 0; i < changes.length; i++) {
int change = changes[i];
if (change > changeMax)
changeMax = change;
}

if (changeMax > 0) {
final Collection<ChangeCompacted> allChanges = teamcity.getAllChanges(new int[] {changeMax});
allChanges.stream().findAny().ifPresent(
compacted -> {
String commit = compacted.commitFullVersion();
if (!Strings.isNullOrEmpty(commit)) {
status.finishedSuiteCommit
= commit.substring(0, PullRequest.INCLUDE_SHORT_VER).toLowerCase();
}
}
);
}
}
else {
status.branchWithFinishedSuite = null;
status.finishedSuiteCommit = null;
status.suiteIsFinished = false;
}

@@ -142,4 +142,11 @@ public String tcUserFullName(IStringCompactor compactor) {
@Override public int hashCode() {
return Objects.hashCode(_ver, id, vcsUsername, tcUserId, tcUserUsername, tcUserFullname, version, date);
}

/**
*
*/
public String commitFullVersion() {
return DatatypeConverter.printHexBinary(version);
}
}
@@ -47,7 +47,7 @@
import java.util.stream.Stream;

/**
*
* Composed data from {@link Build} and other classes, compressed for storage.
*/
@Persisted
public class FatBuildCompacted extends BuildRefCompacted implements IVersionedEntity {
@@ -404,8 +404,15 @@ function showContributionStatus(status, prId, row, srvId, suiteIdSelected) {
if (buildIsCompleted) {
let finishedBranch = status.branchWithFinishedSuite;

tdForPr.html("<a id='showReportlink_" + prId + "' href='" + prShowHref(srvId, suiteIdSelected, finishedBranch) + "'>" +
"<button id='show_" + prId + "'>Show " + finishedBranch + " report</button></a>");
let reportLink = "<a id='showReportlink_" + prId + "' href='" + prShowHref(srvId, suiteIdSelected, finishedBranch) + "'>" +
"<button id='show_" + prId + "'>Show " + finishedBranch + " report</button>" +
"</a>";
if(isDefinedAndFilled(status.finishedSuiteCommit)) {
reportLink += "<br>(" + status.finishedSuiteCommit + ")";
}


tdForPr.html(reportLink);

if (hasJiraIssue) {
let jiraBtn = "<button onclick='" +

0 comments on commit 3e12562

Please sign in to comment.