Skip to content

2479: PR marked as ready with jcheck error #1714

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

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ private void checkStatus() {
var commitMessage = String.join("\n", commit.message());

var readyToPostApprovalNeededComment = readyForReview &&
(!reviewNeeded || visitor.errorFailedChecksMessages().isEmpty()) &&
!visitor.hasErrors(reviewNeeded) &&
integrationBlockers.isEmpty() &&
!statusMessage.contains(TEMPORARY_ISSUE_FAILURE_MARKER);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ List<String> errorFailedChecksMessages() {
return errorFailedChecks.values().stream().flatMap(List::stream).toList();
}


boolean hasErrors(boolean reviewNeeded) {
if (reviewNeeded) {
return !errorFailedChecks.isEmpty();
} else {
return errorFailedChecks.keySet().stream()
.anyMatch(check -> !check.equals(ReviewersCheck.class));
}
}

List<String> warningFailedChecksMessages() {
return warningFailedChecks.values().stream().flatMap(List::stream).toList();
}
Expand Down
72 changes: 72 additions & 0 deletions bots/pr/src/test/java/org/openjdk/skara/bots/pr/BackportTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2163,4 +2163,76 @@ void incompleteBackport(TestInfo testInfo) throws IOException {
assertFalse(pr.store().labelNames().contains("clean"));
}
}

@Test
void cleanBackportWithProblemListIssue(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo);
var tempFolder = new TemporaryDirectory(false)) {

var author = credentials.getHostedRepository();
var integrator = credentials.getHostedRepository();
var reviewer = credentials.getHostedRepository();
var issues = credentials.getIssueProject();
var censusBuilder = credentials.getCensusBuilder()
.addCommitter(author.forge().currentUser().id())
.addReviewer(integrator.forge().currentUser().id())
.addReviewer(reviewer.forge().currentUser().id());
var bot = PullRequestBot.newBuilder()
.repo(integrator)
.censusRepo(censusBuilder.build())
.issueProject(issues)
.issuePRMap(new HashMap<>())
.build();

// Populate the projects repository
var localRepo = CheckableRepository.init(tempFolder.path(), author.repositoryType(),
Path.of("appendable.txt"), Set.of("author", "reviewers", "whitespace", "problemlists"), "0.1");

// Add problemlists configuration to conf
var checkConf = tempFolder.path().resolve(".jcheck/conf");
Files.writeString(checkConf, "\n[checks \"problemlists\"]\n", StandardOpenOption.APPEND);
Files.writeString(checkConf, "dirs=test/jdk\n", StandardOpenOption.APPEND);
// Create ProblemList.txt
Files.createDirectories(tempFolder.path().resolve("test/jdk"));
var problemList = tempFolder.path().resolve("test/jdk/ProblemList.txt");
Files.writeString(problemList, "test 1 windows-all", StandardOpenOption.CREATE);
localRepo.add(tempFolder.path().resolve(".jcheck/conf"));
localRepo.add(problemList);
localRepo.commit("add problemList.txt", "testauthor", "[email protected]");

var masterHash = localRepo.resolve("master").orElseThrow();
localRepo.push(masterHash, author.authenticatedUrl(), "master", true);

var releaseBranch = localRepo.branch(masterHash, "release");
localRepo.checkout(releaseBranch);
var newFile = localRepo.root().resolve("a_new_file.txt");
Files.writeString(newFile, "hello");
localRepo.add(newFile);
var issue1 = credentials.createIssue(issues, "An issue");
var issue1Number = issue1.id().split("-")[1];
var originalMessage = issue1Number + ": An issue\n" +
"\n" +
"Reviewed-by: integrationreviewer2";
var releaseHash = localRepo.commit(originalMessage, "integrationcommitter1", "[email protected]");
localRepo.push(releaseHash, author.authenticatedUrl(), "refs/heads/release", true);

// "backport" the new file to the master branch
localRepo.checkout(localRepo.defaultBranch());
var editBranch = localRepo.branch(masterHash, "edit");
localRepo.checkout(editBranch);
var newFile2 = localRepo.root().resolve("a_new_file.txt");
Files.writeString(newFile2, "hello");
localRepo.add(newFile2);
var editHash = localRepo.commit("Backport", "duke", "[email protected]");
localRepo.push(editHash, author.authenticatedUrl(), "refs/heads/edit", true);
var pr = credentials.createPullRequest(author, "master", "edit", "Backport " + releaseHash.hex(), List.of());

// The bot should reply with a backport message
TestBotRunner.runPeriodicItems(bot);
// Should be marked as ready for review
assertTrue(pr.store().labelNames().contains("rfr"));
// Shouldn't be marked as ready
assertFalse(pr.store().labelNames().contains("ready"));
}
}
}