Revert "[mergebot] Add all-green option (#77660)"

This reverts commit 340c4120d58bbe6031e20b34459fb60cbe87a7c3.

Reverted https://github.com/pytorch/pytorch/pull/77660 on behalf of https://github.com/malfet due to as it broke lint, see https://github.com/pytorch/pytorch/runs/6532480582?check_suite_focus=true
This commit is contained in:
PyTorch MergeBot
2022-05-20 23:01:31 +00:00
parent 340c4120d5
commit c7e8de6e86

View File

@ -384,7 +384,6 @@ def parse_args() -> Any:
parser = ArgumentParser("Merge PR into default branch")
parser.add_argument("--dry-run", action="store_true")
parser.add_argument("--on-green", action="store_true")
parser.add_argument("--all-green", action="store_true")
parser.add_argument("--revert", action="store_true")
parser.add_argument("--force", action="store_true")
parser.add_argument("--comment-id", type=int)
@ -888,7 +887,7 @@ def prefix_with_github_url(suffix_str: str) -> str:
return f"https://github.com/{suffix_str}"
def merge_on_green(pr_num: int, repo: GitRepo, dry_run: bool = False, timeout_minutes: int = 400, all_green: 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())
org, project = repo.gh_owner_and_name()
start_time = time.time()
@ -898,25 +897,10 @@ def merge_on_green(pr_num: int, repo: GitRepo, dry_run: bool = False, timeout_mi
current_time = time.time()
elapsed_time = current_time - start_time
pr = GitHubPR(org, project, pr_num)
try:
if all_green:
checks = pr.get_checkrun_conclusions()
pending_checks = []
failed_checks = []
for check in checks:
if checks[check] is None:
pending_checks.append(check)
elif checks[check] != 'SUCCESS':
failed_checks.append(check)
if len(failed_checks) > 0:
raise RuntimeError(f"Failed to merge due to failing checks, {','.join(failed_checks)}")
if len(pending_checks) > 0:
reject_reason = f"Refusing to merge as mandatory check(s) {','.join(pending_checks)} are missing"
raise MandatoryChecksMissingError(reject_reason)
pr.merge_into(repo, dry_run=dry_run)
else:
pr.merge_into(repo, dry_run=dry_run)
return pr.merge_into(repo, dry_run=dry_run)
except MandatoryChecksMissingError as ex:
last_exception = str(ex)
print(f"Merged failed due to: {ex}. Retrying in 60 seconds.")
@ -958,9 +942,9 @@ def main() -> None:
gh_post_comment(org, project, args.pr_num, "Cross-repo ghstack merges are not supported", dry_run=args.dry_run)
return
if args.on_green or args._all_green:
if args.on_green:
try:
merge_on_green(args.pr_num, repo, dry_run=args.dry_run, all_green=args.all_green)
merge_on_green(args.pr_num, repo, dry_run=args.dry_run)
except Exception as e:
handle_exception(e)
else: