feat: failure link

This commit is contained in:
张泊明518370910136 2024-10-01 02:32:20 -04:00
parent 9d4d4eb7fe
commit d0192f37ef
GPG Key ID: CA088E6D9284F870
2 changed files with 28 additions and 4 deletions

View File

@ -267,6 +267,10 @@ def joj3_failed_table(
failed_table_file_name: str = Argument( failed_table_file_name: str = Argument(
"failed-table.md", help="name of failed table file in the gitea repo" "failed-table.md", help="name of failed table file in the gitea repo"
), ),
run_number: str = Argument(
"",
help="gitea actions run number",
),
) -> 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"): if joj3.check_skipped(score_file_path, "skip-failed-table"):
@ -286,11 +290,17 @@ def joj3_failed_table(
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}"
) )
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( joj3.generate_failed_table(
score_file_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),
action_link,
) )
tea.pot.git.add_commit_and_push( tea.pot.git.add_commit_and_push(
repo_name, repo_name,

View File

@ -110,7 +110,11 @@ def get_failed_table_from_file(table_file_path: str) -> List[List[str]]:
def update_failed_table_from_score_file( 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: ) -> None:
# get info from score file # get info from score file
with open(score_file_path) as json_file: with open(score_file_path) as json_file:
@ -125,7 +129,7 @@ def update_failed_table_from_score_file(
# append to failed table # append to failed table
now = datetime.now().strftime("%Y-%m-%d %H:%M") now = datetime.now().strftime("%Y-%m-%d %H:%M")
repo = f"[{repo_name}]({repo_link})" repo = f"[{repo_name}]({repo_link})"
failure = f"[{failed_name}]({'#'})" # TODO: Update failure link failure = f"[{failed_name}]({action_link})"
row_found = False row_found = False
for i, row in enumerate(data[:]): for i, row in enumerate(data[:]):
if row[1] == repo: if row[1] == repo:
@ -152,7 +156,11 @@ def write_failed_table_into_file(data: List[List[str]], table_file_path: str) ->
def generate_failed_table( 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: ) -> None:
if not table_file_path.endswith(".md"): if not table_file_path.endswith(".md"):
logger.error( logger.error(
@ -161,7 +169,13 @@ def generate_failed_table(
return return
data = get_failed_table_from_file(table_file_path) 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) write_failed_table_into_file(data, table_file_path)