Skip to content

Commit

Permalink
feat: failure link
Browse files Browse the repository at this point in the history
  • Loading branch information
BoYanZh committed Oct 1, 2024
1 parent 9d4d4eb commit d0192f3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
10 changes: 10 additions & 0 deletions joint_teapot/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ def joj3_failed_table(
failed_table_file_name: str = Argument(
"failed-table.md", help="name of failed table file in the gitea repo"
),
run_number: str = Argument(
"",
help="gitea actions run number",
),
) -> None:
set_settings(Settings(_env_file=env_path))
if joj3.check_skipped(score_file_path, "skip-failed-table"):
Expand All @@ -286,11 +290,17 @@ def joj3_failed_table(
f"https://{settings.gitea_domain_name}{settings.gitea_suffix}/"
+ f"{settings.gitea_org_name}/{submitter_repo_name}"
)
action_link = (
f"https://{settings.gitea_domain_name}{settings.gitea_suffix}/"
+ f"{settings.gitea_org_name}/{submitter_repo_name}/"
+ f"actions/runs/{run_number}"
)
joj3.generate_failed_table(
score_file_path,
submitter_repo_name,
submitter_repo_link,
os.path.join(repo_path, failed_table_file_name),
action_link,
)
tea.pot.git.add_commit_and_push(
repo_name,
Expand Down
22 changes: 18 additions & 4 deletions joint_teapot/utils/joj3.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ def get_failed_table_from_file(table_file_path: str) -> List[List[str]]:


def update_failed_table_from_score_file(
data: List[List[str]], score_file_path: str, repo_name: str, repo_link: str
data: List[List[str]],
score_file_path: str,
repo_name: str,
repo_link: str,
action_link: str,
) -> None:
# get info from score file
with open(score_file_path) as json_file:
Expand All @@ -125,7 +129,7 @@ def update_failed_table_from_score_file(
# append to failed table
now = datetime.now().strftime("%Y-%m-%d %H:%M")
repo = f"[{repo_name}]({repo_link})"
failure = f"[{failed_name}]({'#'})" # TODO: Update failure link
failure = f"[{failed_name}]({action_link})"
row_found = False
for i, row in enumerate(data[:]):
if row[1] == repo:
Expand All @@ -152,7 +156,11 @@ def write_failed_table_into_file(data: List[List[str]], table_file_path: str) ->


def generate_failed_table(
score_file_path: str, repo_name: str, repo_link: str, table_file_path: str
score_file_path: str,
repo_name: str,
repo_link: str,
table_file_path: str,
action_link: str,
) -> None:
if not table_file_path.endswith(".md"):
logger.error(
Expand All @@ -161,7 +169,13 @@ def generate_failed_table(
return

data = get_failed_table_from_file(table_file_path)
update_failed_table_from_score_file(data, score_file_path, repo_name, repo_link)
update_failed_table_from_score_file(
data,
score_file_path,
repo_name,
repo_link,
action_link,
)
write_failed_table_into_file(data, table_file_path)


Expand Down

0 comments on commit d0192f3

Please sign in to comment.