Skip to content

Commit 01ab121

Browse files
authored
feat: add new parameter to build in source and pass parameter into workflows (#416)
* add new parameter and pass into workflows * change default to None * update docstring
1 parent 5dac0dc commit 01ab121

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

aws_lambda_builders/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def main(): # pylint: disable=too-many-statements
131131
architecture=params.get("architecture", X86_64),
132132
is_building_layer=params.get("is_building_layer", False),
133133
experimental_flags=params.get("experimental_flags", []),
134+
build_in_source=params.get("build_in_source", None),
134135
)
135136

136137
# Return a success response

aws_lambda_builders/builder.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def build(
7171
architecture=X86_64,
7272
is_building_layer=False,
7373
experimental_flags=None,
74+
build_in_source=None,
7475
):
7576
# pylint: disable-msg=too-many-locals
7677
"""
@@ -138,6 +139,11 @@ def build(
138139
:type experimental_flags: list
139140
:param experimental_flags:
140141
List of strings, which will indicate enabled experimental flags for the current build session
142+
143+
:type build_in_source: Optional[bool]
144+
:param build_in_source:
145+
Optional, will execute the build operation in the source directory if True.
146+
141147
"""
142148

143149
if not os.path.exists(scratch_dir):
@@ -159,6 +165,7 @@ def build(
159165
architecture=architecture,
160166
is_building_layer=is_building_layer,
161167
experimental_flags=experimental_flags,
168+
build_in_source=build_in_source,
162169
)
163170

164171
return workflow.run()

aws_lambda_builders/workflow.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ def __init__(
165165
architecture=X86_64,
166166
is_building_layer=False,
167167
experimental_flags=None,
168+
build_in_source=None,
168169
):
169170
# pylint: disable-msg=too-many-locals
170171
"""
@@ -208,6 +209,9 @@ def __init__(
208209
209210
experimental_flags: list, optional
210211
List of strings, which will indicate enabled experimental flags for the current build session
212+
213+
build_in_source: Optional[bool]
214+
Optional, will execute the build operation in the source directory if True.
211215
"""
212216

213217
self.source_dir = source_dir
@@ -225,6 +229,7 @@ def __init__(
225229
self.architecture = architecture
226230
self.is_building_layer = is_building_layer
227231
self.experimental_flags = experimental_flags if experimental_flags else []
232+
self.build_in_source = build_in_source
228233

229234
# Actions are registered by the subclasses as they seem fit
230235
self.actions = []

tests/functional/test_cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def test_run_hello_workflow_with_backcompat(self, flavor, protocol_version):
8383
"architecture": "x86_64",
8484
"is_building_layer": False,
8585
"experimental_flags": ["experimental"],
86+
"build_in_source": False,
8687
},
8788
}
8889

@@ -149,6 +150,7 @@ def test_run_hello_workflow_incompatible(self, flavor):
149150
"combine_dependencies": False,
150151
"is_building_layer": False,
151152
"experimental_flags": ["experimental"],
153+
"build_in_source": False,
152154
},
153155
}
154156
)

tests/unit/test_builder.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def setUp(self):
127127
[True, False], # combine_dependencies
128128
[True, False], # is_building_layer
129129
[None, [], ["a", "b"]], # experimental flags
130+
[True, False], # build_in_source
130131
)
131132
)
132133
@patch("aws_lambda_builders.builder.os")
@@ -139,6 +140,7 @@ def test_with_mocks(
139140
combine_dependencies,
140141
is_building_layer,
141142
experimental_flags,
143+
build_in_source,
142144
get_workflow_mock,
143145
os_mock,
144146
):
@@ -167,6 +169,7 @@ def test_with_mocks(
167169
combine_dependencies=combine_dependencies,
168170
is_building_layer=is_building_layer,
169171
experimental_flags=experimental_flags,
172+
build_in_source=build_in_source,
170173
)
171174

172175
workflow_cls.assert_called_with(
@@ -185,6 +188,7 @@ def test_with_mocks(
185188
combine_dependencies=combine_dependencies,
186189
is_building_layer=is_building_layer,
187190
experimental_flags=experimental_flags,
191+
build_in_source=build_in_source,
188192
)
189193
workflow_instance.run.assert_called_once()
190194
os_mock.path.exists.assert_called_once_with("scratch_dir")

0 commit comments

Comments
 (0)