diff --git a/action/main.py b/action/main.py index 87cb05d3a84..aed6493c1c6 100644 --- a/action/main.py +++ b/action/main.py @@ -40,6 +40,7 @@ def _run_subprocess( args_list: list, cwd: Optional[str] = None, env: Optional[Mapping] = None, + ignore_error: bool = False, ) -> bool: global ERROR if cwd: @@ -77,12 +78,15 @@ def _run_subprocess( exit_code = process.wait() - if exit_code != 0: + if exit_code == 0: + return True + + print(f'::error:: Process [{args_list}] failed with exit code', exit_code) + if not ignore_error: ERROR = True - print(f'::error:: Process [{args_list}] failed with exit code', exit_code) return False - else: - return True + + return True def set_github_action_output(output_name: str, output_value: str): @@ -294,6 +298,29 @@ def brew_upgrade() -> bool: ) +def brew_debug() -> bool: + # run brew config + print('Running `brew config`') + result = _run_subprocess( + args_list=[ + 'brew', + 'config', + ], + ) + + # run brew doctor + print('Running `brew doctor`') + _run_subprocess( + args_list=[ + 'brew', + 'doctor', + ], + ignore_error=True, + ) + + return result + + def install_formula(formula: str) -> bool: print(f'Installing formula {formula}') env = dict( @@ -341,6 +368,10 @@ def main(): print('::error:: Homebrew update or upgrade failed') raise SystemExit(1) + if not brew_debug(): + print('::error:: Homebrew debug failed') + raise SystemExit(1) + if not audit_formula(formula): print(f'::error:: Formula {formula} failed audit') FAILURES.append('audit') diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index f84ed7801dc..d949efae3e9 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -114,6 +114,10 @@ def test_brew_upgrade(): assert main.brew_upgrade() +def test_brew_debug(): + assert main.brew_debug() + + def test_audit_formula(): assert main.audit_formula(formula='hello_world')