From a239f1e3880079271104d6876f61a90f971f5bad Mon Sep 17 00:00:00 2001 From: BoYanZh Date: Wed, 29 Jan 2025 08:49:07 -0500 Subject: [PATCH] feat: joj3-env for post stages --- joint_teapot/app.py | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/joint_teapot/app.py b/joint_teapot/app.py index e0e5ce3..be3d370 100644 --- a/joint_teapot/app.py +++ b/joint_teapot/app.py @@ -639,6 +639,80 @@ def joj3_all( sleep(retry_interval) +@app.command( + "joj3-env", + help="run all joj3 tasks from env var and cli args", +) +def joj3_env( + env_path: str = Argument("", help="path to .env file"), + score_file_path: str = Argument( + "", help="path to score json file generated by JOJ3" + ), + repo_name: str = Argument( + "", + help="name of grading repo to push failed table file", + ), + submitter_repo_name: str = Argument( + "", + help="repository's name of the submitter", + ), + scoreboard_file_name: str = Argument( + "scoreboard.csv", help="name of scoreboard file in the gitea repo" + ), + failed_table_file_name: str = Argument( + "failed-table.md", help="name of failed table file in the gitea repo" + ), + max_total_score: int = Option( + -1, + help="max total score", + ), + skip_result_issue: bool = Option( + False, + help="skip creating result issue on gitea", + ), + skip_scoreboard: bool = Option( + False, + help="skip creating scoreboard on gitea", + ), + skip_failed_table: bool = Option( + False, + help="skip creating failed table on gitea", + ), + submitter_in_issue_title: bool = Option( + True, + help="whether to include submitter in issue title", + ), +) -> None: + submitter = os.getenv("GITHUB_ACTOR") + run_number = os.getenv("GITHUB_RUN_NUMBER") + exercise_name = os.getenv("CONF_NAME") + commit_hash = os.getenv("GITHUB_SHA") + run_id = os.getenv("RUN_ID") + groups = os.getenv("GROUPS") + if None in (submitter, run_number, exercise_name, commit_hash, run_id, groups): + logger.error("missing required env var") + raise Exit(code=1) + joj3_all( + env_path, + score_file_path, + submitter, + repo_name, + submitter_repo_name, + run_number, + scoreboard_file_name, + failed_table_file_name, + exercise_name, + commit_hash, + run_id, + groups, + max_total_score, + skip_result_issue, + skip_scoreboard, + skip_failed_table, + submitter_in_issue_title, + ) + + @app.command( "joj3-check", help="check joj3 restrictions",