RFR: 1118: The Skara PR bot should not block on a CSR if not enabled for a repo
Guoxiong Li
gli at openjdk.java.net
Tue Apr 26 13:28:42 UTC 2022
On Tue, 26 Apr 2022 13:20:08 GMT, Guoxiong Li <gli at openjdk.org> wrote:
> Hi all,
>
> This patch adds a config item `enable-csr` for the PullRequestbot and then the `CSRCommand` firstly checks whether the csr is enabled. If not enabled, the `CSRCommand` will reply a message about it.
>
> Thanks for taking the time to review.
>
> Best Regards,
> -- Guoxion
When solving this issue, I found the items `two-reviewers` and `24h` seem not be configurated in the JDK project. Because I had not seen the related hints in the PRs of the JDK project. The related code is shown below for convinence.
// file: PullRequestBotFactory
if (repo.value().contains("two-reviewers")) {
var labels = repo.value().get("two-reviewers")
.stream()
.map(label -> label.asString())
.collect(Collectors.toSet());
botBuilder.twoReviewersLabels(labels);
}
if (repo.value().contains("24h")) {
var labels = repo.value().get("24h")
.stream()
.map(label -> label.asString())
.collect(Collectors.toSet());
botBuilder.twentyFourHoursLabels(labels);
}
// file CheckRun
if (labels.stream().anyMatch(label -> workItem.bot.twoReviewersLabels().contains(label))) {
message.append("\n\n");
message.append(" One or more changes in this pull request modifies files in areas of ");
message.append("the source code that often require two reviewers. Please consider if this is ");
message.append("the case for this pull request, and if so, await a second reviewer to approve ");
message.append("this pull request before you integrate it.");
}
if (labels.stream().anyMatch(label -> workItem.bot.twentyFourHoursLabels().contains(label))) {
var rfrAt = pr.labelAddedAt("rfr");
if (rfrAt.isPresent() && ZonedDateTime.now().minusHours(24).isBefore(rfrAt.get())) {
message.append("\n\n");
message.append(" Applicable reviewers for one or more changes in this pull request are spread across ");
message.append("multiple different time zones. Please consider waiting with integrating this pull request until it has ");
message.append("been out for review for at least 24 hours to give all reviewers a chance to review the pull request.");
}
}
-------------
PR: https://git.openjdk.java.net/skara/pull/1308
More information about the skara-dev
mailing list