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

Better tracking when candidates for PR assignment are filtered out #1895

Merged
Merged
Changes from 2 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
34 changes: 27 additions & 7 deletions src/handlers/assign.rs
Original file line number Diff line number Diff line change
@@ -70,7 +70,9 @@ Use `r?` to explicitly pick a reviewer";
const RETURNING_USER_WELCOME_MESSAGE_NO_REVIEWER: &str =
"@{author}: no appropriate reviewer found, use `r?` to override";

const ON_VACATION_WARNING: &str = "{username} is on vacation. Please do not assign them to PRs.";
const ON_VACATION_WARNING: &str = "{username} is on vacation.

Please choose another assignee.";

const NON_DEFAULT_BRANCH: &str =
"Pull requests are usually filed against the {default} branch for this repo, \
@@ -508,7 +510,10 @@ pub(super) async fn handle_command(
{
// This is a comment, so there must already be a reviewer assigned. No need to assign anyone else.
issue
.post_comment(&ctx.github, &on_vacation_msg(&username))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the deletion of on_vacation_msg is in 82c549a (sorry)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the functions better than the consts, because with the function you cannot forget to pass the required placeholders, with the static string you can easily just use it without replacing the placeholder.

.post_comment(
&ctx.github,
&ON_VACATION_WARNING.replace("{username}", &username),
)
.await?;
return Ok(());
}
@@ -544,8 +549,9 @@ pub(super) async fn handle_command(
let work_queue = has_user_capacity(&db_client, &name).await;
if work_queue.is_err() {
// NOTE: disabled for now, just log
log::info!(
"DB reported that user {} has no review capacity. Ignoring.",
log::warn!(
"[#{}] PR self-assign failed, DB reported that user {} has no review capacity. Ignoring.",
issue.number,
name
);
// issue
@@ -785,7 +791,11 @@ async fn find_reviewer_from_names(
// These are all ideas for improving the selection here. However, I'm not
// sure they are really worth the effort.

log::info!("Initial unfiltered list of candidates: {:?}", candidates);
log::info!(
"[#{}] Initial unfiltered list of candidates: {:?}",
issue.number,
candidates
);

// Special case user "ghost", we always skip filtering
if candidates.contains("ghost") {
@@ -799,14 +809,18 @@ async fn find_reviewer_from_names(

if filtered_candidates.is_empty() {
// NOTE: disabled for now, just log
log::info!("Filtered list of PR assignee is empty");
log::info!("[#{}] Filtered list of PR assignee is empty", issue.number);
// return Err(FindReviewerError::AllReviewersFiltered {
// initial: names.to_vec(),
// filtered: names.to_vec(),
// });
}

log::info!("Filtered list of candidates: {:?}", filtered_candidates);
log::info!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should really migrate to tracing and use spans to get have proper log context :)

"[#{}] Filtered list of candidates: {:?}",
issue.number,
filtered_candidates
);

// Return unfiltered list of candidates
Ok(candidates
@@ -934,6 +948,12 @@ fn candidate_reviewers_from_names<'a>(
if filtered.is_empty() {
Err(FindReviewerError::NoReviewer { initial })
} else {
log::warn!(
"[#{}] Initial list of candidates {:?}, filtered-out with reasons: {:?}",
issue.number,
initial,
filtered_debug
);
Err(FindReviewerError::AllReviewersFiltered { initial, filtered })
}
} else {
5 changes: 3 additions & 2 deletions src/handlers/pr_tracking.rs
Original file line number Diff line number Diff line change
@@ -85,8 +85,9 @@ pub(super) async fn handle_input<'a>(
// if user has no capacity, revert the PR assignment (GitHub has already assigned it)
// and post a comment suggesting what to do
if let Err(_) = work_queue {
log::info!(
"DB reported that user {} has no review capacity. Ignoring.",
log::warn!(
"[#{}] DB reported that user {} has no review capacity. Ignoring.",
event.issue.number,
&assignee.login
);