From 6e4c769b0cc6e46d91c3dfd37a730dc481c05d2f Mon Sep 17 00:00:00 2001 From: Reed Hamilton Date: Tue, 9 Dec 2025 16:50:41 -0800 Subject: [PATCH] fix: remove deprecated --without option from ruby bundler --- .../workflows/ruby_bundler/actions.py | 12 +++--- .../workflows/ruby_bundler/test_actions.py | 16 ++++++-- .../workflows/ruby_bundler/test_bundler.py | 38 ++++++++----------- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/aws_lambda_builders/workflows/ruby_bundler/actions.py b/aws_lambda_builders/workflows/ruby_bundler/actions.py index 335a0afbb..b456bf0bf 100644 --- a/aws_lambda_builders/workflows/ruby_bundler/actions.py +++ b/aws_lambda_builders/workflows/ruby_bundler/actions.py @@ -28,7 +28,10 @@ def __init__(self, source_dir, subprocess_bundler): def execute(self): try: LOG.debug("Running bundle install in %s", self.source_dir) - self.subprocess_bundler.run(["install", "--without", "development", "test"], cwd=self.source_dir) + self.subprocess_bundler.run( + ["config", "set", "--local", "without", "development:test"], cwd=self.source_dir + ) + self.subprocess_bundler.run(["install"], cwd=self.source_dir) except BundlerExecutionError as ex: raise ActionFailedError(str(ex)) @@ -49,9 +52,8 @@ def __init__(self, source_dir, subprocess_bundler): def execute(self): try: - LOG.debug("Running bundle install --deployment in %s", self.source_dir) - self.subprocess_bundler.run( - ["install", "--deployment", "--without", "development", "test"], cwd=self.source_dir - ) + LOG.debug("Running bundle install with deployment enabled in %s", self.source_dir) + self.subprocess_bundler.run(["config", "set", "--local", "deployment", "true"], cwd=self.source_dir) + self.subprocess_bundler.run(["install"], cwd=self.source_dir) except BundlerExecutionError as ex: raise ActionFailedError(str(ex)) diff --git a/tests/unit/workflows/ruby_bundler/test_actions.py b/tests/unit/workflows/ruby_bundler/test_actions.py index 3a95e4f22..cbea263eb 100644 --- a/tests/unit/workflows/ruby_bundler/test_actions.py +++ b/tests/unit/workflows/ruby_bundler/test_actions.py @@ -1,5 +1,5 @@ from unittest import TestCase -from unittest.mock import patch +from unittest.mock import patch, call from aws_lambda_builders.actions import ActionFailedError from aws_lambda_builders.workflows.ruby_bundler.actions import RubyBundlerInstallAction, RubyBundlerVendorAction @@ -12,7 +12,12 @@ def test_runs_bundle_install(self, SubprocessBundlerMock): subprocess_bundler = SubprocessBundlerMock.return_value action = RubyBundlerInstallAction("source_dir", subprocess_bundler=subprocess_bundler) action.execute() - subprocess_bundler.run.assert_called_with(["install", "--without", "development", "test"], cwd="source_dir") + subprocess_bundler.run.assert_has_calls( + [ + call(["config", "set", "--local", "without", "development:test"], cwd="source_dir"), + call(["install"], cwd="source_dir"), + ] + ) @patch("aws_lambda_builders.workflows.ruby_bundler.bundler.SubprocessBundler") def test_raises_action_failed_on_failure(self, SubprocessBundlerMock): @@ -31,8 +36,11 @@ def test_runs_bundle_install_deployment(self, SubprocessBundlerMock): subprocess_bundler = SubprocessBundlerMock.return_value action = RubyBundlerVendorAction("source_dir", subprocess_bundler=subprocess_bundler) action.execute() - subprocess_bundler.run.assert_called_with( - ["install", "--deployment", "--without", "development", "test"], cwd="source_dir" + subprocess_bundler.run.assert_has_calls( + [ + call(["config", "set", "--local", "deployment", "true"], cwd="source_dir"), + call(["install"], cwd="source_dir"), + ] ) @patch("aws_lambda_builders.workflows.ruby_bundler.bundler.SubprocessBundler") diff --git a/tests/unit/workflows/ruby_bundler/test_bundler.py b/tests/unit/workflows/ruby_bundler/test_bundler.py index 1de3bf0ae..4a5515cca 100644 --- a/tests/unit/workflows/ruby_bundler/test_bundler.py +++ b/tests/unit/workflows/ruby_bundler/test_bundler.py @@ -31,46 +31,38 @@ def setUp(self, OSUtilMock): def test_run_executes_bundler_on_nixes(self): self.osutils.is_windows.side_effect = [False] self.under_test = SubprocessBundler(self.osutils) - self.under_test.run(["install", "--without", "development", "test"]) - self.osutils.popen.assert_called_with( - ["bundle", "install", "--without", "development", "test"], cwd=None, stderr="PIPE", stdout="PIPE" - ) + self.under_test.run(["install"]) + self.osutils.popen.assert_called_with(["bundle", "install"], cwd=None, stderr="PIPE", stdout="PIPE") def test_run_executes_bundler_on_windows(self): self.osutils.is_windows.side_effect = [True] self.under_test = SubprocessBundler(self.osutils) - self.under_test.run(["install", "--without", "development", "test"]) - self.osutils.popen.assert_called_with( - ["bundler.bat", "install", "--without", "development", "test"], cwd=None, stderr="PIPE", stdout="PIPE" - ) + self.under_test.run(["install"]) + self.osutils.popen.assert_called_with(["bundler.bat", "install"], cwd=None, stderr="PIPE", stdout="PIPE") def test_uses_custom_bundler_path_if_supplied(self): - self.under_test.run(["install", "--without", "development", "test"]) - self.osutils.popen.assert_called_with( - ["/a/b/c/bundle", "install", "--without", "development", "test"], cwd=None, stderr="PIPE", stdout="PIPE" - ) + self.under_test.run(["install"]) + self.osutils.popen.assert_called_with(["/a/b/c/bundle", "install"], cwd=None, stderr="PIPE", stdout="PIPE") def test_uses_cwd_if_supplied(self): - self.under_test.run(["install", "--without", "development", "test"], cwd="/a/cwd") - self.osutils.popen.assert_called_with( - ["/a/b/c/bundle", "install", "--without", "development", "test"], cwd="/a/cwd", stderr="PIPE", stdout="PIPE" - ) + self.under_test.run(["install"], cwd="/a/cwd") + self.osutils.popen.assert_called_with(["/a/b/c/bundle", "install"], cwd="/a/cwd", stderr="PIPE", stdout="PIPE") def test_returns_popen_out_decoded_if_retcode_is_0(self): self.popen.out = b"some encoded text\n\n" - result = self.under_test.run(["install", "--without", "development", "test"]) + result = self.under_test.run(["install"]) self.assertEqual(result, "some encoded text") def test_logs_warning_when_gemfile_missing(self): self.popen.returncode = 10 with patch.object(logger, "warning") as mock_warning: - self.under_test.run(["install", "--without", "development", "test"]) + self.under_test.run(["install"]) mock_warning.assert_called_once_with("Gemfile not found. Continuing the build without dependencies.") def test_bundle_file_removed_if_generated(self): self.popen.returncode = 10 self.osutils.directory_exists.return_value = True - self.under_test.run(["install", "--without", "development", "test"]) + self.under_test.run(["install"]) self.osutils.get_bundle_dir.assert_called_once() self.osutils.remove_directory.assert_called_once() @@ -79,7 +71,7 @@ def test_raises_BundlerExecutionError_with_stdout_text_if_retcode_is_not_0(self) self.popen.out = b"some error text\n\n" self.popen.err = b"" with self.assertRaises(BundlerExecutionError) as raised: - self.under_test.run(["install", "--without", "development", "test"]) + self.under_test.run(["install"]) self.assertEqual(raised.exception.args[0], "Bundler Failed: some error text") def test_raises_BundlerExecutionError_with_stderr_text_if_retcode_is_not_0(self): @@ -87,7 +79,7 @@ def test_raises_BundlerExecutionError_with_stderr_text_if_retcode_is_not_0(self) self.popen.err = b"some error text\n\n" self.popen.out = b"" with self.assertRaises(BundlerExecutionError) as raised: - self.under_test.run(["install", "--without", "development", "test"]) + self.under_test.run(["install"]) self.assertEqual(raised.exception.args[0], "Bundler Failed: some error text") def test_raises_BundlerExecutionError_with_both_stderr_and_stdout_text_if_retcode_is_not_0(self): @@ -95,14 +87,14 @@ def test_raises_BundlerExecutionError_with_both_stderr_and_stdout_text_if_retcod self.popen.err = b"some error text from stderr\n\n" self.popen.out = b"some error text from stdout\n\n" with self.assertRaises(BundlerExecutionError) as raised: - self.under_test.run(["install", "--without", "development", "test"]) + self.under_test.run(["install"]) self.assertEqual( raised.exception.args[0], f"Bundler Failed: some error text from stdout{linesep}some error text from stderr" ) def test_raises_ValueError_if_args_not_a_list(self): with self.assertRaises(ValueError) as raised: - self.under_test.run(("install", "--without", "development", "test")) + self.under_test.run("install") self.assertEqual(raised.exception.args[0], "args must be a list") def test_raises_ValueError_if_args_empty(self):