Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move testing information from the PR body to checks #962

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -124,35 +124,35 @@ static List<Check> summarize(List<Check> checks) {
var checkTitle = check.details().isPresent() ? "[" + check.name() + "](" + check.details().get() + ")" : check.name();
checkDetails.add(checkIcon + checkTitle);
}
var checkBuilder = CheckBuilder.create(platform + " - " + flavor, hash);
var checkBuilder = CheckBuilder.create("Pre-submit tests - " + platform + " - " + flavor, hash);
checkBuilder.summary(String.join("\n", checkDetails));
var firstStartedAt = flavorChecks.stream()
.map(Check::startedAt)
.min(ZonedDateTime::compareTo);
firstStartedAt.ifPresent(checkBuilder::startedAt);

var lastCompletedAt = flavorChecks.stream()
.map(Check::completedAt)
.filter(Optional::isPresent)
.map(Optional::get)
.max(ZonedDateTime::compareTo);
int total = failureCount + pendingCount + successCount;
// Report aggregate counts for successful / still running tests
if (pendingCount > 0) {
checkBuilder.title(pendingCount + "/" + total + " running");
ret.add(checkBuilder.build());
} else if (failureCount > 0) {
checkBuilder.title(failureCount + "/" + total + " failed");
lastCompletedAt.ifPresentOrElse(ca -> checkBuilder.complete(false, ca), () -> checkBuilder.complete(false));
ret.add(checkBuilder.build());
} else if (successCount > 0) {
checkBuilder.title(successCount + "/" + total + " passed");
checkBuilder.complete(true);
lastCompletedAt.ifPresentOrElse(ca -> checkBuilder.complete(true, ca), () -> checkBuilder.complete(true));
ret.add(checkBuilder.build());
}
}
}
}

var failedChecks = latestChecks.stream()
.filter(check -> check.status() == CheckStatus.FAILURE)
.sorted(Comparator.comparing(Check::name))
.collect(Collectors.toList());
for (var check : failedChecks) {
var checkBuilder = CheckBuilder.create(check.name(), hash);
checkBuilder.title("Failure");
checkBuilder.summary("A failing check run was found");
check.details().ifPresent(checkBuilder::details);
checkBuilder.complete(false);
ret.add(checkBuilder.build());
}

return ret;
}

@@ -1,7 +1,7 @@
package org.openjdk.skara.bots.testinfo;

import org.junit.jupiter.api.*;
import org.openjdk.skara.forge.CheckBuilder;
import org.openjdk.skara.forge.*;
import org.openjdk.skara.test.*;

import java.io.IOException;
@@ -10,7 +10,6 @@
import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

public class TestInfoTests {
@Test
@@ -45,6 +44,9 @@ void simple(TestInfo testInfo) throws IOException {
var check3 = CheckBuilder.create("ps3", editHash).title("PS3");
draftPr.createCheck(check3.build());
draftPr.updateCheck(check3.details(URI.create("https://www.example.com")).complete(false).build());
var check4 = CheckBuilder.create("ps4", editHash).title("PS4");
draftPr.createCheck(check4.build());
draftPr.updateCheck(check4.details(URI.create("https://www.example.com")).build());

// Now make an actual PR
localRepo.push(editHash, author.url(), "edit", true);
@@ -53,16 +55,20 @@ void simple(TestInfo testInfo) throws IOException {
// Check the status
TestBotRunner.runPeriodicItems(checkBot);

// Passing jobs are summarized
assertEquals(3, pr.checks(editHash).size());
assertEquals("1/1 passed", pr.checks(editHash).get("ps1 - Build / test").title().orElseThrow());
assertEquals("✔️ ps1", pr.checks(editHash).get("ps1 - Build / test").summary().orElseThrow());

// Failing jobs are reported individually
assertEquals("Failure", pr.checks(editHash).get("ps2").title().orElseThrow());
assertNull(pr.checks(editHash).get("ps2").details().orElse(null));
assertEquals("Failure", pr.checks(editHash).get("ps3").title().orElseThrow());
assertEquals(URI.create("https://www.example.com"), pr.checks(editHash).get("ps3").details().orElseThrow());
// Verify summarized checks
assertEquals(4, pr.checks(editHash).size());
assertEquals("1/1 passed", pr.checks(editHash).get("Pre-submit tests - ps1 - Build / test").title().orElseThrow());
assertEquals("✔️ ps1", pr.checks(editHash).get("Pre-submit tests - ps1 - Build / test").summary().orElseThrow());
assertEquals(CheckStatus.SUCCESS, pr.checks(editHash).get("Pre-submit tests - ps1 - Build / test").status());
assertEquals("1/1 failed", pr.checks(editHash).get("Pre-submit tests - ps2 - Build / test").title().orElseThrow());
assertEquals("❌ ps2", pr.checks(editHash).get("Pre-submit tests - ps2 - Build / test").summary().orElseThrow());
assertEquals(CheckStatus.FAILURE, pr.checks(editHash).get("Pre-submit tests - ps2 - Build / test").status());
assertEquals("1/1 failed", pr.checks(editHash).get("Pre-submit tests - ps3 - Build / test").title().orElseThrow());
assertEquals("❌ [ps3](https://www.example.com)", pr.checks(editHash).get("Pre-submit tests - ps3 - Build / test").summary().orElseThrow());
assertEquals(CheckStatus.FAILURE, pr.checks(editHash).get("Pre-submit tests - ps3 - Build / test").status());
assertEquals("1/1 running", pr.checks(editHash).get("Pre-submit tests - ps4 - Build / test").title().orElseThrow());
assertEquals("⏳ [ps4](https://www.example.com)", pr.checks(editHash).get("Pre-submit tests - ps4 - Build / test").summary().orElseThrow());
assertEquals(CheckStatus.IN_PROGRESS, pr.checks(editHash).get("Pre-submit tests - ps4 - Build / test").status());
}
}
}