Skip to content

Commit efda1dd

Browse files
authored
fix: remove deprecated --without option from ruby bundler (#808)
1 parent 719e7e9 commit efda1dd

3 files changed

Lines changed: 34 additions & 32 deletions

File tree

aws_lambda_builders/workflows/ruby_bundler/actions.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ def __init__(self, source_dir, subprocess_bundler):
2828
def execute(self):
2929
try:
3030
LOG.debug("Running bundle install in %s", self.source_dir)
31-
self.subprocess_bundler.run(["install", "--without", "development", "test"], cwd=self.source_dir)
31+
self.subprocess_bundler.run(
32+
["config", "set", "--local", "without", "development:test"], cwd=self.source_dir
33+
)
34+
self.subprocess_bundler.run(["install"], cwd=self.source_dir)
3235
except BundlerExecutionError as ex:
3336
raise ActionFailedError(str(ex))
3437

@@ -49,9 +52,8 @@ def __init__(self, source_dir, subprocess_bundler):
4952

5053
def execute(self):
5154
try:
52-
LOG.debug("Running bundle install --deployment in %s", self.source_dir)
53-
self.subprocess_bundler.run(
54-
["install", "--deployment", "--without", "development", "test"], cwd=self.source_dir
55-
)
55+
LOG.debug("Running bundle install with deployment enabled in %s", self.source_dir)
56+
self.subprocess_bundler.run(["config", "set", "--local", "deployment", "true"], cwd=self.source_dir)
57+
self.subprocess_bundler.run(["install"], cwd=self.source_dir)
5658
except BundlerExecutionError as ex:
5759
raise ActionFailedError(str(ex))

tests/unit/workflows/ruby_bundler/test_actions.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from unittest import TestCase
2-
from unittest.mock import patch
2+
from unittest.mock import patch, call
33

44
from aws_lambda_builders.actions import ActionFailedError
55
from aws_lambda_builders.workflows.ruby_bundler.actions import RubyBundlerInstallAction, RubyBundlerVendorAction
@@ -12,7 +12,12 @@ def test_runs_bundle_install(self, SubprocessBundlerMock):
1212
subprocess_bundler = SubprocessBundlerMock.return_value
1313
action = RubyBundlerInstallAction("source_dir", subprocess_bundler=subprocess_bundler)
1414
action.execute()
15-
subprocess_bundler.run.assert_called_with(["install", "--without", "development", "test"], cwd="source_dir")
15+
subprocess_bundler.run.assert_has_calls(
16+
[
17+
call(["config", "set", "--local", "without", "development:test"], cwd="source_dir"),
18+
call(["install"], cwd="source_dir"),
19+
]
20+
)
1621

1722
@patch("aws_lambda_builders.workflows.ruby_bundler.bundler.SubprocessBundler")
1823
def test_raises_action_failed_on_failure(self, SubprocessBundlerMock):
@@ -31,8 +36,11 @@ def test_runs_bundle_install_deployment(self, SubprocessBundlerMock):
3136
subprocess_bundler = SubprocessBundlerMock.return_value
3237
action = RubyBundlerVendorAction("source_dir", subprocess_bundler=subprocess_bundler)
3338
action.execute()
34-
subprocess_bundler.run.assert_called_with(
35-
["install", "--deployment", "--without", "development", "test"], cwd="source_dir"
39+
subprocess_bundler.run.assert_has_calls(
40+
[
41+
call(["config", "set", "--local", "deployment", "true"], cwd="source_dir"),
42+
call(["install"], cwd="source_dir"),
43+
]
3644
)
3745

3846
@patch("aws_lambda_builders.workflows.ruby_bundler.bundler.SubprocessBundler")

tests/unit/workflows/ruby_bundler/test_bundler.py

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,46 +31,38 @@ def setUp(self, OSUtilMock):
3131
def test_run_executes_bundler_on_nixes(self):
3232
self.osutils.is_windows.side_effect = [False]
3333
self.under_test = SubprocessBundler(self.osutils)
34-
self.under_test.run(["install", "--without", "development", "test"])
35-
self.osutils.popen.assert_called_with(
36-
["bundle", "install", "--without", "development", "test"], cwd=None, stderr="PIPE", stdout="PIPE"
37-
)
34+
self.under_test.run(["install"])
35+
self.osutils.popen.assert_called_with(["bundle", "install"], cwd=None, stderr="PIPE", stdout="PIPE")
3836

3937
def test_run_executes_bundler_on_windows(self):
4038
self.osutils.is_windows.side_effect = [True]
4139
self.under_test = SubprocessBundler(self.osutils)
42-
self.under_test.run(["install", "--without", "development", "test"])
43-
self.osutils.popen.assert_called_with(
44-
["bundler.bat", "install", "--without", "development", "test"], cwd=None, stderr="PIPE", stdout="PIPE"
45-
)
40+
self.under_test.run(["install"])
41+
self.osutils.popen.assert_called_with(["bundler.bat", "install"], cwd=None, stderr="PIPE", stdout="PIPE")
4642

4743
def test_uses_custom_bundler_path_if_supplied(self):
48-
self.under_test.run(["install", "--without", "development", "test"])
49-
self.osutils.popen.assert_called_with(
50-
["/a/b/c/bundle", "install", "--without", "development", "test"], cwd=None, stderr="PIPE", stdout="PIPE"
51-
)
44+
self.under_test.run(["install"])
45+
self.osutils.popen.assert_called_with(["/a/b/c/bundle", "install"], cwd=None, stderr="PIPE", stdout="PIPE")
5246

5347
def test_uses_cwd_if_supplied(self):
54-
self.under_test.run(["install", "--without", "development", "test"], cwd="/a/cwd")
55-
self.osutils.popen.assert_called_with(
56-
["/a/b/c/bundle", "install", "--without", "development", "test"], cwd="/a/cwd", stderr="PIPE", stdout="PIPE"
57-
)
48+
self.under_test.run(["install"], cwd="/a/cwd")
49+
self.osutils.popen.assert_called_with(["/a/b/c/bundle", "install"], cwd="/a/cwd", stderr="PIPE", stdout="PIPE")
5850

5951
def test_returns_popen_out_decoded_if_retcode_is_0(self):
6052
self.popen.out = b"some encoded text\n\n"
61-
result = self.under_test.run(["install", "--without", "development", "test"])
53+
result = self.under_test.run(["install"])
6254
self.assertEqual(result, "some encoded text")
6355

6456
def test_logs_warning_when_gemfile_missing(self):
6557
self.popen.returncode = 10
6658
with patch.object(logger, "warning") as mock_warning:
67-
self.under_test.run(["install", "--without", "development", "test"])
59+
self.under_test.run(["install"])
6860
mock_warning.assert_called_once_with("Gemfile not found. Continuing the build without dependencies.")
6961

7062
def test_bundle_file_removed_if_generated(self):
7163
self.popen.returncode = 10
7264
self.osutils.directory_exists.return_value = True
73-
self.under_test.run(["install", "--without", "development", "test"])
65+
self.under_test.run(["install"])
7466
self.osutils.get_bundle_dir.assert_called_once()
7567
self.osutils.remove_directory.assert_called_once()
7668

@@ -79,30 +71,30 @@ def test_raises_BundlerExecutionError_with_stdout_text_if_retcode_is_not_0(self)
7971
self.popen.out = b"some error text\n\n"
8072
self.popen.err = b""
8173
with self.assertRaises(BundlerExecutionError) as raised:
82-
self.under_test.run(["install", "--without", "development", "test"])
74+
self.under_test.run(["install"])
8375
self.assertEqual(raised.exception.args[0], "Bundler Failed: some error text")
8476

8577
def test_raises_BundlerExecutionError_with_stderr_text_if_retcode_is_not_0(self):
8678
self.popen.returncode = 1
8779
self.popen.err = b"some error text\n\n"
8880
self.popen.out = b""
8981
with self.assertRaises(BundlerExecutionError) as raised:
90-
self.under_test.run(["install", "--without", "development", "test"])
82+
self.under_test.run(["install"])
9183
self.assertEqual(raised.exception.args[0], "Bundler Failed: some error text")
9284

9385
def test_raises_BundlerExecutionError_with_both_stderr_and_stdout_text_if_retcode_is_not_0(self):
9486
self.popen.returncode = 1
9587
self.popen.err = b"some error text from stderr\n\n"
9688
self.popen.out = b"some error text from stdout\n\n"
9789
with self.assertRaises(BundlerExecutionError) as raised:
98-
self.under_test.run(["install", "--without", "development", "test"])
90+
self.under_test.run(["install"])
9991
self.assertEqual(
10092
raised.exception.args[0], f"Bundler Failed: some error text from stdout{linesep}some error text from stderr"
10193
)
10294

10395
def test_raises_ValueError_if_args_not_a_list(self):
10496
with self.assertRaises(ValueError) as raised:
105-
self.under_test.run(("install", "--without", "development", "test"))
97+
self.under_test.run("install")
10698
self.assertEqual(raised.exception.args[0], "args must be a list")
10799

108100
def test_raises_ValueError_if_args_empty(self):

0 commit comments

Comments
 (0)