From d0192f37eff9d9bd68304a4508f9cb8e8c4d3d2f Mon Sep 17 00:00:00 2001 From: BoYanZh Date: Tue, 1 Oct 2024 02:32:20 -0400 Subject: [PATCH] feat: failure link --- joint_teapot/app.py | 10 ++++++++++ joint_teapot/utils/joj3.py | 22 ++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/joint_teapot/app.py b/joint_teapot/app.py index eb69963..23ebe6d 100644 --- a/joint_teapot/app.py +++ b/joint_teapot/app.py @@ -267,6 +267,10 @@ def joj3_failed_table( failed_table_file_name: str = Argument( "failed-table.md", help="name of failed table file in the gitea repo" ), + run_number: str = Argument( + "", + help="gitea actions run number", + ), ) -> None: set_settings(Settings(_env_file=env_path)) if joj3.check_skipped(score_file_path, "skip-failed-table"): @@ -286,11 +290,17 @@ def joj3_failed_table( f"https://{settings.gitea_domain_name}{settings.gitea_suffix}/" + f"{settings.gitea_org_name}/{submitter_repo_name}" ) + action_link = ( + f"https://{settings.gitea_domain_name}{settings.gitea_suffix}/" + + f"{settings.gitea_org_name}/{submitter_repo_name}/" + + f"actions/runs/{run_number}" + ) joj3.generate_failed_table( score_file_path, submitter_repo_name, submitter_repo_link, os.path.join(repo_path, failed_table_file_name), + action_link, ) tea.pot.git.add_commit_and_push( repo_name, diff --git a/joint_teapot/utils/joj3.py b/joint_teapot/utils/joj3.py index 088957b..921bd31 100644 --- a/joint_teapot/utils/joj3.py +++ b/joint_teapot/utils/joj3.py @@ -110,7 +110,11 @@ def get_failed_table_from_file(table_file_path: str) -> List[List[str]]: def update_failed_table_from_score_file( - data: List[List[str]], score_file_path: str, repo_name: str, repo_link: str + data: List[List[str]], + score_file_path: str, + repo_name: str, + repo_link: str, + action_link: str, ) -> None: # get info from score file with open(score_file_path) as json_file: @@ -125,7 +129,7 @@ def update_failed_table_from_score_file( # append to failed table now = datetime.now().strftime("%Y-%m-%d %H:%M") repo = f"[{repo_name}]({repo_link})" - failure = f"[{failed_name}]({'#'})" # TODO: Update failure link + failure = f"[{failed_name}]({action_link})" row_found = False for i, row in enumerate(data[:]): if row[1] == repo: @@ -152,7 +156,11 @@ def write_failed_table_into_file(data: List[List[str]], table_file_path: str) -> def generate_failed_table( - score_file_path: str, repo_name: str, repo_link: str, table_file_path: str + score_file_path: str, + repo_name: str, + repo_link: str, + table_file_path: str, + action_link: str, ) -> None: if not table_file_path.endswith(".md"): logger.error( @@ -161,7 +169,13 @@ def generate_failed_table( return data = get_failed_table_from_file(table_file_path) - update_failed_table_from_score_file(data, score_file_path, repo_name, repo_link) + update_failed_table_from_score_file( + data, + score_file_path, + repo_name, + repo_link, + action_link, + ) write_failed_table_into_file(data, table_file_path)