mirror of
https://github.com/servo/servo.git
synced 2025-09-22 04:40:09 +01:00
Auto merge of #29712 - mrobinson:no-test-results-for-closed-prs, r=mukilan
Don't report test results for closed PRs When doing a try run, bors will often push the last closed merge onto the branch before pushing the change to try. This means that test results get reported on closed PRs. There are two issues with this: 1. Doing too much work on the bots. 2. Extra results on closed PRs. This changes fixes the second issue. Fixes #29583. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #29583 <!-- Either: --> - [x] These changes do not require tests because they fix a infrastructure issue. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
0e1d1e3189
1 changed files with 22 additions and 10 deletions
|
@ -153,6 +153,11 @@ def get_github_run_url() -> Optional[str]:
|
||||||
return f"[#{run_id}](https://github.com/{repository}/actions/runs/{run_id})"
|
return f"[#{run_id}](https://github.com/{repository}/actions/runs/{run_id})"
|
||||||
|
|
||||||
|
|
||||||
|
def is_pr_open(pr_number: str) -> bool:
|
||||||
|
return b"open" == subprocess.check_output(
|
||||||
|
["gh", "api", f"/repos/servo/servo/pulls/{pr_number}", "--template", "{{.state}}"])
|
||||||
|
|
||||||
|
|
||||||
def get_pr_number() -> Optional[str]:
|
def get_pr_number() -> Optional[str]:
|
||||||
github_context = json.loads(os.environ.get("GITHUB_CONTEXT", "{}"))
|
github_context = json.loads(os.environ.get("GITHUB_CONTEXT", "{}"))
|
||||||
if "event" not in github_context:
|
if "event" not in github_context:
|
||||||
|
@ -161,20 +166,29 @@ def get_pr_number() -> Optional[str]:
|
||||||
return None
|
return None
|
||||||
commit_title = github_context["event"]["head_commit"]["message"]
|
commit_title = github_context["event"]["head_commit"]["message"]
|
||||||
match = re.match(r"^Auto merge of #(\d+)", commit_title)
|
match = re.match(r"^Auto merge of #(\d+)", commit_title)
|
||||||
return match.group(1) if match else None
|
|
||||||
|
if not match:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Only return a PR number if the PR is open. bors will often push old merges
|
||||||
|
# onto the HEAD of try branches and we don't want to return results for these
|
||||||
|
# old PRs.
|
||||||
|
number = match.group(1)
|
||||||
|
return number if is_pr_open(number) else None
|
||||||
|
|
||||||
|
|
||||||
def create_check_run(body: str, tag: str):
|
def create_check_run(body: str, tag: str = ""):
|
||||||
|
# This process is based on the documentation here:
|
||||||
# https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-runs
|
# https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-runs
|
||||||
conclusion = 'neutral'
|
|
||||||
# get conclusion
|
|
||||||
results = json.loads(os.environ.get("RESULTS", "{}"))
|
results = json.loads(os.environ.get("RESULTS", "{}"))
|
||||||
if "cancelled" in results:
|
|
||||||
conclusion = 'cancelled'
|
|
||||||
if "failure" in results:
|
|
||||||
conclusion = 'failure'
|
|
||||||
if all(r == 'success' for r in results):
|
if all(r == 'success' for r in results):
|
||||||
conclusion = 'success'
|
conclusion = 'success'
|
||||||
|
elif "failure" in results:
|
||||||
|
conclusion = 'failure'
|
||||||
|
elif "cancelled" in results:
|
||||||
|
conclusion = 'cancelled'
|
||||||
|
else:
|
||||||
|
conclusion = 'neutral'
|
||||||
|
|
||||||
github_token = os.environ.get("GITHUB_TOKEN")
|
github_token = os.environ.get("GITHUB_TOKEN")
|
||||||
github_context = json.loads(os.environ.get("GITHUB_CONTEXT", "{}"))
|
github_context = json.loads(os.environ.get("GITHUB_CONTEXT", "{}"))
|
||||||
|
@ -193,11 +207,9 @@ def create_check_run(body: str, tag: str):
|
||||||
'output': {
|
'output': {
|
||||||
'title': f'Aggregated {tag} report',
|
'title': f'Aggregated {tag} report',
|
||||||
'summary': body,
|
'summary': body,
|
||||||
# 'text': '',
|
|
||||||
'images': [{'alt': 'WPT logo', 'image_url': 'https://avatars.githubusercontent.com/u/37226233'}]
|
'images': [{'alt': 'WPT logo', 'image_url': 'https://avatars.githubusercontent.com/u/37226233'}]
|
||||||
},
|
},
|
||||||
'actions': [
|
'actions': [
|
||||||
# {'label': 'Fix', 'identifier': 'fix_errors', 'description': 'Allow us to fix these errors for you'}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue