feat: support joj3 metadata skip steps
This commit is contained in:
parent
85fae796ce
commit
98e4400e32
|
@ -211,7 +211,7 @@ def unsubscribe_from_repos(pattern: str = Argument("")) -> None:
|
||||||
)
|
)
|
||||||
def joj3_scoreboard(
|
def joj3_scoreboard(
|
||||||
env_path: str = Argument("", help="path to .env file"),
|
env_path: str = Argument("", help="path to .env file"),
|
||||||
scorefile_path: str = Argument(
|
score_file_path: str = Argument(
|
||||||
"", help="path to score json file generated by JOJ3"
|
"", help="path to score json file generated by JOJ3"
|
||||||
),
|
),
|
||||||
submitter: str = Argument("", help="submitter ID"),
|
submitter: str = Argument("", help="submitter ID"),
|
||||||
|
@ -224,6 +224,8 @@ def joj3_scoreboard(
|
||||||
),
|
),
|
||||||
) -> None:
|
) -> None:
|
||||||
set_settings(Settings(_env_file=env_path))
|
set_settings(Settings(_env_file=env_path))
|
||||||
|
if joj3.check_skipped(score_file_path, "skip-scoreboard"):
|
||||||
|
return
|
||||||
repo_path = tea.pot.git.repo_clean_and_checkout(repo_name, "grading")
|
repo_path = tea.pot.git.repo_clean_and_checkout(repo_name, "grading")
|
||||||
repo: Repo = tea.pot.git.get_repo(repo_name)
|
repo: Repo = tea.pot.git.get_repo(repo_name)
|
||||||
if "grading" not in repo.remote().refs:
|
if "grading" not in repo.remote().refs:
|
||||||
|
@ -236,7 +238,7 @@ def joj3_scoreboard(
|
||||||
return
|
return
|
||||||
repo.git.reset("--hard", "origin/grading")
|
repo.git.reset("--hard", "origin/grading")
|
||||||
joj3.generate_scoreboard(
|
joj3.generate_scoreboard(
|
||||||
scorefile_path,
|
score_file_path,
|
||||||
submitter,
|
submitter,
|
||||||
os.path.join(repo_path, scoreboard_file_name),
|
os.path.join(repo_path, scoreboard_file_name),
|
||||||
)
|
)
|
||||||
|
@ -252,12 +254,12 @@ def joj3_scoreboard(
|
||||||
)
|
)
|
||||||
def joj3_failed_table(
|
def joj3_failed_table(
|
||||||
env_path: str = Argument("", help="path to .env file"),
|
env_path: str = Argument("", help="path to .env file"),
|
||||||
scorefile_path: str = Argument(
|
score_file_path: str = Argument(
|
||||||
"", help="path to score json file generated by JOJ3"
|
"", help="path to score json file generated by JOJ3"
|
||||||
),
|
),
|
||||||
repo_name: str = Argument(
|
repo_name: str = Argument(
|
||||||
"",
|
"",
|
||||||
help="name of grading repo to push scoreboard file",
|
help="name of grading repo to push failed table file",
|
||||||
),
|
),
|
||||||
submitter_repo_name: str = Argument(
|
submitter_repo_name: str = Argument(
|
||||||
"",
|
"",
|
||||||
|
@ -268,6 +270,8 @@ def joj3_failed_table(
|
||||||
),
|
),
|
||||||
) -> None:
|
) -> None:
|
||||||
set_settings(Settings(_env_file=env_path))
|
set_settings(Settings(_env_file=env_path))
|
||||||
|
if joj3.check_skipped(score_file_path, "skip-failed-table"):
|
||||||
|
return
|
||||||
repo_path = tea.pot.git.repo_clean_and_checkout(repo_name, "grading")
|
repo_path = tea.pot.git.repo_clean_and_checkout(repo_name, "grading")
|
||||||
repo: Repo = tea.pot.git.get_repo(repo_name)
|
repo: Repo = tea.pot.git.get_repo(repo_name)
|
||||||
if "grading" not in repo.remote().refs:
|
if "grading" not in repo.remote().refs:
|
||||||
|
@ -284,7 +288,7 @@ def joj3_failed_table(
|
||||||
+ f"{settings.gitea_org_name}/{submitter_repo_name}"
|
+ f"{settings.gitea_org_name}/{submitter_repo_name}"
|
||||||
)
|
)
|
||||||
joj3.generate_failed_table(
|
joj3.generate_failed_table(
|
||||||
scorefile_path,
|
score_file_path,
|
||||||
submitter_repo_name,
|
submitter_repo_name,
|
||||||
submitter_repo_link,
|
submitter_repo_link,
|
||||||
os.path.join(repo_path, failed_table_file_name),
|
os.path.join(repo_path, failed_table_file_name),
|
||||||
|
@ -301,7 +305,7 @@ def joj3_failed_table(
|
||||||
)
|
)
|
||||||
def joj3_create_result_issue(
|
def joj3_create_result_issue(
|
||||||
env_path: str = Argument("", help="path to .env file"),
|
env_path: str = Argument("", help="path to .env file"),
|
||||||
scorefile_path: str = Argument(
|
score_file_path: str = Argument(
|
||||||
"", help="path to score json file generated by JOJ3"
|
"", help="path to score json file generated by JOJ3"
|
||||||
),
|
),
|
||||||
submitter_repo_name: str = Argument(
|
submitter_repo_name: str = Argument(
|
||||||
|
@ -314,12 +318,14 @@ def joj3_create_result_issue(
|
||||||
),
|
),
|
||||||
) -> None:
|
) -> None:
|
||||||
set_settings(Settings(_env_file=env_path))
|
set_settings(Settings(_env_file=env_path))
|
||||||
|
if joj3.check_skipped(score_file_path, "skip-result-issue"):
|
||||||
|
return
|
||||||
action_link = (
|
action_link = (
|
||||||
f"https://{settings.gitea_domain_name}{settings.gitea_suffix}/"
|
f"https://{settings.gitea_domain_name}{settings.gitea_suffix}/"
|
||||||
+ f"{settings.gitea_org_name}/{submitter_repo_name}/"
|
+ f"{settings.gitea_org_name}/{submitter_repo_name}/"
|
||||||
+ f"actions/runs/{run_number}"
|
+ f"actions/runs/{run_number}"
|
||||||
)
|
)
|
||||||
title, comment = joj3.generate_title_and_comment(scorefile_path, action_link)
|
title, comment = joj3.generate_title_and_comment(score_file_path, action_link)
|
||||||
tea.pot.gitea.create_issue(submitter_repo_name, title, comment, False)
|
tea.pot.gitea.create_issue(submitter_repo_name, title, comment, False)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,10 @@ def generate_scoreboard(
|
||||||
|
|
||||||
exercise_name = "unknown"
|
exercise_name = "unknown"
|
||||||
for stage in stages:
|
for stage in stages:
|
||||||
if stage["name"] == "metadata":
|
if stage["name"] != "metadata":
|
||||||
comment = stage["results"][0]["comment"]
|
continue
|
||||||
exercise_name = comment.split("-")[0]
|
comment = stage["results"][0]["comment"]
|
||||||
|
exercise_name = comment.split("-")[0]
|
||||||
# Find if exercise in table:
|
# Find if exercise in table:
|
||||||
if exercise_name not in columns:
|
if exercise_name not in columns:
|
||||||
column_tail = columns[3:]
|
column_tail = columns[3:]
|
||||||
|
@ -183,3 +184,15 @@ def generate_title_and_comment(
|
||||||
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
title = f"JOJ3 Result {now} - Total Score: {total_score}"
|
title = f"JOJ3 Result {now} - Total Score: {total_score}"
|
||||||
return title, comment
|
return title, comment
|
||||||
|
|
||||||
|
|
||||||
|
def check_skipped(score_file_path: str, keyword: str) -> bool:
|
||||||
|
with open(score_file_path) as json_file:
|
||||||
|
stages: List[Dict[str, Any]] = json.load(json_file)
|
||||||
|
for stage in stages:
|
||||||
|
if stage["name"] != "metadata":
|
||||||
|
continue
|
||||||
|
comment = stage["results"][0]["comment"]
|
||||||
|
if keyword in comment or "skip-teapot" in comment:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user