From 1a46b7ed0eca80ebfc81d010c534d76bda95a942 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Tue, 18 Jun 2024 07:27:46 -0400 Subject: [PATCH] ci: assignees: set multiple assignees of same area Noticing many PRs that wait too long in the queue although once of the maintainers approved with asignees set to other maintainers. This changes the current behavior of picking the first maintainer in the list and assigning to them only, instead we assign to all maintainers of the main area being changed. Who ends up driving the PR to a mergeable state is then to the maintainers and they can unassign/assign based on availability. Signed-off-by: Anas Nashif --- scripts/set_assignees.py | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/scripts/set_assignees.py b/scripts/set_assignees.py index 679735414c3..9a2994411cf 100755 --- a/scripts/set_assignees.py +++ b/scripts/set_assignees.py @@ -122,8 +122,7 @@ def process_pr(gh, maintainer_file, number): log(f"Submitted by: {pr.user.login}") log(f"candidate maintainers: {_all_maintainers}") - maintainers = list(_all_maintainers.keys()) - assignee = None + assignees = [] # we start with areas with most files changed and pick the maintainer from the first one. # if the first area is an implementation, i.e. driver or platform, we @@ -132,26 +131,14 @@ def process_pr(gh, maintainer_file, number): if count == 0: continue if len(area.maintainers) > 0: - assignee = area.maintainers[0] + assignees = area.maintainers if 'Platform' not in area.name: break - # if the submitter is the same as the maintainer, check if we have - # multiple maintainers - if len(maintainers) > 1 and pr.user.login == assignee: - log("Submitter is same as Assignee, trying to find another assignee...") - aff = list(area_counter.keys())[0] - for area in all_areas: - if area == aff: - if len(area.maintainers) > 1: - assignee = area.maintainers[1] - else: - log(f"This area has only one maintainer, keeping assignee as {assignee}") - - if assignee: - prop = (found_maintainers[assignee] / num_files) * 100 - log(f"Picked assignee: {assignee} ({prop:.2f}% ownership)") + if assignees: + prop = (found_maintainers[assignees[0]] / num_files) * 100 + log(f"Picked assignees: {assignees} ({prop:.2f}% ownership)") log("+++++++++++++++++++++++++") # Set labels @@ -217,10 +204,11 @@ def process_pr(gh, maintainer_file, number): ms = [] # assignees - if assignee and not pr.assignee: + if assignees and not pr.assignee: try: - u = gh.get_user(assignee) - ms.append(u) + for assignee in assignees: + u = gh.get_user(assignee) + ms.append(u) except GithubException: log(f"Error: Unknown user")