From 831605c4e2718223921bc13b7a6ae4e79e7678a5 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Thu, 14 Nov 2024 19:49:34 -0600 Subject: [PATCH] feat(brew): automatically update and upgrade brew (#105) --- action/main.py | 25 +++++++++++++++++++++++++ tests/unit/test_main.py | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/action/main.py b/action/main.py index 76bce42b56d..87cb05d3a84 100644 --- a/action/main.py +++ b/action/main.py @@ -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( @@ -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') diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index 4bfafc42fcd..f84ed7801dc 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -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')