diff --git a/aws_lambda_builders/workflows/dotnet_clipackage/actions.py b/aws_lambda_builders/workflows/dotnet_clipackage/actions.py index accaaad08..dc918fa25 100644 --- a/aws_lambda_builders/workflows/dotnet_clipackage/actions.py +++ b/aws_lambda_builders/workflows/dotnet_clipackage/actions.py @@ -1,5 +1,5 @@ """ -Actions for Ruby dependency resolution with Bundler +Actions for .NET dependency resolution with CLI Package """ import os diff --git a/aws_lambda_builders/workflows/go_modules/builder.py b/aws_lambda_builders/workflows/go_modules/builder.py index 38e220768..9604c6f64 100644 --- a/aws_lambda_builders/workflows/go_modules/builder.py +++ b/aws_lambda_builders/workflows/go_modules/builder.py @@ -3,6 +3,7 @@ """ import logging +from aws_lambda_builders.workflow import BuildMode LOG = logging.getLogger(__name__) @@ -18,7 +19,7 @@ class GoModulesBuilder(object): LANGUAGE = "go" - def __init__(self, osutils, binaries): + def __init__(self, osutils, binaries, mode=BuildMode.RELEASE): """Initialize a GoModulesBuilder. :type osutils: :class:`lambda_builders.utils.OSUtils` @@ -30,6 +31,7 @@ def __init__(self, osutils, binaries): """ self.osutils = osutils self.binaries = binaries + self.mode = mode def build(self, source_dir_path, output_path): """Builds a go project onto an output path. @@ -44,7 +46,11 @@ def build(self, source_dir_path, output_path): env.update(self.osutils.environ) env.update({"GOOS": "linux", "GOARCH": "amd64"}) runtime_path = self.binaries[self.LANGUAGE].binary_path - cmd = [runtime_path, "build", "-o", output_path, source_dir_path] + cmd = [runtime_path, "build"] + if self.mode and self.mode.lower() == BuildMode.DEBUG: + LOG.debug("Debug build requested: Setting configuration to Debug") + cmd += ["-gcflags='all=-N -l'"] + cmd += ["-o", output_path, source_dir_path] p = self.osutils.popen(cmd, cwd=source_dir_path, env=env, stdout=self.osutils.pipe, stderr=self.osutils.pipe) out, err = p.communicate() diff --git a/aws_lambda_builders/workflows/go_modules/workflow.py b/aws_lambda_builders/workflows/go_modules/workflow.py index a80c1d65a..0932e81f5 100644 --- a/aws_lambda_builders/workflows/go_modules/workflow.py +++ b/aws_lambda_builders/workflows/go_modules/workflow.py @@ -15,7 +15,9 @@ class GoModulesWorkflow(BaseWorkflow): CAPABILITY = Capability(language="go", dependency_manager="modules", application_framework=None) - def __init__(self, source_dir, artifacts_dir, scratch_dir, manifest_path, runtime=None, osutils=None, **kwargs): + def __init__( + self, source_dir, artifacts_dir, scratch_dir, manifest_path, runtime=None, osutils=None, mode=None, **kwargs + ): super(GoModulesWorkflow, self).__init__( source_dir, artifacts_dir, scratch_dir, manifest_path, runtime=runtime, **kwargs @@ -29,7 +31,7 @@ def __init__(self, source_dir, artifacts_dir, scratch_dir, manifest_path, runtim output_path = osutils.joinpath(artifacts_dir, handler) - builder = GoModulesBuilder(osutils, binaries=self.binaries) + builder = GoModulesBuilder(osutils, binaries=self.binaries, mode=mode) self.actions = [GoModulesBuildAction(source_dir, output_path, builder)] def get_validators(self): diff --git a/tests/unit/workflows/go_modules/test_builder.py b/tests/unit/workflows/go_modules/test_builder.py index daea632c6..5e9b163a1 100644 --- a/tests/unit/workflows/go_modules/test_builder.py +++ b/tests/unit/workflows/go_modules/test_builder.py @@ -49,3 +49,14 @@ def test_raises_BuilderError_with_err_text_if_retcode_is_not_0(self): with self.assertRaises(BuilderError) as raised: self.under_test.build("source_dir", "output_path") self.assertEqual(raised.exception.args[0], "Builder Failed: some error text") + + def test_debug_configuration_set(self): + self.under_test = GoModulesBuilder(self.osutils, self.binaries, "Debug") + self.under_test.build("source_dir", "output_path") + self.osutils.popen.assert_called_with( + ["/path/to/go", "build", "-gcflags='all=-N -l'", "-o", "output_path", "source_dir"], + cwd="source_dir", + env={"GOOS": "linux", "GOARCH": "amd64"}, + stderr="PIPE", + stdout="PIPE", + )