Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ruby3.2 support (#450) (#470) #5186

Merged
merged 3 commits into from
May 26, 2023
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
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ jobs:
- uses: ruby/setup-ruby@v1
with:
ruby-version: "2.7"
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
- uses: actions/setup-node@v3
with:
node-version: 18
Expand Down
4 changes: 2 additions & 2 deletions samcli/commands/build/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"""

DESCRIPTION = """
Build AWS serverless function code to generate artifacts targeting
Build AWS serverless function code to generate artifacts targeting
AWS Lambda execution environment.\n
\b
Supported Resource Types
Expand All @@ -52,7 +52,7 @@
------------------
1. Python 3.7, 3.8, 3.9, 3.10 using PIP\n
2. Nodejs 18.x, 16.x, 14.x, 12.x using NPM\n
3. Ruby 2.7 using Bundler\n
3. Ruby 2.7, 3.2 using Bundler\n
4. Java 8, Java 11, Java 17 using Gradle and Maven\n
5. Dotnetcore 3.1, Dotnet6 using Dotnet CLI (without --use-container)\n
6. Go 1.x using Go Modules (without --use-container)\n
Expand Down
2 changes: 2 additions & 0 deletions samcli/lib/build/workflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def get_layer_subfolder(build_workflow: str) -> str:
"nodejs16.x": "nodejs",
"nodejs18.x": "nodejs",
"ruby2.7": "ruby/lib",
"ruby3.2": "ruby/lib",
"java8": "java",
"java11": "java",
"java8.al2": "java",
Expand Down Expand Up @@ -159,6 +160,7 @@ def get_workflow_config(
"nodejs16.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"nodejs18.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"ruby2.7": BasicWorkflowSelector(RUBY_BUNDLER_CONFIG),
"ruby3.2": BasicWorkflowSelector(RUBY_BUNDLER_CONFIG),
"dotnetcore3.1": BasicWorkflowSelector(DOTNET_CLIPACKAGE_CONFIG),
"dotnet6": BasicWorkflowSelector(DOTNET_CLIPACKAGE_CONFIG),
"go1.x": BasicWorkflowSelector(GO_MOD_CONFIG),
Expand Down
1 change: 1 addition & 0 deletions samcli/lib/utils/architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"python3.9": [ARM64, X86_64],
"python3.10": [ARM64, X86_64],
"ruby2.7": [ARM64, X86_64],
"ruby3.2": [ARM64, X86_64],
"java8": [X86_64],
"java8.al2": [ARM64, X86_64],
"java11": [ARM64, X86_64],
Expand Down
2 changes: 1 addition & 1 deletion samcli/lib/utils/preview_runtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"""
from typing import Set

PREVIEW_RUNTIMES: Set[str] = set()
PREVIEW_RUNTIMES: Set[str] = {"ruby3.2"}
4 changes: 3 additions & 1 deletion samcli/local/common/runtime_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"ruby": [
{
"runtimes": ["ruby2.7"],
"runtimes": ["ruby3.2", "ruby2.7"],
"dependency_manager": "bundler",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-ruby"),
"build": True,
Expand Down Expand Up @@ -119,6 +119,7 @@ def get_local_lambda_images_location(mapping, runtime):
"python3.8",
"python3.7",
# ruby runtimes in descending order
"ruby3.2",
"ruby2.7",
]

Expand All @@ -140,6 +141,7 @@ def get_local_lambda_images_location(mapping, runtime):
"python3.9": "amazon/python3.9-base",
"python3.8": "amazon/python3.8-base",
"python3.7": "amazon/python3.7-base",
"ruby3.2": "amazon/ruby3.2-base",
"ruby2.7": "amazon/ruby2.7-base",
}

Expand Down
1 change: 1 addition & 0 deletions samcli/local/docker/lambda_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Runtime(Enum):
python39 = "python3.9"
python310 = "python3.10"
ruby27 = "ruby2.7"
ruby32 = "ruby3.2"
java8 = "java8"
java8al2 = "java8.al2"
java11 = "java11"
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/buildcmd/test_build_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,13 +637,13 @@ def test_building_default_package_json(self, runtime, use_container, architectur


class TestBuildCommand_RubyFunctions(BuildIntegRubyBase):
@parameterized.expand(["ruby2.7"])
@parameterized.expand(["ruby2.7", "ruby3.2"])
@pytest.mark.flaky(reruns=3)
@skipIf(SKIP_DOCKER_TESTS or SKIP_DOCKER_BUILD, SKIP_DOCKER_MESSAGE)
def test_building_ruby_in_container(self, runtime):
self._test_with_default_gemfile(runtime, "use_container", "Ruby", self.test_data_path)

@parameterized.expand(["ruby2.7"])
@parameterized.expand(["ruby2.7", "ruby3.2"])
@pytest.mark.flaky(reruns=3)
def test_building_ruby_in_process(self, runtime):
self._test_with_default_gemfile(runtime, False, "Ruby", self.test_data_path)
Expand All @@ -652,13 +652,13 @@ def test_building_ruby_in_process(self, runtime):
class TestBuildCommand_RubyFunctions_With_Architecture(BuildIntegRubyBase):
template = "template_with_architecture.yaml"

@parameterized.expand(["ruby2.7", ("ruby2.7", "arm64")])
@parameterized.expand(["ruby2.7", ("ruby2.7", "arm64"), "ruby3.2", ("ruby3.2", "arm64")])
@pytest.mark.flaky(reruns=3)
@skipIf(SKIP_DOCKER_TESTS or SKIP_DOCKER_BUILD, SKIP_DOCKER_MESSAGE)
def test_building_ruby_in_container_with_specified_architecture(self, runtime, architecture="x86_64"):
self._test_with_default_gemfile(runtime, "use_container", "Ruby", self.test_data_path, architecture)

@parameterized.expand(["ruby2.7", ("ruby2.7", "arm64")])
@parameterized.expand(["ruby2.7", ("ruby2.7", "arm64"), "ruby3.2", ("ruby3.2", "arm64")])
@pytest.mark.flaky(reruns=3)
def test_building_ruby_in_process_with_specified_architecture(self, runtime, architecture="x86_64"):
self._test_with_default_gemfile(runtime, False, "Ruby", self.test_data_path, architecture)
Expand All @@ -670,7 +670,7 @@ class TestBuildCommand_RubyFunctionsWithGemfileInTheRoot(BuildIntegRubyBase):
This doesn't apply to containerized build, since it copies only the function folder to the container
"""

@parameterized.expand([("ruby2.7")])
@parameterized.expand([("ruby2.7"), ("ruby3.2")])
@pytest.mark.flaky(reruns=3)
def test_building_ruby_in_process_with_root_gemfile(self, runtime):
self._prepare_application_environment()
Expand Down
8 changes: 5 additions & 3 deletions tests/unit/commands/init/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,7 @@ def test_must_return_runtime_from_base_image_name(self):
"amazon/python3.8-base",
"amazon/ruby2.7-base",
"amazon/go-provided.al2-base",
"amazon/ruby3.2-base",
]

expected_runtime = [
Expand All @@ -2137,6 +2138,7 @@ def test_must_return_runtime_from_base_image_name(self):
"python3.8",
"ruby2.7",
"go (provided.al2)",
"ruby3.2",
]

for index, base_image in enumerate(base_images):
Expand Down Expand Up @@ -2786,9 +2788,9 @@ def test_init_cli_generate_app_template_from_local_cli_templates(

@patch("samcli.local.common.runtime_template.INIT_RUNTIMES")
def test_must_remove_unsupported_runtime(self, init_runtime_mock):
runtime_option_list = ["python3.7", "ruby2.7", "java11", "unsupported_runtime", "dotnetcore3.1"]
init_runtime_mock.return_value = ["dotnetcore3.1", "go1.x", "java11", "python3.7", "ruby2.7"]
expect_result = ["dotnetcore3.1", "java11", "python3.7", "ruby2.7"]
runtime_option_list = ["python3.7", "ruby3.2", "ruby2.7", "java11", "unsupported_runtime", "dotnetcore3.1"]
init_runtime_mock.return_value = ["dotnetcore3.1", "go1.x", "java11", "python3.7", "ruby3.2", "ruby2.7"]
expect_result = ["dotnetcore3.1", "java11", "python3.7", "ruby3.2", "ruby2.7"]
actual_result = get_sorted_runtimes(runtime_option_list)
self.assertEqual(actual_result, expect_result)

Expand Down
1 change: 1 addition & 0 deletions tests/unit/local/docker/test_lambda_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class TestRuntime(TestCase):
("python3.8", "python:3.8-x86_64"),
("python3.9", "python:3.9-x86_64"),
("ruby2.7", "ruby:2.7-x86_64"),
("ruby3.2", "ruby:3.2-x86_64"),
("java8", "java:8"),
("java8.al2", "java:8.al2-x86_64"),
("java11", "java:11-x86_64"),
Expand Down