Skip to content

Commit

Permalink
fix: mods.json printer compatibility should be array, don't hardcode …
Browse files Browse the repository at this point in the history
…tools for summary
  • Loading branch information
FHeilmann committed Jan 8, 2024
1 parent f4f554a commit 92b0817
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
8 changes: 0 additions & 8 deletions voron_toolkit/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,3 @@ class ToolIdentifierEnum(ToolIdentifier, Enum):
README_GENERATOR = ToolIdentifier(tool_id="readme_generator", tool_name="Readme generator")
ROTATION_CHECK = ToolIdentifier(tool_id="rotation_check", tool_name="STL rotation checker")
FILE_CHECK = ToolIdentifier(tool_id="file_check", tool_name="File checker")


VORONUSERS_PR_COMMENT_SECTIONS: list[ToolIdentifierEnum] = [
ToolIdentifierEnum.FILE_CHECK,
ToolIdentifierEnum.MOD_STRUCTURE_CHECK,
ToolIdentifierEnum.CORRUPTION_CHECK,
ToolIdentifierEnum.ROTATION_CHECK,
]
4 changes: 2 additions & 2 deletions voron_toolkit/tools/readme_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def run(self: Self) -> None:
"title": metadata["title"],
"creator": yml_file.relative_to(self.input_dir).parts[0],
"description": metadata["description"],
"printer_compatibility": f'{", ".join(sorted(metadata["printer_compatibility"]))}',
"printer_compatibility": sorted(metadata["printer_compatibility"]),
"last_changed": GithubActionHelper.last_commit_timestamp(file_or_directory=yml_file.parent),
}
)
Expand All @@ -118,7 +118,7 @@ def run(self: Self) -> None:
mod["creator"] if mod["creator"] != prev_username else "",
f'[{textwrap.shorten(mod["title"], width=35, placeholder="...")}]({mod["path"]})',
textwrap.shorten(mod["description"], width=70, placeholder="..."),
mod["printer_compatibility"],
f'{", ".join(mod["printer_compatibility"])}',
mod["last_changed"],
]
)
Expand Down
21 changes: 12 additions & 9 deletions voron_toolkit/voronuser_utils/pr_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
LABEL_CI_PASSED,
LABEL_READY_FOR_CI,
LABELS_CI_ALL,
VORONUSERS_PR_COMMENT_SECTIONS,
ExtendedResultEnum,
ItemResult,
PrAction,
Expand Down Expand Up @@ -106,8 +105,8 @@ def _result_details_for_extended_result(self: Self, extended_result: ExtendedRes
result_details += "<details>\n"
result_details += f"<summary>{extended_result.name}: {extended_result.icon}</summary>\n\n"

for pr_step_identifier in VORONUSERS_PR_COMMENT_SECTIONS:
if pr_step_identifier not in self.tool_results or not self.tool_results[pr_step_identifier]:
for pr_step_identifier in self.tool_results:
if not self.tool_results[pr_step_identifier]:
continue
filtered_markdown_table = self.tool_results[pr_step_identifier].tool_result_items.to_markdown(filter_result=extended_result)
if not filtered_markdown_table:
Expand All @@ -125,17 +124,21 @@ def _parse_artifact_and_get_labels(self: Self) -> set[str]:

logger.info("Parsing Artifact ...")

for pr_step_identifier in [*VORONUSERS_PR_COMMENT_SECTIONS, ToolIdentifierEnum.README_GENERATOR]:
if not (Path(self.tmp_path, pr_step_identifier.tool_id, "tool_result.json").exists()):
for directory in [item for item in self.tmp_path.iterdir() if item.is_dir()]:
try:
pr_step_identifier = ToolIdentifierEnum[directory.name.upper()]
except ValueError:
logger.warning("Skipping unknown directory {}", directory.name)
continue
if not (Path(directory, "tool_result.json").exists()):
logger.warning(
"Section '{}' is missing or incomplete in artifact! folder: {}, json: {}",
"Section '{}' is incomplete in artifact! json: {}",
pr_step_identifier,
Path(self.tmp_path, pr_step_identifier.tool_id).exists(),
Path(self.tmp_path, pr_step_identifier.tool_id, "tool_result.json").exists(),
Path(directory, "tool_result.json").exists(),
)
labels.add(LABEL_CI_ERROR)
continue
ci_step_result = ToolResult.from_json(Path(self.tmp_path, pr_step_identifier.tool_id, "tool_result.json").read_text())
ci_step_result = ToolResult.from_json(Path(directory, "tool_result.json").read_text())
result_ok = ExtendedResultEnum.WARNING if ci_step_result.tool_ignore_warnings else ExtendedResultEnum.SUCCESS
if ci_step_result.extended_result > result_ok:
labels.add(LABEL_CI_ISSUES_FOUND)
Expand Down

0 comments on commit 92b0817

Please sign in to comment.