Skip to content

Commit

Permalink
fix: Set output folder and summary switch globally
Browse files Browse the repository at this point in the history
  • Loading branch information
FHeilmann committed Dec 11, 2023
1 parent 7464dbe commit 9e15e9c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 114 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/test_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 3 additions & 14 deletions voron_ci/tools/mod_structure_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]] = []

Expand Down Expand Up @@ -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",
Expand All @@ -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()
Expand Down
21 changes: 1 addition & 20 deletions voron_ci/tools/readme_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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",
Expand Down
23 changes: 1 addition & 22 deletions voron_ci/tools/stl_corruption_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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",
Expand All @@ -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()

Expand Down
23 changes: 1 addition & 22 deletions voron_ci/tools/stl_rotation_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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()

Expand Down
23 changes: 1 addition & 22 deletions voron_ci/tools/whitespace_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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()

Expand Down
10 changes: 7 additions & 3 deletions voron_ci/utils/github_action_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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:
Expand Down

0 comments on commit 9e15e9c

Please sign in to comment.