Print another message in Bugfix check if internal check had been failed

This commit is contained in:
vdimir 2023-12-20 17:30:07 +00:00
parent 9b54bf465f
commit a3b4b7e880
No known key found for this signature in database
GPG Key ID: 6EE4CE2BEDC51862

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
from pathlib import Path
from typing import List, Tuple
from typing import List, Tuple, Optional
import argparse
import csv
import logging
@ -32,7 +32,8 @@ def post_commit_status_from_file(file_path: Path) -> List[str]:
return res[0]
def process_result(file_path: Path) -> Tuple[bool, TestResults]:
# Returns (is_ok, test_results, error_message)
def process_result(file_path: Path) -> Tuple[bool, TestResults, Optional[str]]:
test_results = [] # type: TestResults
state, report_url, description = post_commit_status_from_file(file_path)
prefix = file_path.parent.name
@ -46,11 +47,11 @@ def process_result(file_path: Path) -> Tuple[bool, TestResults]:
if report_url != "null"
else "Check failed"
)
return False, [TestResult(f"{prefix}: {description}", status)]
return False, [TestResult(f"{prefix}: {description}", status)], "Check failed"
is_ok = state == "success"
if is_ok and report_url == "null":
return is_ok, test_results
return is_ok, test_results, None
status = (
f'OK: Bug reproduced (<a href="{report_url}">Report</a>)'
@ -58,19 +59,22 @@ def process_result(file_path: Path) -> Tuple[bool, TestResults]:
else f'Bug is not reproduced (<a href="{report_url}">Report</a>)'
)
test_results.append(TestResult(f"{prefix}: {description}", status))
return is_ok, test_results
return is_ok, test_results, None
def process_all_results(file_paths: List[Path]) -> Tuple[bool, TestResults]:
def process_all_results(
file_paths: List[Path],
) -> Tuple[bool, TestResults, Optional[str]]:
any_ok = False
all_results = []
error = None
for status_path in file_paths:
is_ok, test_results = process_result(status_path)
is_ok, test_results, error = process_result(status_path)
any_ok = any_ok or is_ok
if test_results is not None:
all_results.extend(test_results)
return any_ok, all_results
return any_ok, all_results, error
def main():
@ -80,7 +84,13 @@ def main():
check_name_with_group = "Bugfix validate check"
is_ok, test_results = process_all_results(status_files)
is_ok, test_results, error = process_all_results(status_files)
description = ""
if error:
description = error
elif not is_ok:
description = "Changed tests don't reproduce the bug"
pr_info = PRInfo()
if not test_results:
@ -88,7 +98,6 @@ def main():
report_url = ""
logging.info("No results to upload")
else:
description = "" if is_ok else "Changed tests don't reproduce the bug"
report_url = upload_results(
S3Helper(),
pr_info.number,