mirror of
https://github.com/pytorch/pytorch.git
synced 2025-11-11 22:34:53 +08:00
[GHF] More verbose failures messages (#71941)
Summary:
Modify _check_output to capture `CalledProcessError` and add
stdout/stderr to the failure message
Also record github actions run id in the failure message (calculated based on `${{ github.run_id}}`)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/71941
Reviewed By: seemethere
Differential Revision: D33829633
Pulled By: malfet
fbshipit-source-id: 060b2856ca6c71574075effa72b982f9e1d64e6e
(cherry picked from commit a9ad7df9b540f9ab14524a644cab5e06225debe4)
This commit is contained in:
committed by
PyTorch MergeBot
parent
c85965600c
commit
3b9f2e2cca
14
.github/scripts/gitutils.py
vendored
14
.github/scripts/gitutils.py
vendored
@ -30,8 +30,18 @@ def fuzzy_list_to_dict(items: List[Tuple[str, str]]) -> Dict[str, List[str]]:
|
||||
|
||||
|
||||
def _check_output(items: List[str], encoding: str = "utf-8") -> str:
|
||||
from subprocess import check_output
|
||||
return check_output(items).decode(encoding)
|
||||
from subprocess import check_output, CalledProcessError
|
||||
try:
|
||||
return check_output(items).decode(encoding)
|
||||
except CalledProcessError as e:
|
||||
msg = f"Command `{' '.join(e.cmd)}` returned non-zero exit code {e.returncode}"
|
||||
stdout = e.stdout.decode(encoding) if e.stdout is not None else ""
|
||||
stderr = e.stderr.decode(encoding) if e.stderr is not None else ""
|
||||
if len(stderr) == 0:
|
||||
msg += f"\n{stdout}"
|
||||
else:
|
||||
msg += f"\nstdout:\n{stdout}\nstderr:\n{stderr}"
|
||||
raise RuntimeError(msg) from e
|
||||
|
||||
|
||||
class GitCommit:
|
||||
|
||||
12
.github/scripts/trymerge.py
vendored
12
.github/scripts/trymerge.py
vendored
@ -411,7 +411,11 @@ def main() -> None:
|
||||
try:
|
||||
try_revert(repo, pr, dry_run=args.dry_run)
|
||||
except Exception as e:
|
||||
gh_post_comment(org, project, args.pr_num, f"Reverting PR {args.pr_num} failed due to {e}", dry_run=args.dry_run)
|
||||
msg = f"Reverting PR {args.pr_num} failed due to {e}"
|
||||
run_url = os.getenv("GH_RUN_URL")
|
||||
if run_url is not None:
|
||||
msg += f"\nRaised by {run_url}"
|
||||
gh_post_comment(org, project, args.pr_num, msg, dry_run=args.dry_run)
|
||||
return
|
||||
|
||||
if pr.is_closed():
|
||||
@ -425,7 +429,11 @@ def main() -> None:
|
||||
try:
|
||||
pr.merge_into(repo, dry_run=args.dry_run)
|
||||
except Exception as e:
|
||||
gh_post_comment(org, project, args.pr_num, f"Merge failed due to {e}", dry_run=args.dry_run)
|
||||
msg = f"Merge failed due to {e}"
|
||||
run_url = os.getenv("GH_RUN_URL")
|
||||
if run_url is not None:
|
||||
msg += f"\nRaised by {run_url}"
|
||||
gh_post_comment(org, project, args.pr_num, msg, dry_run=args.dry_run)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
1
.github/workflows/revert.yml
vendored
1
.github/workflows/revert.yml
vendored
@ -27,5 +27,6 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.MERGEBOT_TOKEN }}
|
||||
PR_NUM: ${{ github.event.client_payload.pr_num }}
|
||||
GH_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
run: |
|
||||
python3 .github/scripts/trymerge.py --revert "${PR_NUM}"
|
||||
|
||||
1
.github/workflows/trymerge.yml
vendored
1
.github/workflows/trymerge.yml
vendored
@ -27,5 +27,6 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.MERGEBOT_TOKEN }}
|
||||
PR_NUM: ${{ github.event.client_payload.pr_num }}
|
||||
GH_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
run: |
|
||||
python3 .github/scripts/trymerge.py "${PR_NUM}"
|
||||
|
||||
Reference in New Issue
Block a user