mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 13:44:15 +08:00
Delete old branches (#117079)
Example https://github.com/pytorch/pytorch/actions/runs/7562281351/job/20592425611?pr=117079 (The code to delete branches isn't being run, it's just listing the branches it wants to delete) Internal code: https://fburl.com/code/hdvvbfkj Threshold for branch with PR is 30 days regardless of whether or not the PR is merged or not (compared to 3 days if merged and 30 days if closed). Threshold for branch without PR is 1.5 years (same internally). Threshold of ~400 queries to github so it doesn't hit token usage limits. Currently this leads to about 350 branches deleted per run. Only query for the last 90 days of updated PRs to reduce token usage, so if a branch has a PR but it was updated 90+ days ago, it will think it doesn't have a PR and will wait for the 1.5 years branch update check instead, regardless of whether the PR is open or closed. I tested that it could delete my own branch and it worked. labeled with test-config/crossref because I just want the smallest test config possible to reduce CI usage Pull Request resolved: https://github.com/pytorch/pytorch/pull/117079 Approved by: https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
b816760a2f
commit
200108c6e6
13
.github/scripts/github_utils.py
vendored
13
.github/scripts/github_utils.py
vendored
@ -119,6 +119,19 @@ def gh_fetch_json_dict(
|
||||
return cast(Dict[str, Any], _gh_fetch_json_any(url, params, data))
|
||||
|
||||
|
||||
def gh_graphql(query: str, **kwargs: Any) -> Dict[str, Any]:
|
||||
rc = gh_fetch_url(
|
||||
"https://api.github.com/graphql",
|
||||
data={"query": query, "variables": kwargs},
|
||||
reader=json.load,
|
||||
)
|
||||
if "errors" in rc:
|
||||
raise RuntimeError(
|
||||
f"GraphQL query {query}, args {kwargs} failed: {rc['errors']}"
|
||||
)
|
||||
return cast(Dict[str, Any], rc)
|
||||
|
||||
|
||||
def _gh_post_comment(
|
||||
url: str, comment: str, dry_run: bool = False
|
||||
) -> List[Dict[str, Any]]:
|
||||
|
Reference in New Issue
Block a user