do WPT reports as GitHub job summery (#33587)

this is less user friendly as GitHub checks but has bigger content limits

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Samson 2024-10-02 17:24:49 +02:00 committed by GitHub
parent 56f0abeb89
commit 6d4438808a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -184,7 +184,16 @@ def get_pr_number() -> Optional[str]:
return None
def create_check_run(body: str, tag: str = ""):
def create_github_reports(body: str, tag: str = ""):
# GitHub will set a special environment variable which points to a file where
# a job summary can be appended. This is produced in addition to the GitHub
# check run below, as it has a larger length limit.
if "GITHUB_STEP_SUMMARY" in os.environ:
with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as f:
print(body, file=f)
# Create a GitHub check run. This is more user friendly than a job summary,
# but has a very limited size -- thus it may fail.
# This process is based on the documentation here:
# https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-runs
results = json.loads(os.environ.get("RESULTS", "{}"))
@ -237,16 +246,16 @@ def main():
results = get_results(filenames, args.tag)
if not results:
print("Did not find any unexpected results.")
create_check_run("Did not find any unexpected results.", args.tag)
create_github_reports("Did not find any unexpected results.", args.tag)
return
print(results.to_string())
pr_number = get_pr_number()
html_string = ElementTree.tostring(
results.to_html(), encoding="unicode")
create_check_run(html_string, args.tag)
create_github_reports(html_string, args.tag)
pr_number = get_pr_number()
if pr_number:
process = subprocess.Popen(
['gh', 'pr', 'comment', pr_number, '-F', '-'], stdin=subprocess.PIPE)