From e332c6422188b26acf192c784a22a1b991acb443 Mon Sep 17 00:00:00 2001 From: BoYanZh Date: Sat, 14 Sep 2024 21:58:53 -0400 Subject: [PATCH] feat: joj3 comment show link to actions --- joint_teapot/app.py | 11 ++++++++++- joint_teapot/utils/joj3.py | 6 ++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/joint_teapot/app.py b/joint_teapot/app.py index 9395aad..fd9c6e7 100644 --- a/joint_teapot/app.py +++ b/joint_teapot/app.py @@ -308,9 +308,18 @@ def joj3_create_result_issue( "", help="repository's name of the submitter", ), + run_number: str = Argument( + "", + help="gitea actions run number", + ), ) -> None: set_settings(Settings(_env_file=env_path)) - title, comment = joj3.generate_title_and_comment(scorefile_path) + action_link = ( + f"https://{settings.gitea_domain_name}{settings.gitea_suffix}/" + + f"{settings.gitea_org_name}/{submitter_repo_name}/" + + f"actions/runs/{run_number}" + ) + title, comment = joj3.generate_title_and_comment(scorefile_path, action_link) tea.pot.gitea.create_issue(submitter_repo_name, title, comment, False) diff --git a/joint_teapot/utils/joj3.py b/joint_teapot/utils/joj3.py index 099c172..631c14d 100644 --- a/joint_teapot/utils/joj3.py +++ b/joint_teapot/utils/joj3.py @@ -164,12 +164,14 @@ def generate_failed_table( write_failed_table_into_file(data, table_file_path) -def generate_title_and_comment(score_file_path: str) -> Tuple[str, str]: +def generate_title_and_comment( + score_file_path: str, action_link: 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 = "" + comment = f"[Gitea Actions]({action_link})\n" for stage in stages: comment += f"## {stage['name']}\n" for i, result in enumerate(stage["results"]):