-
Notifications
You must be signed in to change notification settings - Fork 630
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
Implementing Thresholds for Incremental PR Reviews #423
Merged
mrT23
merged 4 commits into
Codium-ai:main
from
zmeir:zmeir-external-incremental_review_thresholds
Nov 6, 2023
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c623c3b
Added new configurations to prevent too frequent incremental commits …
zmeir 92071fc
Stack all incremental parameters
zmeir 8e3fa39
Extract incremental review checks to separate method
zmeir b286c8e
Added documentation for the new configurations
zmeir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import copy | ||
import datetime | ||
from collections import OrderedDict | ||
from typing import List, Tuple | ||
|
||
|
@@ -100,9 +101,33 @@ async def run(self) -> None: | |
if self.is_auto and not get_settings().pr_reviewer.automatic_review: | ||
get_logger().info(f'Automatic review is disabled {self.pr_url}') | ||
return None | ||
if self.is_auto and self.incremental.is_incremental and not self.incremental.first_new_commit_sha: | ||
get_logger().info(f"Incremental review is enabled for {self.pr_url} but there are no new commits") | ||
return None | ||
if self.incremental.is_incremental: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zmeir please move all of this to a dedicated, self-contained function. this is too much content to appear directly |
||
if self.is_auto and not self.incremental.first_new_commit_sha: | ||
get_logger().info(f"Incremental review is enabled for {self.pr_url} but there are no new commits") | ||
return None | ||
# checking if there are enough commits to start the review | ||
num_new_commits = len(self.incremental.commits_range) | ||
num_commits_threshold = get_settings().pr_reviewer.minimal_commits_for_incremental_review | ||
not_enough_commits = num_new_commits < num_commits_threshold | ||
# checking if the commits are not too recent to start the review | ||
recent_commits_threshold = datetime.datetime.now() - datetime.timedelta( | ||
minutes=get_settings().pr_reviewer.minimal_minutes_for_incremental_review | ||
) | ||
last_seen_commit_date = ( | ||
self.incremental.last_seen_commit.commit.author.date if self.incremental.last_seen_commit else None | ||
) | ||
all_commits_too_recent = ( | ||
last_seen_commit_date > recent_commits_threshold if self.incremental.last_seen_commit else False | ||
) | ||
# check all the thresholds or just one to start the review | ||
condition = any if get_settings().pr_reviewer.require_all_thresholds_for_incremental_review else all | ||
if condition((not_enough_commits, all_commits_too_recent)): | ||
get_logger().info( | ||
f"Incremental review is enabled for {self.pr_url} but didn't pass the threshold check to run:" | ||
f"\n* Number of new commits = {num_new_commits} (threshold is {num_commits_threshold})" | ||
f"\n* Last seen commit date = {last_seen_commit_date} (threshold is {recent_commits_threshold})" | ||
) | ||
return None | ||
|
||
get_logger().info(f'Reviewing PR: {self.pr_url} ...') | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you stack all the 'incremental' parameters ?
i don't want the config to be just a long incoherent list
something like
/# incremental parameters:
minimal_commits_for_incremental_review=0
minimal_minutes_for_incremental_review=0
...