Skip to content

feat: Adding New Parameters #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions aws_lambda_builders/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def main(): # pylint: disable=too-many-statements
optimizations=params["optimizations"],
options=params["options"],
mode=params.get("mode", None),
download_dependencies=params.get("download_dependencies", True),
dependencies_dir=params.get("dependencies_dir", None),
)

# Return a success response
Expand Down
12 changes: 12 additions & 0 deletions aws_lambda_builders/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def build(
options=None,
executable_search_paths=None,
mode=None,
download_dependencies=True,
dependencies_dir=None,
):
"""
Actually build the code by running workflows
Expand Down Expand Up @@ -105,6 +107,14 @@ def build(
:type mode: str
:param mode:
Optional, Mode the build should produce

:type mode: bool
:param download_dependencies:
Optional, Should download dependencies when building

:type mode: str
:param dependencies_dir:
Optional, Path to folder the dependencies should be downloaded to
"""

if not os.path.exists(scratch_dir):
Expand All @@ -120,6 +130,8 @@ def build(
options=options,
executable_search_paths=executable_search_paths,
mode=mode,
download_dependencies=download_dependencies,
dependencies_dir=dependencies_dir,
)

return workflow.run()
Expand Down
12 changes: 12 additions & 0 deletions aws_lambda_builders/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ def __init__(
optimizations=None,
options=None,
mode=BuildMode.RELEASE,
download_dependencies=True,
dependencies_dir=None,
):
"""
Initialize the builder with given arguments. These arguments together form the "public API" that each
Expand Down Expand Up @@ -182,6 +184,14 @@ def __init__(
:type mode: str
:param mode:
Optional, Mode the build should produce

:type mode: bool
:param download_dependencies:
Optional, Should download dependencies when building

:type mode: str
:param dependencies_dir:
Optional, Path to folder the dependencies should be downloaded to
"""

self.source_dir = source_dir
Expand All @@ -193,6 +203,8 @@ def __init__(
self.options = options
self.executable_search_paths = executable_search_paths
self.mode = mode
self.download_dependencies = download_dependencies
self.dependencies_dir = dependencies_dir

# Actions are registered by the subclasses as they seem fit
self.actions = []
Expand Down
4 changes: 4 additions & 0 deletions tests/functional/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def test_run_hello_workflow_with_backcompat(self, flavor, protocol_version):
"runtime": "ignored",
"optimizations": {},
"options": {},
"download_dependencies": False,
"dependencies_dir": "/ignored-dep",
},
}

Expand Down Expand Up @@ -138,6 +140,8 @@ def test_run_hello_workflow_incompatible(self, flavor):
"optimizations": {},
"options": {},
"executable_search_paths": [str(pathlib.Path(sys.executable).parent)],
"download_dependencies": False,
"dependencies_dir": "/ignored-dep",
},
}
)
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def __init__(
options=None,
executable_search_paths=None,
mode=None,
download_dependencies=True,
dependencies_dir=None,
):
super(MyWorkflow, self).__init__(
source_dir,
Expand All @@ -93,6 +95,8 @@ def __init__(
options=options,
executable_search_paths=executable_search_paths,
mode=mode,
download_dependencies=download_dependencies,
dependencies_dir=dependencies_dir,
)

# Don't load any other workflows. The above class declaration will automatically load the workflow into registry
Expand Down Expand Up @@ -136,6 +140,8 @@ def test_with_mocks(self, scratch_dir_exists, get_workflow_mock, importlib_mock,
options="options",
executable_search_paths="executable_search_paths",
mode=None,
download_dependencies=False,
dependencies_dir="dependency_folder",
)

workflow_cls.assert_called_with(
Expand All @@ -148,6 +154,8 @@ def test_with_mocks(self, scratch_dir_exists, get_workflow_mock, importlib_mock,
options="options",
executable_search_paths="executable_search_paths",
mode=None,
download_dependencies=False,
dependencies_dir="dependency_folder",
)
workflow_instance.run.assert_called_once()
os_mock.path.exists.assert_called_once_with("scratch_dir")
Expand Down