mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
[mergebot cli] add new revert regex (#77459)
Since we added a new CLI, we have to update the regex validator for reverting. The same validation is not there for merging. The example command we want to validate: `@pytorchbot merge -c="ghfirst" -m="this is breaking things internally"` Pull Request resolved: https://github.com/pytorch/pytorch/pull/77459 Approved by: https://github.com/malfet, https://github.com/janeyx99
This commit is contained in:
committed by
PyTorch MergeBot
parent
d76efed578
commit
906fc77745
9
.github/scripts/trymerge.py
vendored
9
.github/scripts/trymerge.py
vendored
@ -301,6 +301,7 @@ RE_PULL_REQUEST_RESOLVED = re.compile(
|
|||||||
re.MULTILINE
|
re.MULTILINE
|
||||||
)
|
)
|
||||||
RE_REVERT_CMD = re.compile(r"@pytorch(merge|)bot\s+revert\s+this")
|
RE_REVERT_CMD = re.compile(r"@pytorch(merge|)bot\s+revert\s+this")
|
||||||
|
RE_REVERT_CMD_CLI = re.compile(r"@pytorch(merge|)bot\s+revert\s+(-m.*-c.*|-c.*-m.*)")
|
||||||
RE_DIFF_REV = re.compile(r'^Differential Revision:.+?(D[0-9]+)', re.MULTILINE)
|
RE_DIFF_REV = re.compile(r'^Differential Revision:.+?(D[0-9]+)', re.MULTILINE)
|
||||||
|
|
||||||
|
|
||||||
@ -819,7 +820,7 @@ def try_revert(repo: GitRepo, pr: GitHubPR, *, dry_run: bool = False, comment_id
|
|||||||
if not pr.is_closed():
|
if not pr.is_closed():
|
||||||
return post_comment(f"Can't revert open PR #{pr.pr_num}")
|
return post_comment(f"Can't revert open PR #{pr.pr_num}")
|
||||||
comment = pr.get_last_comment() if comment_id is None else pr.get_comment_by_id(comment_id)
|
comment = pr.get_last_comment() if comment_id is None else pr.get_comment_by_id(comment_id)
|
||||||
if not RE_REVERT_CMD.match(comment.body_text):
|
if not RE_REVERT_CMD.match(comment.body_text) and not RE_REVERT_CMD_CLI.match(comment.body_text):
|
||||||
raise RuntimeError(f"Comment {comment.body_text} does not seem to be a valid revert command")
|
raise RuntimeError(f"Comment {comment.body_text} does not seem to be a valid revert command")
|
||||||
if comment.editor_login is not None:
|
if comment.editor_login is not None:
|
||||||
return post_comment("Don't want to revert based on edited command")
|
return post_comment("Don't want to revert based on edited command")
|
||||||
@ -858,13 +859,13 @@ def prefix_with_github_url(suffix_str: str) -> str:
|
|||||||
return f"https://github.com/{suffix_str}"
|
return f"https://github.com/{suffix_str}"
|
||||||
|
|
||||||
|
|
||||||
def merge_on_green(pr_num: int, repo: GitRepo, dry_run: bool = False) -> None:
|
def merge_on_green(pr_num: int, repo: GitRepo, dry_run: bool = False, timeout_minutes: int = 400) -> None:
|
||||||
repo = GitRepo(get_git_repo_dir(), get_git_remote_name())
|
repo = GitRepo(get_git_repo_dir(), get_git_remote_name())
|
||||||
org, project = repo.gh_owner_and_name()
|
org, project = repo.gh_owner_and_name()
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
last_exception = ''
|
last_exception = ''
|
||||||
elapsed_time = 0.0
|
elapsed_time = 0.0
|
||||||
while elapsed_time < 400 * 60:
|
while elapsed_time < timeout_minutes * 60:
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
elapsed_time = current_time - start_time
|
elapsed_time = current_time - start_time
|
||||||
|
|
||||||
@ -877,7 +878,7 @@ def merge_on_green(pr_num: int, repo: GitRepo, dry_run: bool = False) -> None:
|
|||||||
print(f"Merged failed due to: {ex}. Retrying in 60 seconds.")
|
print(f"Merged failed due to: {ex}. Retrying in 60 seconds.")
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
# Finally report timeout back
|
# Finally report timeout back
|
||||||
msg = "Merged timed out after 6 hours. Please contact the pytorch_dev_infra team."
|
msg = f"Merged timed out after {timeout_minutes} minutes. Please contact the pytorch_dev_infra team."
|
||||||
msg += f"The last exception was: {last_exception}"
|
msg += f"The last exception was: {last_exception}"
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
gh_add_labels(org, project, pr_num, ["land-failed"])
|
gh_add_labels(org, project, pr_num, ["land-failed"])
|
||||||
|
Reference in New Issue
Block a user