From 1a4ffa214df985787b3d9014f1227d6f9b6a9948 Mon Sep 17 00:00:00 2001 From: BoYanZh Date: Wed, 16 Oct 2024 20:51:57 -0400 Subject: [PATCH] feat: show commit hash --- joint_teapot/app.py | 27 +++++++++++++++++++++++---- joint_teapot/utils/joj3.py | 8 +++++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/joint_teapot/app.py b/joint_teapot/app.py index b07199b..ce414f4 100644 --- a/joint_teapot/app.py +++ b/joint_teapot/app.py @@ -239,6 +239,10 @@ def joj3_scoreboard( "unknown", help="name of the exercise that appears on the issue title", ), + commit_hash: str = Argument( + "", + help="commit hash that triggers gitea actions", + ), ) -> None: set_settings(Settings(_env_file=env_path)) set_logger(settings.stderr_log_level, diagnose=False, backtrace=False) @@ -268,7 +272,8 @@ def joj3_scoreboard( + f"actions/runs/{run_number}" ) commit_message = ( - f"joj3: update scoreboard by @{submitter} in {submitter_repo_name}\n\n" + 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}" ) tea.pot.git.add_commit_and_push(repo_name, [scoreboard_file_name], commit_message) @@ -303,6 +308,10 @@ def joj3_failed_table( "unknown", help="name of the exercise that appears on the issue title", ), + commit_hash: str = Argument( + "", + help="commit hash that triggers gitea actions", + ), ) -> None: set_settings(Settings(_env_file=env_path)) set_logger(settings.stderr_log_level, diagnose=False, backtrace=False) @@ -337,7 +346,8 @@ def joj3_failed_table( actions_link, ) commit_message = ( - f"joj3: update failed table by @{submitter} in {submitter_repo_name}\n\n" + 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}" ) tea.pot.git.add_commit_and_push( @@ -356,6 +366,7 @@ def joj3_create_result_issue( score_file_path: str = Argument( "", help="path to score json file generated by JOJ3" ), + submitter: str = Argument("", help="submitter ID"), submitter_repo_name: str = Argument( "", help="repository's name of the submitter", @@ -368,7 +379,10 @@ def joj3_create_result_issue( "unknown", help="name of the exercise that appears on the issue title", ), - submitter: str = Argument("", help="submitter ID"), + commit_hash: str = Argument( + "", + help="commit hash that triggers gitea actions", + ), ) -> None: set_settings(Settings(_env_file=env_path)) set_logger(settings.stderr_log_level, diagnose=False, backtrace=False) @@ -381,7 +395,12 @@ def joj3_create_result_issue( + f"actions/runs/{run_number}" ) title, comment = joj3.generate_title_and_comment( - score_file_path, actions_link, run_number, exercise_name, submitter + score_file_path, + actions_link, + run_number, + exercise_name, + submitter, + commit_hash, ) 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 8431c49..99372fd 100644 --- a/joint_teapot/utils/joj3.py +++ b/joint_teapot/utils/joj3.py @@ -82,9 +82,9 @@ def generate_scoreboard( submitter_row[columns.index("total")] = str(total) now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") - submitter_row[columns.index("last_edit")] = ( - now # FIXME: Delete this in formal version - ) + submitter_row[ + columns.index("last_edit") + ] = now # FIXME: Delete this in formal version # Sort data by total, from low to high data.sort(key=lambda x: int(x[columns.index("total")])) @@ -184,6 +184,7 @@ def generate_title_and_comment( run_number: str, exercise_name: str, submitter: str, + commit_hash: str, ) -> Tuple[str, str]: with open(score_file_path) as json_file: stages: List[Dict[str, Any]] = json.load(json_file) @@ -196,6 +197,7 @@ def generate_title_and_comment( total_score = 0 comment = ( f"Generated from [Gitea Actions #{run_number}]({action_link}), " + + f"commit {commit_hash}, " + f"triggered by @{submitter}.\n" + "Powered by [JOJ3](https://github.com/joint-online-judge/JOJ3) and " + "[Joint-Teapot](https://github.com/BoYanZh/Joint-Teapot) with ❤️.\n"