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

Update CI expected review count to 2 #14659

Closed
wants to merge 2 commits into from
Closed
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
23 changes: 14 additions & 9 deletions ci/ci/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,19 @@ async def _update_last_known_github_status(self, gh):
self.last_known_github_status = last_known_github_status
self.target_branch.state_changed = True

@staticmethod
def _overall_review_status_from_latest_state_by_login(latest_state_by_login):
active_states = [
state for state in latest_state_by_login.values() if state in ('APPROVED', 'CHANGES_REQUESTED')
]

if any(state == 'CHANGES_REQUESTED' for state in latest_state_by_login.values()):
return 'changes_requested'
elif len(active_states) < 2:
return 'pending'
else:
return 'approved'

async def _update_github_review_state(self, gh):
latest_state_by_login = {}
async for review in gh.getiter(
Expand All @@ -496,15 +509,7 @@ async def _update_github_review_state(self, gh):
if state != 'COMMENTED':
latest_state_by_login[login] = state

review_state = 'pending'
for login, state in latest_state_by_login.items():
if state == 'CHANGES_REQUESTED':
review_state = 'changes_requested'
break
if state == 'APPROVED':
review_state = 'approved'
else:
assert state in ('DISMISSED', 'COMMENTED', 'PENDING'), state
review_state = PR._overall_review_status_from_latest_state_by_login(latest_state_by_login)

if review_state != self.review_state:
self.set_review_state(review_state)
Expand Down
Loading