From 460d6b3a8682172cbde3b6f30cf4c38f65c08d74 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 09:38:53 -0700 Subject: [PATCH 1/6] chore(deps-dev): bump ruff from 0.3.4 to 0.3.5 in /requirements (#636) Bumps [ruff](https://github.com/astral-sh/ruff) from 0.3.4 to 0.3.5. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.3.4...v0.3.5) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 6a4d6e2e0..6a3458039 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -9,4 +9,4 @@ pyelftools~=0.31 # Used to verify the generated Go binary architecture in integr # formatter black==24.3.0 -ruff==0.3.4 +ruff==0.3.5 From f37e0985a3769298fa69f634829e0b05d1c5e0b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:28:51 -0700 Subject: [PATCH 2/6] chore(deps-dev): bump black from 24.3.0 to 24.4.0 in /requirements (#638) Bumps [black](https://github.com/psf/black) from 24.3.0 to 24.4.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/24.3.0...24.4.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 6a3458039..8d57bc638 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -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.3.0 +black==24.4.0 ruff==0.3.5 From 6080161543abd5a0cb7b9ce3d2c88c11fc262f7c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Apr 2024 09:29:43 -0700 Subject: [PATCH 3/6] chore(deps-dev): bump ruff from 0.3.5 to 0.3.7 in /requirements (#637) Bumps [ruff](https://github.com/astral-sh/ruff) from 0.3.5 to 0.3.7. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.3.5...v0.3.7) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 8d57bc638..8a2453120 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -9,4 +9,4 @@ pyelftools~=0.31 # Used to verify the generated Go binary architecture in integr # formatter black==24.4.0 -ruff==0.3.5 +ruff==0.3.7 From dc1aa0a0e5dc04ac049632e05f9300a38d4df298 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 10:33:03 -0700 Subject: [PATCH 4/6] chore(deps-dev): bump ruff from 0.3.7 to 0.4.1 in /requirements (#639) Bumps [ruff](https://github.com/astral-sh/ruff) from 0.3.7 to 0.4.1. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.3.7...v0.4.1) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 8a2453120..aaa78e54d 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -9,4 +9,4 @@ pyelftools~=0.31 # Used to verify the generated Go binary architecture in integr # formatter black==24.4.0 -ruff==0.3.7 +ruff==0.4.1 From e5b0f83564b1743ec66568077c10da08a425f340 Mon Sep 17 00:00:00 2001 From: sidhujus <105385029+sidhujus@users.noreply.github.com> Date: Mon, 29 Apr 2024 13:23:17 -0700 Subject: [PATCH 5/6] fix: specify glibc version when building with cargo lambda for provided.al2 (#640) * specify glibc version for cargo lambda * remove debug log * fix lint error * pr feedback * formatting fix --- aws_lambda_builders/builder.py | 2 + aws_lambda_builders/workflow.py | 2 + .../workflows/rust_cargo/actions.py | 14 +++++- .../workflows/rust_cargo/workflow.py | 13 ++++- tests/unit/test_builder.py | 1 + .../unit/workflows/rust_cargo/test_actions.py | 47 +++++++++++++++---- 6 files changed, 66 insertions(+), 13 deletions(-) diff --git a/aws_lambda_builders/builder.py b/aws_lambda_builders/builder.py index 338e0a3f1..e47c299e9 100644 --- a/aws_lambda_builders/builder.py +++ b/aws_lambda_builders/builder.py @@ -60,6 +60,7 @@ def build( scratch_dir, manifest_path, runtime=None, + unpatched_runtime=None, optimizations=None, options=None, executable_search_paths=None, @@ -154,6 +155,7 @@ def build( scratch_dir, manifest_path, runtime=runtime, + unpatched_runtime=unpatched_runtime, optimizations=optimizations, options=options, executable_search_paths=executable_search_paths, diff --git a/aws_lambda_builders/workflow.py b/aws_lambda_builders/workflow.py index ab6c5c713..d8897882e 100644 --- a/aws_lambda_builders/workflow.py +++ b/aws_lambda_builders/workflow.py @@ -201,6 +201,7 @@ def __init__( is_building_layer=False, experimental_flags=None, build_in_source=None, + unpatched_runtime=None, ): # pylint: disable-msg=too-many-locals """ @@ -263,6 +264,7 @@ def __init__( self.combine_dependencies = combine_dependencies self.architecture = architecture self.is_building_layer = is_building_layer + self.unpatched_runtime = unpatched_runtime self.experimental_flags = experimental_flags if experimental_flags else [] # this represents where the build/install happens, not the final output directory (that's the artifacts_dir) diff --git a/aws_lambda_builders/workflows/rust_cargo/actions.py b/aws_lambda_builders/workflows/rust_cargo/actions.py index 9ca568fb6..82cac9018 100644 --- a/aws_lambda_builders/workflows/rust_cargo/actions.py +++ b/aws_lambda_builders/workflows/rust_cargo/actions.py @@ -26,6 +26,7 @@ def __init__( binaries, mode, subprocess_cargo_lambda, + runtime=None, architecture=X86_64, handler=None, flags=None, @@ -68,18 +69,27 @@ def __init__( self._flags = flags self._architecture = architecture self._subprocess_cargo_lambda = subprocess_cargo_lambda + self._runtime = runtime def build_command(self): cmd = [self._binaries["cargo"].binary_path, "lambda", "build"] if self._mode != BuildMode.DEBUG: cmd.append("--release") - if self._architecture == ARM64: + # Provided.al2 runtime only has GLIB_2.26 and cargo lambda builds with a higher version by default + if self._runtime == "provided.al2": + if self._architecture == ARM64: + # We cant use the --arm shortcut because then the incorrect version of GLIBC is used + cmd.append("--target") + cmd.append("aarch64-unknown-linux-gnu.2.26") + if self._architecture == X86_64: + cmd.append("--target") + cmd.append("x86_64-unknown-linux-gnu.2.26") + elif self._architecture == ARM64: cmd.append("--arm64") if self._handler: cmd.extend(["--bin", self._handler]) if self._flags: cmd.extend(self._flags) - return cmd def execute(self): diff --git a/aws_lambda_builders/workflows/rust_cargo/workflow.py b/aws_lambda_builders/workflows/rust_cargo/workflow.py index 80ea11b09..a27437479 100644 --- a/aws_lambda_builders/workflows/rust_cargo/workflow.py +++ b/aws_lambda_builders/workflows/rust_cargo/workflow.py @@ -22,7 +22,17 @@ class RustCargoLambdaWorkflow(BaseWorkflow): SUPPORTED_MANIFESTS = ["Cargo.toml"] - def __init__(self, source_dir, artifacts_dir, scratch_dir, manifest_path, runtime=None, mode=None, **kwargs): + def __init__( + self, + source_dir, + artifacts_dir, + scratch_dir, + manifest_path, + runtime=None, + unpatched_runtime=None, + mode=None, + **kwargs, + ): super(RustCargoLambdaWorkflow, self).__init__( source_dir, artifacts_dir, scratch_dir, manifest_path, runtime=runtime, **kwargs ) @@ -43,6 +53,7 @@ def __init__(self, source_dir, artifacts_dir, scratch_dir, manifest_path, runtim self.binaries, mode, subprocess_cargo_lambda, + unpatched_runtime, self.architecture, handler, flags, diff --git a/tests/unit/test_builder.py b/tests/unit/test_builder.py index ed04d6faa..9dad6d80b 100644 --- a/tests/unit/test_builder.py +++ b/tests/unit/test_builder.py @@ -178,6 +178,7 @@ def test_with_mocks( "manifest_path", architecture="arm64", runtime="runtime", + unpatched_runtime=None, optimizations="optimizations", options="options", executable_search_paths="executable_search_paths", diff --git a/tests/unit/workflows/rust_cargo/test_actions.py b/tests/unit/workflows/rust_cargo/test_actions.py index eba8fe649..6e286ae4a 100644 --- a/tests/unit/workflows/rust_cargo/test_actions.py +++ b/tests/unit/workflows/rust_cargo/test_actions.py @@ -1,5 +1,6 @@ from unittest import TestCase from unittest.mock import patch +from parameterized import parameterized import io import logging import os @@ -43,9 +44,35 @@ def which(cmd, executable_search_paths): proc = SubprocessCargoLambda(which=which, osutils=self.osutils) self.subprocess_cargo_lambda = proc + @parameterized.expand( + [ + ("provided.al2", "x86_64", "x86_64-unknown-linux-gnu.2.26"), + ("provided.al2", "arm64", "aarch64-unknown-linux-gnu.2.26"), + ] + ) + def test_release_build_cargo_command_with_correct_targets(self, runtime, architecture, expected_target): + cargo = BinaryPath(None, None, None, binary_path="path/to/cargo") + action = RustCargoLambdaBuildAction( + "source_dir", {"cargo": cargo}, None, self.subprocess_cargo_lambda, runtime, architecture + ) + self.assertEqual( + action.build_command(), + ["path/to/cargo", "lambda", "build", "--release", "--target", expected_target], + ) + + def test_release_build_cargo_command_for_provided_al2023(self): + cargo = BinaryPath(None, None, None, binary_path="path/to/cargo") + action = RustCargoLambdaBuildAction( + "source_dir", {"cargo": cargo}, None, self.subprocess_cargo_lambda, "provided.al2023" + ) + self.assertEqual( + action.build_command(), + ["path/to/cargo", "lambda", "build", "--release"], + ) + def test_release_build_cargo_command_without_release_mode(self): cargo = BinaryPath(None, None, None, binary_path="path/to/cargo") - action = RustCargoLambdaBuildAction("source_dir", {"cargo": cargo}, None, self.subprocess_cargo_lambda) + action = RustCargoLambdaBuildAction("source_dir", {"cargo": cargo}, None, None, self.subprocess_cargo_lambda) self.assertEqual( action.build_command(), ["path/to/cargo", "lambda", "build", "--release"], @@ -54,7 +81,7 @@ def test_release_build_cargo_command_without_release_mode(self): def test_release_build_cargo_command(self): cargo = BinaryPath(None, None, None, binary_path="path/to/cargo") action = RustCargoLambdaBuildAction( - "source_dir", {"cargo": cargo}, BuildMode.RELEASE, self.subprocess_cargo_lambda + "source_dir", {"cargo": cargo}, BuildMode.RELEASE, None, self.subprocess_cargo_lambda ) self.assertEqual( action.build_command(), @@ -64,7 +91,7 @@ def test_release_build_cargo_command(self): def test_release_build_cargo_command_with_target(self): cargo = BinaryPath(None, None, None, binary_path="path/to/cargo") action = RustCargoLambdaBuildAction( - "source_dir", {"cargo": cargo}, BuildMode.RELEASE, self.subprocess_cargo_lambda, "arm64" + "source_dir", {"cargo": cargo}, BuildMode.RELEASE, None, self.subprocess_cargo_lambda, "arm64" ) self.assertEqual( action.build_command(), @@ -74,7 +101,7 @@ def test_release_build_cargo_command_with_target(self): def test_debug_build_cargo_command(self): cargo = BinaryPath(None, None, None, binary_path="path/to/cargo") action = RustCargoLambdaBuildAction( - "source_dir", {"cargo": cargo}, BuildMode.DEBUG, self.subprocess_cargo_lambda + "source_dir", {"cargo": cargo}, BuildMode.DEBUG, None, self.subprocess_cargo_lambda ) self.assertEqual( action.build_command(), @@ -84,7 +111,7 @@ def test_debug_build_cargo_command(self): def test_debug_build_cargo_command_with_architecture(self): cargo = BinaryPath(None, None, None, binary_path="path/to/cargo") action = RustCargoLambdaBuildAction( - "source_dir", {"cargo": cargo}, BuildMode.DEBUG, self.subprocess_cargo_lambda, "arm64" + "source_dir", {"cargo": cargo}, BuildMode.DEBUG, None, self.subprocess_cargo_lambda, "arm64" ) self.assertEqual( action.build_command(), @@ -95,7 +122,7 @@ def test_debug_build_cargo_command_with_flags(self): cargo = BinaryPath(None, None, None, binary_path="path/to/cargo") flags = ["--package", "package-in-workspace"] action = RustCargoLambdaBuildAction( - "source_dir", {"cargo": cargo}, BuildMode.DEBUG, self.subprocess_cargo_lambda, "arm64", flags=flags + "source_dir", {"cargo": cargo}, BuildMode.DEBUG, None, self.subprocess_cargo_lambda, "arm64", flags=flags ) self.assertEqual( action.build_command(), @@ -105,7 +132,7 @@ def test_debug_build_cargo_command_with_flags(self): def test_debug_build_cargo_command_with_handler(self): cargo = BinaryPath(None, None, None, binary_path="path/to/cargo") action = RustCargoLambdaBuildAction( - "source_dir", {"cargo": cargo}, BuildMode.DEBUG, self.subprocess_cargo_lambda, "arm64", handler="foo" + "source_dir", {"cargo": cargo}, BuildMode.DEBUG, None, self.subprocess_cargo_lambda, "arm64", handler="foo" ) self.assertEqual( action.build_command(), @@ -115,7 +142,7 @@ def test_debug_build_cargo_command_with_handler(self): def test_execute_happy_path(self): cargo = BinaryPath(None, None, None, binary_path="path/to/cargo") action = RustCargoLambdaBuildAction( - "source_dir", {"cargo": cargo}, BuildMode.RELEASE, self.subprocess_cargo_lambda + "source_dir", {"cargo": cargo}, BuildMode.RELEASE, self.subprocess_cargo_lambda, None ) action.execute() @@ -125,7 +152,7 @@ def test_execute_cargo_build_fail(self): cargo = BinaryPath(None, None, None, binary_path="path/to/cargo") action = RustCargoLambdaBuildAction( - "source_dir", {"cargo": cargo}, BuildMode.RELEASE, self.subprocess_cargo_lambda + "source_dir", {"cargo": cargo}, BuildMode.RELEASE, self.subprocess_cargo_lambda, None ) with self.assertRaises(ActionFailedError) as err_assert: action.execute() @@ -136,7 +163,7 @@ def test_execute_happy_with_logger(self): with patch.object(LOG, "debug") as mock_warning: cargo = BinaryPath(None, None, None, binary_path="path/to/cargo") action = RustCargoLambdaBuildAction( - "source_dir", {"cargo": cargo}, BuildMode.RELEASE, self.subprocess_cargo_lambda + "source_dir", {"cargo": cargo}, BuildMode.RELEASE, self.subprocess_cargo_lambda, None ) out = action.execute() self.assertEqual(out, "out") From 86e572a2d1939203925fc2d852cfcf13e7f03d74 Mon Sep 17 00:00:00 2001 From: sidhujus <105385029+sidhujus@users.noreply.github.com> Date: Mon, 29 Apr 2024 13:53:07 -0700 Subject: [PATCH 6/6] chore: bump version to 1.49 (#645) --- aws_lambda_builders/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws_lambda_builders/__init__.py b/aws_lambda_builders/__init__.py index 9e768cd0d..d7910614c 100644 --- a/aws_lambda_builders/__init__.py +++ b/aws_lambda_builders/__init__.py @@ -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.48.0" +__version__ = "1.49.0" RPC_PROTOCOL_VERSION = "0.3"