Skip to content

Commit 999ce90

Browse files
authored
fix: Rename provided go binary to bootstrap (#621)
* fix: Rename provided go binary to bootstrap * Format files * Windows compliant tests
1 parent ddd4adb commit 999ce90

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

aws_lambda_builders/workflows/go_modules/workflow.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ def __init__(
3232
handler = options.get("artifact_executable_name", None)
3333
trim_go_path = options.get("trim_go_path", False)
3434

35-
output_path = osutils.joinpath(artifacts_dir, handler)
35+
# For provided runtimes, the binary must be named "bootstrap"
36+
output_path = (
37+
osutils.joinpath(artifacts_dir, handler)
38+
if runtime != "provided"
39+
else osutils.joinpath(artifacts_dir, "bootstrap")
40+
)
3641

3742
builder = GoModulesBuilder(
3843
osutils,

tests/integration/workflows/go_modules/test_go.py

+17
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from pathlib2 import Path
99

1010
from unittest import TestCase
11+
from parameterized import parameterized
12+
1113

1214
from aws_lambda_builders.builder import LambdaBuilder
1315
from aws_lambda_builders.exceptions import WorkflowFailedError
@@ -196,3 +198,18 @@ def test_builds_project_with_nested_dir(self):
196198
expected_files = {"helloWorld"}
197199
output_files = set(os.listdir(self.artifacts_dir))
198200
self.assertEqual(expected_files, output_files)
201+
202+
@parameterized.expand([("provided", "bootstrap"), ("go1.x", "helloWorld")])
203+
def test_binary_named_bootstrap_for_provided_runtime(self, runtime, expected_binary):
204+
source_dir = os.path.join(self.TEST_DATA_FOLDER, "no-deps")
205+
self.builder.build(
206+
source_dir,
207+
self.artifacts_dir,
208+
self.scratch_dir,
209+
os.path.join(source_dir, "go.mod"),
210+
runtime=runtime,
211+
options={"artifact_executable_name": "helloWorld"},
212+
)
213+
expected_files = {expected_binary}
214+
output_files = set(os.listdir(self.artifacts_dir))
215+
self.assertEqual(expected_files, output_files)

tests/unit/workflows/go_modules/test_workflow.py

+15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from unittest import TestCase
2+
from pathlib import Path
23

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

28+
def test_workflow_sets_up_builder_actions_provided(self):
29+
workflow = GoModulesWorkflow(
30+
"source",
31+
"artifacts",
32+
"scratch_dir",
33+
"manifest",
34+
runtime="provided",
35+
options={"artifact_executable_name": "main"},
36+
)
37+
38+
self.assertEqual(len(workflow.actions), 1)
39+
self.assertIsInstance(workflow.actions[0], GoModulesBuildAction)
40+
self.assertEqual(workflow.actions[0].output_path, str(Path("artifacts", "bootstrap")))
41+
2742
def test_must_validate_architecture(self):
2843
workflow = GoModulesWorkflow(
2944
"source",

0 commit comments

Comments
 (0)