Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions action/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
args_list: list,
cwd: Optional[str] = None,
env: Optional[Mapping] = None,
ignore_error: bool = False,
) -> bool:
global ERROR
if cwd:
Expand Down Expand Up @@ -77,12 +78,15 @@

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):
Expand Down Expand Up @@ -294,6 +298,29 @@
)


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(
Expand Down Expand Up @@ -341,6 +368,10 @@
print('::error:: Homebrew update or upgrade failed')
raise SystemExit(1)

if not brew_debug():
print('::error:: Homebrew debug failed')
raise SystemExit(1)

Check warning on line 373 in action/main.py

View check run for this annotation

Codecov / codecov/patch

action/main.py#L372-L373

Added lines #L372 - L373 were not covered by tests

if not audit_formula(formula):
print(f'::error:: Formula {formula} failed audit')
FAILURES.append('audit')
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
Loading