diff --git a/.github/workflows/test_container.yml b/.github/workflows/test_container.yml index af48f63..64e23b3 100644 --- a/.github/workflows/test_container.yml +++ b/.github/workflows/test_container.yml @@ -5,8 +5,8 @@ on: jobs: test_job: env: - CORRUPTION_CHECKER_INPUT_DIR: tests/test_repository_root/printer_mods - ROTATION_CHECKER_INPUT_DIR: tests/test_repository_root/printer_mods + VORON_CI_OUTPUT: workflow_output + VORON_CI_STEP_SUMMARY: true runs-on: ubuntu-latest steps: # Checkout the entire repo @@ -35,29 +35,33 @@ jobs: WHITESPACE_CHECKER_INPUT_DIR: tests/test_repository_root/printer_mods WHITESPACE_CHECKER_VERBOSE: true WHITESPACE_CHECKER_IGNORE_WARNINGS: false - WHITESPACE_CHECKER_GITHUB_STEP_SUMMARY: true - WHITESPACE_CHECKER_OUTPUT_DIR: workflow_output with: args: check-whitespace + - name: Mod Structure Checker + uses: docker://ghcr.io/fheilmann/voron_ci_container:latest + env: + MOD_STRUCTURE_CHECKER_INPUT_DIR: tests/test_repository_root/printer_mods + MOD_STRUCTURE_CHECKER_VERBOSE: true + MOD_STRUCTURE_CHECKER_IGNORE_WARNINGS: false + with: + args: check-mod-structure # Run the corruption checker - name: Corruption Checker uses: docker://ghcr.io/fheilmann/voron_ci_container:latest env: + CORRUPTION_CHECKER_INPUT_DIR: tests/test_repository_root/printer_mods CORRUPTION_CHECKER_VERBOSE: true CORRUPTION_CHECKER_IGNORE_WARNINGS: true - CORRUPTION_CHECKER_GITHUB_STEP_SUMMARY: true - CORRUPTION_CHECKER_OUTPUT_DIR: workflow_output with: args: check-stl-corruption # Run the rotation checker - name: Rotation Checker uses: docker://ghcr.io/fheilmann/voron_ci_container:latest env: + ROTATION_CHECKER_INPUT_DIR: tests/test_repository_root/printer_mods ROTATION_CHECKER_VERBOSE: true ROTATION_CHECKER_IGNORE_WARNINGS: true - ROTATION_CHECKER_GITHUB_STEP_SUMMARY: true - ROTATION_CHECKER_OUTPUT_DIR: workflow_output - ROTATION_CHECKER_IMAGEKIT_ENDPOINT: ./ + ROTATION_CHECKER_IMAGEKIT_ENDPOINT: ./img ROTATION_CHECKER_IMAGEKIT_SUBFOLDER: test_run with: args: check-stl-rotation @@ -69,8 +73,6 @@ jobs: README_GENERATOR_README: true README_GENERATOR_VERBOSE: true README_GENERATOR_JSON: true - README_GENERATOR_GITHUB_STEP_SUMMARY: true - README_GENERATOR_OUTPUT_DIR: workflow_output with: args: generate-readme # Upload Artifact diff --git a/voron_ci/tools/mod_structure_checker.py b/voron_ci/tools/mod_structure_checker.py index 436a8c2..beba879 100644 --- a/voron_ci/tools/mod_structure_checker.py +++ b/voron_ci/tools/mod_structure_checker.py @@ -28,9 +28,7 @@ class FileErrors(StrEnum): class ModStructureChecker: def __init__(self: Self, args: configargparse.Namespace) -> None: self.input_dir: Path = Path(Path.cwd(), args.input_dir) - self.gh_helper: GithubActionHelper = GithubActionHelper( - output_path=None, do_gh_step_summary=args.github_step_summary, ignore_warnings=args.fail_on_error - ) + self.gh_helper: GithubActionHelper = GithubActionHelper(ignore_warnings=args.ignore_warnings) self.return_status: ReturnStatus = ReturnStatus.SUCCESS self.check_summary: list[list[str]] = [] @@ -101,7 +99,7 @@ def main() -> None: action="store", type=str, env_var=f"{ENV_VAR_PREFIX}_INPUT_DIR", - help="Directory containing STL files to be checked", + help="Directory containing Mods to be checked", ) parser.add_argument( "-v", @@ -118,16 +116,7 @@ def main() -> None: required=False, action="store_true", env_var=f"{ENV_VAR_PREFIX}_IGNORE_WARNINGS", - help="Whether to return an error exit code if one of the STLs is faulty", - default=False, - ) - parser.add_argument( - "-g", - "--github_step_summary", - required=False, - action="store_true", - env_var=f"{ENV_VAR_PREFIX}_GITHUB_STEP_SUMMARY", - help="Whether to output a step summary when running inside a github action", + help="Whether to return an error exit code if bad files or badly structured mods are found", default=False, ) args: configargparse.Namespace = parser.parse_args() diff --git a/voron_ci/tools/readme_generator.py b/voron_ci/tools/readme_generator.py index 2a85a3b..f48055a 100644 --- a/voron_ci/tools/readme_generator.py +++ b/voron_ci/tools/readme_generator.py @@ -35,7 +35,7 @@ def __init__(self: Self, args: configargparse.Namespace) -> None: self.input_dir: Path = Path(Path.cwd(), args.input_dir) self.json: bool = args.json self.readme: bool = args.readme - self.gh_helper: GithubActionHelper = GithubActionHelper(output_path=args.output_dir, do_gh_step_summary=args.github_step_summary, ignore_warnings=False) + self.gh_helper: GithubActionHelper = GithubActionHelper(ignore_warnings=False) if args.verbose: logger.setLevel("INFO") @@ -116,25 +116,6 @@ def main() -> None: env_var=f"{ENV_VAR_PREFIX}_INPUT_DIR", help="Base directory to search for metadata files", ) - parser.add_argument( - "-o", - "--output_dir", - required=False, - action="store", - type=str, - env_var=f"{ENV_VAR_PREFIX}_OUTPUT_DIR", - help="Directory to store the fixed STL files into", - default="", - ) - parser.add_argument( - "-g", - "--github_step_summary", - required=False, - action="store_true", - env_var=f"{ENV_VAR_PREFIX}_GITHUB_STEP_SUMMARY", - help="Whether to output a step summary when running inside a github action", - default=False, - ) parser.add_argument( "-r", "--readme", diff --git a/voron_ci/tools/stl_corruption_checker.py b/voron_ci/tools/stl_corruption_checker.py index cb2720b..f2c2ccc 100644 --- a/voron_ci/tools/stl_corruption_checker.py +++ b/voron_ci/tools/stl_corruption_checker.py @@ -23,9 +23,7 @@ def __init__(self: Self, args: configargparse.Namespace) -> None: self.input_dir: Path = Path(Path.cwd(), args.input_dir) self.return_status: ReturnStatus = ReturnStatus.SUCCESS self.check_summary: list[list[str]] = [] - self.gh_helper: GithubActionHelper = GithubActionHelper( - output_path=args.output_dir, do_gh_step_summary=args.github_step_summary, ignore_warnings=args.ignore_warnings - ) + self.gh_helper: GithubActionHelper = GithubActionHelper(ignore_warnings=args.ignore_warnings) if args.verbose: logger.setLevel("INFO") @@ -114,16 +112,6 @@ def main() -> None: env_var=f"{ENV_VAR_PREFIX}_INPUT_DIR", help="Directory containing STL files to be checked", ) - parser.add_argument( - "-o", - "--output_dir", - required=False, - action="store", - type=str, - env_var=f"{ENV_VAR_PREFIX}_OUTPUT_DIR", - help="Directory to store the fixed STL files into", - default="", - ) parser.add_argument( "-f", "--ignore_warnings", @@ -142,15 +130,6 @@ def main() -> None: help="Print debug output to stdout", default=False, ) - parser.add_argument( - "-g", - "--github_step_summary", - required=False, - action="store_true", - env_var=f"{ENV_VAR_PREFIX}_GITHUB_STEP_SUMMARY", - help="Whether to output a step summary when running inside a github action", - default=False, - ) args: configargparse.Namespace = parser.parse_args() STLCorruptionChecker(args=args).run() diff --git a/voron_ci/tools/stl_rotation_checker.py b/voron_ci/tools/stl_rotation_checker.py index 1671413..66a3723 100644 --- a/voron_ci/tools/stl_rotation_checker.py +++ b/voron_ci/tools/stl_rotation_checker.py @@ -33,9 +33,7 @@ def __init__(self: Self, args: configargparse.Namespace) -> None: self.imagekit_subfolder: str = args.imagekit_subfolder self.return_status: ReturnStatus = ReturnStatus.SUCCESS self.check_summary: list[list[str]] = [] - self.gh_helper: GithubActionHelper = GithubActionHelper( - output_path=args.output_dir, do_gh_step_summary=args.github_step_summary, ignore_warnings=args.ignore_warnings - ) + self.gh_helper: GithubActionHelper = GithubActionHelper(ignore_warnings=args.ignore_warnings) if args.verbose: logger.setLevel("INFO") @@ -188,16 +186,6 @@ def main() -> None: env_var=f"{ENV_VAR_PREFIX}_INPUT_DIR", help="Directory containing STL files to be checked", ) - parser.add_argument( - "-o", - "--output_dir", - required=False, - action="store", - type=str, - env_var=f"{ENV_VAR_PREFIX}_OUTPUT_DIR", - help="Directory to store the fixed STL files into", - default="", - ) parser.add_argument( "-u", "--imagekit_endpoint", @@ -236,15 +224,6 @@ def main() -> None: help="Print debug output to stdout", default=False, ) - parser.add_argument( - "-g", - "--github_step_summary", - required=False, - action="store_true", - env_var=f"{ENV_VAR_PREFIX}_GITHUB_STEP_SUMMARY", - help="Whether to output a step summary when running inside a github action", - default=False, - ) args: configargparse.Namespace = parser.parse_args() STLRotationChecker(args=args).run() diff --git a/voron_ci/tools/whitespace_checker.py b/voron_ci/tools/whitespace_checker.py index 4f1c5a7..e3671bf 100644 --- a/voron_ci/tools/whitespace_checker.py +++ b/voron_ci/tools/whitespace_checker.py @@ -23,9 +23,7 @@ class WhitespaceChecker: def __init__(self: Self, args: configargparse.Namespace) -> None: self.return_status: ReturnStatus = ReturnStatus.SUCCESS self.check_summary: list[list[str]] = [] - self.gh_helper: GithubActionHelper = GithubActionHelper( - output_path=args.output_dir, do_gh_step_summary=args.github_step_summary, ignore_warnings=args.ignore_warnings - ) + self.gh_helper: GithubActionHelper = GithubActionHelper(ignore_warnings=args.ignore_warnings) if args.verbose: logger.setLevel("INFO") @@ -92,16 +90,6 @@ def main() -> None: help="Directory containing files to be checked", default="", ) - parser.add_argument( - "-o", - "--output_dir", - required=False, - action="store", - type=str, - env_var=f"{ENV_VAR_PREFIX}_OUTPUT_DIR", - help="Output directory", - default="", - ) parser.add_argument( "-e", "--input_env_var", @@ -129,15 +117,6 @@ def main() -> None: help="Whether to ignore warnings and return a success exit code", default=False, ) - parser.add_argument( - "-g", - "--github_step_summary", - required=False, - action="store_true", - env_var=f"{ENV_VAR_PREFIX}_GITHUB_STEP_SUMMARY", - help="Whether to output a step summary when running inside a github action", - default=False, - ) args: configargparse.Namespace = parser.parse_args() WhitespaceChecker(args=args).run() diff --git a/voron_ci/utils/github_action_helper.py b/voron_ci/utils/github_action_helper.py index 2fd26e7..93dc0d7 100644 --- a/voron_ci/utils/github_action_helper.py +++ b/voron_ci/utils/github_action_helper.py @@ -17,6 +17,8 @@ STEP_SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY" OUTPUT_ENV_VAR = "GITHUB_OUTPUT" +VORON_CI_OUTPUT_ENV_VAR = "VORON_CI_OUTPUT" +VORON_CI_STEP_SUMMARY_ENV_VAR = "VORON_CI_STEP_SUMMARY" logger = logging.getLogger(__name__) @@ -30,11 +32,13 @@ class ActionResult: class GithubActionHelper: - def __init__(self: Self, *, output_path: Path | str | None = None, do_gh_step_summary: bool = False, ignore_warnings: bool = False) -> None: - self.output_path: Path | None = Path(output_path) if output_path else None + def __init__(self: Self, *, ignore_warnings: bool = False) -> None: + output_path_var: str | None = os.environ.get(VORON_CI_OUTPUT_ENV_VAR, None) + github_step_summary: str | None = os.environ.get(VORON_CI_STEP_SUMMARY_ENV_VAR, "False") + self.output_path: Path | None = Path(output_path_var) if output_path_var else None self.artifacts: dict[str, str | bytes] = {} self.github_output: StringIO = StringIO() - self.do_gh_step_summary: bool = do_gh_step_summary + self.do_gh_step_summary: bool = bool(github_step_summary) self.ignore_warnings: bool = ignore_warnings def set_output(self: Self, output: dict[str, str]) -> None: