feat: update joj3 issue format

This commit is contained in:
张泊明518370910136 2024-09-30 05:59:43 -04:00
parent b128625bce
commit cc9cb3224c
GPG Key ID: CA088E6D9284F870
2 changed files with 10 additions and 9 deletions

View File

@ -325,7 +325,9 @@ def joj3_create_result_issue(
+ f"{settings.gitea_org_name}/{submitter_repo_name}/"
+ f"actions/runs/{run_number}"
)
title, comment = joj3.generate_title_and_comment(score_file_path, action_link)
title, comment = joj3.generate_title_and_comment(
score_file_path, action_link, run_number
)
tea.pot.gitea.create_issue(submitter_repo_name, title, comment, False)

View File

@ -166,23 +166,22 @@ def generate_failed_table(
def generate_title_and_comment(
score_file_path: str, action_link: str
score_file_path: str, action_link: str, run_number: str
) -> Tuple[str, str]:
with open(score_file_path) as json_file:
stages: List[Dict[str, Any]] = json.load(json_file)
total_score = 0
comment = f"Generated by [Gitea Actions]({action_link})\n"
comment = f"Generated by [Gitea Actions #{run_number}]({action_link})\n"
for stage in stages:
comment += f"## {stage['name']}\n"
comment += f"## {stage['name']}"
single_case = len(stage["results"]) == 1
for i, result in enumerate(stage["results"]):
comment += "### "
if not single_case:
comment += f"Case {i} - Score: {result['score']}"
else:
comment += f"Score: {result['score']}"
if single_case:
comment += f" - Score: {stage['results'][0]['score']}"
comment += "\n"
for i, result in enumerate(stage["results"]):
if not single_case:
comment += f"### Case {i} - Score: {result['score']}\n"
if result["comment"].strip() != "":
comment += f"{result['comment']}\n"
total_score += result["score"]