Skip to content

Commit

Permalink
fix: Result table changes, add mod table to comment, add thumbnail of…
Browse files Browse the repository at this point in the history
… multi-part STLs
  • Loading branch information
FHeilmann committed Dec 15, 2023
1 parent 11d369d commit 3bbbe39
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
4 changes: 2 additions & 2 deletions voron_toolkit/tools/stl_corruption_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ def _check_stl(self: Self, stl_file_path: Path) -> StepResult:
return StepResult.FAILURE
logger.success("STL '{}' OK!", stl_file_path.relative_to(self.input_dir).as_posix())
self.check_summary.append(
[stl_file_path.name, StepResult.SUCCESS.result_icon, "0"],
[stl_file_path.name, f"{StepResult.SUCCESS.result_icon} {StepResult.SUCCESS.name}", "0"],
)
return StepResult.SUCCESS
except Exception: # noqa: BLE001
logger.critical("A fatal error occurred while checking '{}'!", stl_file_path.relative_to(self.input_dir).as_posix())
self.check_summary.append(
[stl_file_path.name, StepResult.EXCEPTION.result_icon, "0"],
[stl_file_path.name, f"{StepResult.EXCEPTION.result_icon} {StepResult.EXCEPTION.name}", "0"],
)
return StepResult.EXCEPTION

Expand Down
11 changes: 6 additions & 5 deletions voron_toolkit/tools/stl_rotation_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,14 @@ def _write_fixed_stl_file(self: Self, stl: dict[int, Any], opts: Tweak, stl_file
def _check_stl(self: Self, stl_file_path: Path) -> StepResult:
try:
mesh_objects: dict[int, Any] = FileHandler().load_mesh(inputfile=stl_file_path.as_posix())
original_image_url: str = self._make_markdown_image(stl_file_path=stl_file_path.relative_to(self.input_dir))

if len(mesh_objects.items()) > 1:
logger.warning("File '{}' contains multiple objects and is therefore skipped!", stl_file_path.relative_to(self.input_dir).as_posix())
self.check_summary.append([stl_file_path.name, StepResult.WARNING.result_icon, "", ""])
self.check_summary.append([stl_file_path.name, f"{StepResult.WARNING.result_icon} MULTI-PART", original_image_url, ""])
return StepResult.WARNING
rotated_mesh: Tweak = Tweak(mesh_objects[0]["mesh"], extended_mode=True, verbose=False, min_volume=True)

original_image_url: str = self._make_markdown_image(stl_file_path=stl_file_path.relative_to(self.input_dir))
if rotated_mesh.rotation_angle >= TWEAK_THRESHOLD:
logger.warning("Found rotation suggestion for STL '{}'!", stl_file_path.relative_to(self.input_dir).as_posix())
output_stl_path: Path = Path(
Expand All @@ -157,20 +158,20 @@ def _check_stl(self: Self, stl_file_path: Path) -> StepResult:
self.check_summary.append(
[
stl_file_path.name,
StepResult.WARNING.result_icon,
f"{StepResult.WARNING.result_icon} {StepResult.WARNING.name}",
original_image_url,
rotated_image_url,
],
)
return StepResult.WARNING
logger.success("File '{}' OK!", stl_file_path.relative_to(self.input_dir).as_posix())
self.check_summary.append(
[stl_file_path.name, StepResult.SUCCESS.result_icon, original_image_url, ""],
[stl_file_path.name, f"{StepResult.SUCCESS.result_icon} {StepResult.SUCCESS.name}", original_image_url, ""],
)
return StepResult.SUCCESS
except Exception: # noqa: BLE001
logger.critical("A fatal error occurred while checking {}", stl_file_path.relative_to(self.input_dir).as_posix())
self.check_summary.append([stl_file_path.name, StepResult.EXCEPTION.result_icon, "", ""])
self.check_summary.append([stl_file_path.name, f"{StepResult.EXCEPTION.result_icon} {StepResult.EXCEPTION.name}", "", ""])
return StepResult.EXCEPTION


Expand Down
4 changes: 2 additions & 2 deletions voron_toolkit/tools/whitespace_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def _check_for_whitespace(self: Self) -> None:

if result_ok:
logger.success("File '{}' OK!", input_file)
self.check_summary.append([input_file, StepResult.SUCCESS.result_icon, ""])
self.check_summary.append([input_file, f"{StepResult.SUCCESS.result_icon} {StepResult.SUCCESS.name}", ""])
else:
logger.error("File '{}' contains whitespace!", input_file)
self.check_summary.append([input_file, StepResult.FAILURE.result_icon, "This [path] contains whitespace!"])
self.check_summary.append([input_file, f"{StepResult.FAILURE.result_icon} {StepResult.FAILURE.name}", "This folder/file contains whitespace!"])
self.return_status = StepResult.FAILURE

def run(self: Self) -> None:
Expand Down
20 changes: 18 additions & 2 deletions voron_toolkit/utils/pr_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import configargparse
from loguru import logger

from voron_toolkit.constants import CI_ERROR_LABEL, CI_FAILURE_LABEL, CI_PASSED_LABEL, VORONUSERS_PR_COMMENT_SECTIONS, StepResult
from voron_toolkit.constants import CI_ERROR_LABEL, CI_FAILURE_LABEL, CI_PASSED_LABEL, VORONUSERS_PR_COMMENT_SECTIONS, StepIdentifier, StepResult
from voron_toolkit.utils.github_action_helper import GithubActionHelper
from voron_toolkit.utils.logging import init_logging

Expand Down Expand Up @@ -45,6 +45,22 @@ def _parse_artifact(self: Self) -> None:
logger.error("Artifact is missing pr_number.txt file!")
sys.exit(255)
self.pr_number = int(Path(self.tmp_path, "pr_number.txt").read_text())
# Parse generate-readme step if it was executed:
if not (
Path(self.tmp_path, StepIdentifier.README_GENERATOR.step_id, "summary.md").exists()
and Path(self.tmp_path, StepIdentifier.README_GENERATOR.step_id, "outcome.txt").exists()
):
logger.info("No README_GENERATOR step found in artifact, skipping ...")
else:
outcome: StepResult = StepResult[Path(self.tmp_path, StepIdentifier.README_GENERATOR.step_id, "outcome.txt").read_text()]
self.comment_body += "I have found and attempted to parse the following mods in this PR:\n\n"
self.comment_body += Path(self.tmp_path, StepIdentifier.README_GENERATOR.step_id, "summary.md").read_text()
self.comment_body += "\n\n---\n\n"
if outcome > StepResult.SUCCESS:
self.labels.add(CI_ERROR_LABEL)

self.comment_body += "\nThese are the results of the individual CI checks:\n\n"

for pr_step_identifier in VORONUSERS_PR_COMMENT_SECTIONS:
if not (
Path(self.tmp_path, pr_step_identifier.step_id, "summary.md").exists()
Expand All @@ -59,7 +75,7 @@ def _parse_artifact(self: Self) -> None:
)
self.labels.add(CI_ERROR_LABEL)
continue
outcome: StepResult = StepResult[Path(self.tmp_path, pr_step_identifier.step_id, "outcome.txt").read_text()]
outcome = StepResult[Path(self.tmp_path, pr_step_identifier.step_id, "outcome.txt").read_text()]
self.comment_body += f"#### {pr_step_identifier.step_name}: {outcome.result_icon}\n\n"
self.comment_body += Path(self.tmp_path, pr_step_identifier.step_id, "summary.md").read_text()
self.comment_body += "\n\n---\n\n"
Expand Down

0 comments on commit 3bbbe39

Please sign in to comment.