mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
add check for ci sev (#79745)
block merge when theres an open issue with ci sev label + "merge blocking" in the body tested on https://github.com/pytorch/pytorch-canary/pull/108 Pull Request resolved: https://github.com/pytorch/pytorch/pull/79745 Approved by: https://github.com/seemethere
This commit is contained in:
committed by
PyTorch MergeBot
parent
f6d9a9a952
commit
5b44ba834f
26
.github/scripts/trymerge.py
vendored
26
.github/scripts/trymerge.py
vendored
@ -5,6 +5,7 @@ import json
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import urllib.parse
|
||||
from datetime import datetime
|
||||
from dataclasses import dataclass
|
||||
from urllib.request import urlopen, Request
|
||||
@ -337,7 +338,7 @@ def fetch_json(url: str,
|
||||
data: Optional[Dict[str, Any]] = None) -> List[Dict[str, Any]]:
|
||||
headers = {'Accept': 'application/vnd.github.v3+json'}
|
||||
if params is not None and len(params) > 0:
|
||||
url += '?' + '&'.join(f"{name}={val}" for name, val in params.items())
|
||||
url += '?' + '&'.join(f"{name}={urllib.parse.quote(str(val))}" for name, val in params.items())
|
||||
return cast(List[Dict[str, Any]], _fetch_url(url, headers=headers, data=data, reader=json.load))
|
||||
|
||||
|
||||
@ -917,6 +918,27 @@ def prefix_with_github_url(suffix_str: str) -> str:
|
||||
return f"https://github.com/{suffix_str}"
|
||||
|
||||
|
||||
def check_for_sev(org: str, project: str, force: bool) -> None:
|
||||
if force:
|
||||
return
|
||||
response = cast(
|
||||
Dict[str, Any],
|
||||
fetch_json(
|
||||
"https://api.github.com/search/issues",
|
||||
params={"q": f'repo:{org}/{project} is:open is:issue label:"ci: sev"'},
|
||||
),
|
||||
)
|
||||
if response["total_count"] != 0:
|
||||
for item in response["items"]:
|
||||
if "merge blocking" in item["body"].lower():
|
||||
raise RuntimeError(
|
||||
"Not merging any PRs at the moment because there is a "
|
||||
+ "merge blocking https://github.com/pytorch/pytorch/labels/ci:%20sev issue open at: \n"
|
||||
+ f"{item['html_url']}"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
def merge(pr_num: int, repo: GitRepo,
|
||||
dry_run: bool = False,
|
||||
force: bool = False,
|
||||
@ -929,6 +951,7 @@ def merge(pr_num: int, repo: GitRepo,
|
||||
org, project = repo.gh_owner_and_name()
|
||||
pr = GitHubPR(org, project, pr_num)
|
||||
initial_commit_sha = pr.last_commit()['oid']
|
||||
check_for_sev(org, project, force)
|
||||
if force or can_skip_internal_checks(pr, comment_id):
|
||||
# do not wait for any pending signals if PR is closed as part of co-development process
|
||||
return pr.merge_into(repo, dry_run=dry_run, force=force, comment_id=comment_id)
|
||||
@ -939,6 +962,7 @@ def merge(pr_num: int, repo: GitRepo,
|
||||
last_exception = ''
|
||||
elapsed_time = 0.0
|
||||
while elapsed_time < timeout_minutes * 60:
|
||||
check_for_sev(org, project, force)
|
||||
current_time = time.time()
|
||||
elapsed_time = current_time - start_time
|
||||
print(f"Attempting merge of https://github.com/{org}/{project}/pull/{pr_num} ({elapsed_time / 60} minutes elapsed)")
|
||||
|
Reference in New Issue
Block a user