Skip to content

Commit

Permalink
feat(brew): automatically update and upgrade brew (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher authored Nov 15, 2024
1 parent c624c0f commit 831605c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions action/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,26 @@ def audit_formula(formula: str) -> bool:
)


def brew_upgrade() -> bool:
print('Updating Homebrew')
result = _run_subprocess(
args_list=[
'brew',
'update'
]
)
if not result:
return False

print('Upgrading Homebrew')
return _run_subprocess(
args_list=[
'brew',
'upgrade'
]
)


def install_formula(formula: str) -> bool:
print(f'Installing formula {formula}')
env = dict(
Expand Down Expand Up @@ -316,6 +336,11 @@ def main():
print('Skipping audit, install, and test')
return

upgrade_status = brew_upgrade()
if not upgrade_status:
print('::error:: Homebrew update or upgrade failed')
raise SystemExit(1)

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 @@ -110,6 +110,10 @@ def test_is_brew_installed(operating_system):
assert main.is_brew_installed()


def test_brew_upgrade():
assert main.brew_upgrade()


def test_audit_formula():
assert main.audit_formula(formula='hello_world')

Expand Down

0 comments on commit 831605c

Please sign in to comment.