Skip to content

Commit 76d7836

Browse files
fix(release_homebrew): enable no installed dependents check (#15)
1 parent 06978e5 commit 76d7836

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

actions/release_homebrew/main.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,19 @@ def audit_formula(formula: str) -> bool:
284284

285285
def brew_upgrade() -> bool:
286286
print('Updating Homebrew')
287+
env = dict(
288+
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK='1'
289+
)
290+
291+
# combine with os environment
292+
env.update(os.environ)
293+
287294
result = _run_subprocess(
288295
args_list=[
289296
'brew',
290297
'update'
291-
]
298+
],
299+
env=env,
292300
)
293301
if not result:
294302
return False
@@ -298,7 +306,8 @@ def brew_upgrade() -> bool:
298306
args_list=[
299307
'brew',
300308
'upgrade'
301-
]
309+
],
310+
env=env,
302311
)
303312

304313

tests/release_homebrew/test_release_homebrew.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,14 @@ def test_process_input_formula_copy_failure(mock_exists, tmp_path, operating_sys
411411

412412
@patch('actions.release_homebrew.main._run_subprocess')
413413
def test_brew_upgrade_update_failure(mock_run):
414-
# Set up the mock to fail on brew update but not continue to brew upgrade
414+
# Set up the mock to fail on brew update
415415
def side_effect(args_list, *args, **kwargs):
416-
if 'update' in args_list:
416+
# Check if 'update' is in the args_list (which is a list)
417+
if args_list and 'update' in args_list:
418+
main.ERROR = True
417419
return False
418-
return True # Return True for any other commands
420+
# Should not reach here for upgrade since update failed
421+
return True
419422

420423
mock_run.side_effect = side_effect
421424

@@ -425,10 +428,10 @@ def side_effect(args_list, *args, **kwargs):
425428
# Assert that brew_upgrade returns False when update fails
426429
assert not result
427430

428-
# Verify that brew update was called
429-
update_call_made = any('update' in str(call) for call in mock_run.call_args_list)
430-
assert update_call_made
431+
# Verify that only one call was made (the update call)
432+
assert mock_run.call_count == 1
431433

432-
# Verify that brew upgrade was NOT called (execution should stop after update fails)
433-
upgrade_call_made = any('upgrade' in str(call) for call in mock_run.call_args_list)
434-
assert not upgrade_call_made
434+
# Verify that the call was for brew update
435+
call_args = mock_run.call_args_list[0][1]['args_list']
436+
assert 'update' in call_args
437+
assert 'upgrade' not in call_args

0 commit comments

Comments
 (0)