Skip to content
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
7 changes: 6 additions & 1 deletion aws_lambda_builders/workflows/go_modules/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ def __init__(
handler = options.get("artifact_executable_name", None)
trim_go_path = options.get("trim_go_path", False)

output_path = osutils.joinpath(artifacts_dir, handler)
# For provided runtimes, the binary must be named "bootstrap"
output_path = (
osutils.joinpath(artifacts_dir, handler)
if runtime != "provided"
else osutils.joinpath(artifacts_dir, "bootstrap")
)

builder = GoModulesBuilder(
osutils,
Expand Down
17 changes: 17 additions & 0 deletions tests/integration/workflows/go_modules/test_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from pathlib2 import Path

from unittest import TestCase
from parameterized import parameterized


from aws_lambda_builders.builder import LambdaBuilder
from aws_lambda_builders.exceptions import WorkflowFailedError
Expand Down Expand Up @@ -196,3 +198,18 @@ def test_builds_project_with_nested_dir(self):
expected_files = {"helloWorld"}
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)

@parameterized.expand([("provided", "bootstrap"), ("go1.x", "helloWorld")])
def test_binary_named_bootstrap_for_provided_runtime(self, runtime, expected_binary):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "no-deps")
self.builder.build(
source_dir,
self.artifacts_dir,
self.scratch_dir,
os.path.join(source_dir, "go.mod"),
runtime=runtime,
options={"artifact_executable_name": "helloWorld"},
)
expected_files = {expected_binary}
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)
15 changes: 15 additions & 0 deletions tests/unit/workflows/go_modules/test_workflow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from unittest import TestCase
from pathlib import Path

from aws_lambda_builders.workflows.go_modules.workflow import GoModulesWorkflow
from aws_lambda_builders.workflows.go_modules.actions import GoModulesBuildAction
Expand All @@ -24,6 +25,20 @@ def test_workflow_sets_up_builder_actions(self):
self.assertEqual(len(workflow.actions), 1)
self.assertIsInstance(workflow.actions[0], GoModulesBuildAction)

def test_workflow_sets_up_builder_actions_provided(self):
workflow = GoModulesWorkflow(
"source",
"artifacts",
"scratch_dir",
"manifest",
runtime="provided",
options={"artifact_executable_name": "main"},
)

self.assertEqual(len(workflow.actions), 1)
self.assertIsInstance(workflow.actions[0], GoModulesBuildAction)
self.assertEqual(workflow.actions[0].output_path, str(Path("artifacts", "bootstrap")))

def test_must_validate_architecture(self):
workflow = GoModulesWorkflow(
"source",
Expand Down