feat: load score file from env var
This commit is contained in:
parent
c8d6c10409
commit
1430b11e45
|
@ -649,9 +649,6 @@ def joj3_all(
|
||||||
)
|
)
|
||||||
def joj3_all_env(
|
def joj3_all_env(
|
||||||
env_path: str = Argument("", help="path to .env file"),
|
env_path: str = Argument("", help="path to .env file"),
|
||||||
score_file_path: str = Argument(
|
|
||||||
"", help="path to score json file generated by JOJ3"
|
|
||||||
),
|
|
||||||
grading_repo_name: str = Argument(
|
grading_repo_name: str = Argument(
|
||||||
"",
|
"",
|
||||||
help="name of grading repo to push failed table file",
|
help="name of grading repo to push failed table file",
|
||||||
|
@ -704,6 +701,7 @@ def joj3_all_env(
|
||||||
groups = os.getenv("JOJ3_GROUPS", "")
|
groups = os.getenv("JOJ3_GROUPS", "")
|
||||||
commit_msg = os.getenv("JOJ3_COMMIT_MSG", "")
|
commit_msg = os.getenv("JOJ3_COMMIT_MSG", "")
|
||||||
force_quit_stage_name = os.getenv("JOJ3_FORCE_QUIT_STAGE_NAME") or ""
|
force_quit_stage_name = os.getenv("JOJ3_FORCE_QUIT_STAGE_NAME") or ""
|
||||||
|
score_file_path = os.getenv("JOJ3_OUTPUT_PATH", "")
|
||||||
submitter_repo_name = (repository or "").split("/")[-1]
|
submitter_repo_name = (repository or "").split("/")[-1]
|
||||||
total_score = joj3.get_total_score(score_file_path)
|
total_score = joj3.get_total_score(score_file_path)
|
||||||
res = {
|
res = {
|
||||||
|
@ -772,7 +770,7 @@ def joj3_all_env(
|
||||||
if skip_scoreboard and skip_failed_table:
|
if skip_scoreboard and skip_failed_table:
|
||||||
return
|
return
|
||||||
lock_file_path = os.path.join(
|
lock_file_path = os.path.join(
|
||||||
settings.repos_dir, submitter_repo_name, settings.joj3_lock_file_path
|
settings.repos_dir, grading_repo_name, settings.joj3_lock_file_path
|
||||||
)
|
)
|
||||||
logger.info(
|
logger.info(
|
||||||
f"try to acquire lock, file path: {lock_file_path}, "
|
f"try to acquire lock, file path: {lock_file_path}, "
|
||||||
|
@ -784,12 +782,12 @@ def joj3_all_env(
|
||||||
git_push_ok = False
|
git_push_ok = False
|
||||||
while not git_push_ok:
|
while not git_push_ok:
|
||||||
repo_path = tea.pot.git.repo_clean_and_checkout(
|
repo_path = tea.pot.git.repo_clean_and_checkout(
|
||||||
submitter_repo_name,
|
grading_repo_name,
|
||||||
"grading",
|
"grading",
|
||||||
clean_git_lock=True,
|
clean_git_lock=True,
|
||||||
reset_target="origin/grading",
|
reset_target="origin/grading",
|
||||||
)
|
)
|
||||||
repo: Repo = tea.pot.git.get_repo(submitter_repo_name)
|
repo: Repo = tea.pot.git.get_repo(grading_repo_name)
|
||||||
if "grading" not in repo.remote().refs:
|
if "grading" not in repo.remote().refs:
|
||||||
logger.error(
|
logger.error(
|
||||||
'"grading" branch not found in remote, create and push it to origin first.'
|
'"grading" branch not found in remote, create and push it to origin first.'
|
||||||
|
@ -807,7 +805,7 @@ def joj3_all_env(
|
||||||
exercise_name,
|
exercise_name,
|
||||||
)
|
)
|
||||||
tea.pot.git.add_commit(
|
tea.pot.git.add_commit(
|
||||||
submitter_repo_name,
|
grading_repo_name,
|
||||||
[scoreboard_file_name],
|
[scoreboard_file_name],
|
||||||
(
|
(
|
||||||
f"joj3: update scoreboard for {exercise_name} by @{submitter} in "
|
f"joj3: update scoreboard for {exercise_name} by @{submitter} in "
|
||||||
|
@ -826,7 +824,7 @@ def joj3_all_env(
|
||||||
gitea_actions_url,
|
gitea_actions_url,
|
||||||
)
|
)
|
||||||
tea.pot.git.add_commit(
|
tea.pot.git.add_commit(
|
||||||
submitter_repo_name,
|
grading_repo_name,
|
||||||
[failed_table_file_name],
|
[failed_table_file_name],
|
||||||
(
|
(
|
||||||
f"joj3: update failed table for {exercise_name} by @{submitter} in "
|
f"joj3: update failed table for {exercise_name} by @{submitter} in "
|
||||||
|
@ -836,7 +834,7 @@ def joj3_all_env(
|
||||||
f"groups: {groups}\n"
|
f"groups: {groups}\n"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
push_info_list = tea.pot.git.push(submitter_repo_name)
|
push_info_list = tea.pot.git.push(grading_repo_name)
|
||||||
git_push_ok = push_info_list.error is None
|
git_push_ok = push_info_list.error is None
|
||||||
if not git_push_ok:
|
if not git_push_ok:
|
||||||
retry_interval *= 2
|
retry_interval *= 2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user