Auto merge of #29349 - mrobinson:small-improvements-to-results, r=delan

Make two small improvements to try result comment

Sort the test names alphabetically so that they are stable between try runs and also include the action URL in the comment when possible.

<!-- 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 do not require tests because they just change CI.

<!-- 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:
bors-servo 2023-02-14 21:24:47 +01:00 committed by GitHub
commit 0720f4f736
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -61,7 +61,7 @@ class Item:
def to_html(self, level: int = 0) -> ElementTree.Element:
if level == 0:
title = result = ElementTree.Element("div")
title = result = ElementTree.Element("span")
elif level == 1:
result = ElementTree.Element("details")
title = ElementTree.SubElement(result, "summary")
@ -97,6 +97,9 @@ def get_results() -> Optional[Item]:
unexpected += data["unexpected"]
known_intermittents += data["known_intermittents"]
unexpected.sort(key=lambda result: result["path"])
known_intermittents.sort(key=lambda result: result["path"])
children = []
if unexpected:
children.append(
@ -109,7 +112,24 @@ def get_results() -> Optional[Item]:
f"({len(known_intermittents)})", "",
[Item.from_result(result) for result in known_intermittents])
)
return Item("Results from try job:", "", children) if children else None
run_url = get_github_run_url()
if run_url:
text = f"Results from try job ({run_url}):"
else:
text = "Results from try job:"
return Item(text, "", children) if children else None
def get_github_run_url() -> Optional[str]:
github_context = json.loads(os.environ.get("GITHUB_CONTEXT", "{}"))
if "repository" not in github_context:
return None
if "run_id" not in github_context:
return None
repository = github_context['repository']
run_id = github_context['run_id']
return f"[#{run_id}](https://github.com/{repository}/actions/runs/{run_id})"
def get_pr_number() -> Optional[str]: