From 40db41e87f76d7b5f0a2ca876ec6b74ad854b4c1 Mon Sep 17 00:00:00 2001 From: BoYanZh Date: Sun, 27 Oct 2024 04:58:08 -0400 Subject: [PATCH] feat: joj3 all with link to issue --- joint_teapot/app.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/joint_teapot/app.py b/joint_teapot/app.py index c7086c9..bcb7c3e 100644 --- a/joint_teapot/app.py +++ b/joint_teapot/app.py @@ -476,25 +476,32 @@ def joj3_all( set_settings(Settings(_env_file=env_path)) set_logger(settings.stderr_log_level, diagnose=False, backtrace=False) logger.info(f"debug log to file: {settings.log_file_path}") - actions_link = ( + actions_url = ( f"https://{settings.gitea_domain_name}{settings.gitea_suffix}/" + f"{settings.gitea_org_name}/{submitter_repo_name}/" + f"actions/runs/{run_number}" ) - submitter_repo_link = ( + submitter_repo_url = ( f"https://{settings.gitea_domain_name}{settings.gitea_suffix}/" + f"{settings.gitea_org_name}/{submitter_repo_name}" ) + gitea_issue_url = "" if not skip_result_issue: title, comment = joj3.generate_title_and_comment( score_file_path, - actions_link, + actions_url, run_number, exercise_name, submitter, commit_hash, ) - tea.pot.gitea.create_issue(submitter_repo_name, title, comment, False) + res = tea.pot.gitea.issue_api.issue_create_issue( + tea.pot.gitea.org_name, + submitter_repo_name, + body={"title": title, "body": comment}, + ) + logger.info(f"create issue result: {res}") + gitea_issue_url = res["url"] if skip_scoreboard and skip_failed_table: return tea.pot.git # trigger lazy load @@ -530,25 +537,27 @@ def joj3_all( [scoreboard_file_name], ( f"joj3: update scoreboard by @{submitter} in " - + f"{settings.gitea_org_name}/{submitter_repo_name}@{commit_hash}\n\n" - + f"gitea actions link: {actions_link}" + f"{settings.gitea_org_name}/{submitter_repo_name}@{commit_hash}\n\n" + f"gitea actions link: {actions_url}\n" + f"gitea issue link: {gitea_issue_url}" ), ) if not skip_failed_table: joj3.generate_failed_table( score_file_path, submitter_repo_name, - submitter_repo_link, + submitter_repo_url, os.path.join(repo_path, failed_table_file_name), - actions_link, + actions_url, ) tea.pot.git.add_commit( repo_name, [failed_table_file_name], ( f"joj3: update failed table by @{submitter} in " - + f"{settings.gitea_org_name}/{submitter_repo_name}@{commit_hash}\n\n" - + f"gitea actions link: {actions_link}" + f"{settings.gitea_org_name}/{submitter_repo_name}@{commit_hash}\n\n" + f"gitea actions link: {actions_url}" + f"gitea issue link: {gitea_issue_url}" ), ) tea.pot.git.push(repo_name)