Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-sam-cli-bot committed May 13, 2024
2 parents 008bf08 + 4b8b675 commit f9ffd0c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 14 deletions.
2 changes: 1 addition & 1 deletion aws_lambda_builders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# Changing version will trigger a new release!
# Please make the version change as the last step of your development.

__version__ = "1.49.0"
__version__ = "1.50.0"
RPC_PROTOCOL_VERSION = "0.3"
3 changes: 3 additions & 0 deletions aws_lambda_builders/workflows/python_pip/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ class DependencyBuilder(object):
"cp37m": (2, 17),
"cp38": (2, 26),
"cp39": (2, 26),
"cp310": (2, 26),
"cp311": (2, 26),
"cp312": (2, 26),
}
# Fallback version if we're on an unknown python version
# not in _RUNTIME_GLIBC.
Expand Down
6 changes: 6 additions & 0 deletions aws_lambda_builders/workflows/rust_cargo/cargo_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ def run(self, command, cwd):
if "RUST_LOG" not in os.environ:
os.environ["RUST_LOG"] = "debug"
LOG.debug("RUST_LOG environment variable set to `%s`", os.environ.get("RUST_LOG"))

if not os.getenv("CARGO_TARGET_DIR"):
# This results in the "target" dir being created under the member dir of a cargo workspace
# This is for supporting sam build for a Cargo Workspace project
os.environ["CARGO_TARGET_DIR"] = "target"

cargo_process = self._osutils.popen(
command,
stderr=subprocess.PIPE,
Expand Down
6 changes: 3 additions & 3 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage==7.4.4
coverage==7.5.1
flake8==3.8.4
pytest-cov==5.0.0

Expand All @@ -8,5 +8,5 @@ parameterized==0.9.0
pyelftools~=0.31 # Used to verify the generated Go binary architecture in integration tests (utils.py)

# formatter
black==24.4.0
ruff==0.4.1
black==24.4.2
ruff==0.4.3
40 changes: 30 additions & 10 deletions tests/integration/workflows/rust_cargo/test_rust_cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from aws_lambda_builders.workflows.rust_cargo.feature_flag import EXPERIMENTAL_FLAG_CARGO_LAMBDA


def rm_target_lambda(base):
shutil.rmtree(os.path.join(base, "target", "lambda"), ignore_errors=True)
def rm_target(base):
shutil.rmtree(os.path.join(base, "target"), ignore_errors=True)


class TestRustCargo(TestCase):
Expand Down Expand Up @@ -52,7 +52,7 @@ def test_failed_build_project(self):

def test_builds_hello_project(self):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "hello")
rm_target_lambda(source_dir)
rm_target(source_dir)

self.builder.build(
source_dir,
Expand All @@ -70,7 +70,7 @@ def test_builds_hello_project(self):

def test_builds_hello_project_with_artifact_name(self):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "hello")
rm_target_lambda(source_dir)
rm_target(source_dir)

self.builder.build(
source_dir,
Expand All @@ -89,7 +89,7 @@ def test_builds_hello_project_with_artifact_name(self):

def test_builds_hello_project_for_arm64(self):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "hello")
rm_target_lambda(source_dir)
rm_target(source_dir)

self.builder.build(
source_dir,
Expand All @@ -109,10 +109,10 @@ def test_builds_hello_project_for_arm64(self):

def test_builds_workspaces_project_with_bin_name(self):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "workspaces")
rm_target_lambda(source_dir)
rm_target(source_dir)

self.builder.build(
source_dir,
f"{source_dir}",
self.artifacts_dir,
self.scratch_dir,
os.path.join(source_dir, "Cargo.toml"),
Expand All @@ -125,10 +125,30 @@ def test_builds_workspaces_project_with_bin_name(self):
output_files = set(os.listdir(self.artifacts_dir))

self.assertEqual(expected_files, output_files)
self.assertIn("foo", os.listdir(os.path.join(source_dir, "target", "lambda")))

def test_builds_workspace_member(self):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "workspaces")
rm_target(source_dir)

self.builder.build(
f"{source_dir}/bar",
self.artifacts_dir,
self.scratch_dir,
os.path.join(source_dir, "Cargo.toml"),
runtime=self.runtime,
experimental_flags=[EXPERIMENTAL_FLAG_CARGO_LAMBDA],
)

expected_files = {"bootstrap"}
output_files = set(os.listdir(self.artifacts_dir))

self.assertEqual(expected_files, output_files)
self.assertIn("bar", os.path.join(source_dir, "bar", "target", "lambda"))

def test_builds_workspaces_project_with_package_option(self):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "workspaces")
rm_target_lambda(source_dir)
rm_target(source_dir)

self.builder.build(
source_dir,
Expand All @@ -147,7 +167,7 @@ def test_builds_workspaces_project_with_package_option(self):

def test_builds_multi_function_project_with_function_a(self):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "multi-binary")
rm_target_lambda(source_dir)
rm_target(source_dir)

self.builder.build(
source_dir,
Expand All @@ -166,7 +186,7 @@ def test_builds_multi_function_project_with_function_a(self):

def test_builds_multi_function_project_with_function_b(self):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "multi-binary")
rm_target_lambda(source_dir)
rm_target(source_dir)

self.builder.build(
source_dir,
Expand Down

0 comments on commit f9ffd0c

Please sign in to comment.