diff --git a/scripts/ci/pr-bot/findPrsNeedingAttention.ts b/scripts/ci/pr-bot/findPrsNeedingAttention.ts index 621e89b2d87d..095be5ba762f 100644 --- a/scripts/ci/pr-bot/findPrsNeedingAttention.ts +++ b/scripts/ci/pr-bot/findPrsNeedingAttention.ts @@ -114,13 +114,16 @@ async function assignToNewReviewers( reviewersToExclude.push(pull.user.login); const reviewersForLabels: { [key: string]: string[] } = reviewerConfig.getReviewersForLabels(labelObjects, reviewersToExclude); + const fallbackReviewers = + reviewerConfig.getFallbackReviewers(); for (const labelObject of labelObjects) { const label = labelObject.name; let availableReviewers = reviewersForLabels[label]; if (availableReviewers && availableReviewers.length > 0) { let reviewersState = await stateClient.getReviewersForLabelState(label); let chosenReviewer = await reviewersState.assignNextCommitter( - availableReviewers + availableReviewers, + fallbackReviewers ); reviewerStateToUpdate[label] = reviewersState; prState.reviewersAssignedForLabels[label] = chosenReviewer; diff --git a/scripts/ci/pr-bot/processNewPrs.ts b/scripts/ci/pr-bot/processNewPrs.ts index db723e5623fa..5aa89e9cce4c 100644 --- a/scripts/ci/pr-bot/processNewPrs.ts +++ b/scripts/ci/pr-bot/processNewPrs.ts @@ -217,8 +217,11 @@ async function processPull( ); const availableReviewers = reviewerConfig.getReviewersForLabel(labelOfReviewer); + const fallbackReviewers = + reviewerConfig.getFallbackReviewers(); const chosenCommitter = await reviewersState.assignNextCommitter( - availableReviewers + availableReviewers, + fallbackReviewers ); prState.reviewersAssignedForLabels[labelOfReviewer] = chosenCommitter; prState.committerAssigned = true; diff --git a/scripts/ci/pr-bot/shared/reviewersForLabel.ts b/scripts/ci/pr-bot/shared/reviewersForLabel.ts index 971f3f1cd7a5..f46f5359a8b9 100644 --- a/scripts/ci/pr-bot/shared/reviewersForLabel.ts +++ b/scripts/ci/pr-bot/shared/reviewersForLabel.ts @@ -75,7 +75,10 @@ export class ReviewersForLabel { // Given the up to date list of available reviewers (excluding the author), // returns the next reviewer up based on who has reviewed least recently. // Updates this object to reflect their assignment. - async assignNextCommitter(availableReviewers: string[]): Promise { + async assignNextCommitter( + availableReviewers: string[], + fallbackReviewers: string[] + ): Promise { let earliestDate = Date.now(); let earliestCommitter: string = ""; @@ -94,7 +97,9 @@ export class ReviewersForLabel { } if (!earliestCommitter) { - throw new Error(`No committers available for label ${this.label}`); + console.log(`No committers available for label ${this.label}`); + console.log(`Using fallbackReviewers label instead of ${this.label}`); + return this.assignNextCommitter(fallbackReviewers, fallbackReviewers); } this.dateOfLastReviewAssignment[earliestCommitter] = Date.now(); return earliestCommitter;