diff --git a/etc/ci/report_aggregated_expected_results.py b/etc/ci/report_aggregated_expected_results.py index ac93951ca6e..fbfe763d74c 100755 --- a/etc/ci/report_aggregated_expected_results.py +++ b/etc/ci/report_aggregated_expected_results.py @@ -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)