Skip to content

Commit 18f9472

Browse files
committed
refactor: centralize AWS Lambda runtime definitions
Centralized all AWS Lambda runtime definitions into a single source of truth to improve maintainability and reduce code duplication across the codebase.
1 parent 9c30f3b commit 18f9472

File tree

6 files changed

+29
-43
lines changed

6 files changed

+29
-43
lines changed

tests/integration/workflows/dotnet_clipackage/test_dotnet.py

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313

1414
from aws_lambda_builders.builder import LambdaBuilder
1515
from aws_lambda_builders.architecture import ARM64, X86_64
16+
from aws_lambda_builders.supported_runtimes import DOTNET_RUNTIMES
17+
18+
# Map dotnet runtimes to their versions and test projects
19+
DOTNET_RUNTIME_CONFIGS = [
20+
("dotnet6", "6.0", "WithDefaultsFile6"),
21+
("dotnet8", "8.0", "WithDefaultsFile8"),
22+
]
23+
24+
DOTNET_CUSTOM_RUNTIME_CONFIGS = [
25+
("dotnet6", "6.0", "CustomRuntime6"),
26+
("dotnet8", "8.0", "CustomRuntime8"),
27+
]
1628

1729

1830
class TestDotnetBase(TestCase):
@@ -57,12 +69,7 @@ class TestDotnet(TestDotnetBase):
5769
def setUp(self):
5870
super(TestDotnet, self).setUp()
5971

60-
@parameterized.expand(
61-
[
62-
("dotnet6", "6.0", "WithDefaultsFile6"),
63-
("dotnet8", "8.0", "WithDefaultsFile8"),
64-
]
65-
)
72+
@parameterized.expand(DOTNET_RUNTIME_CONFIGS)
6673
def test_with_defaults_file(self, runtime, version, test_project):
6774
source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)
6875

@@ -83,12 +90,7 @@ def test_with_defaults_file(self, runtime, version, test_project):
8390
self.assertEqual(expected_files, output_files)
8491
self.verify_architecture("WithDefaultsFile.deps.json", "linux-x64", version)
8592

86-
@parameterized.expand(
87-
[
88-
("dotnet6", "6.0", "WithDefaultsFile6"),
89-
("dotnet8", "8.0", "WithDefaultsFile8"),
90-
]
91-
)
93+
@parameterized.expand(DOTNET_RUNTIME_CONFIGS)
9294
def test_with_defaults_file_x86(self, runtime, version, test_project):
9395
source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)
9496

@@ -109,12 +111,7 @@ def test_with_defaults_file_x86(self, runtime, version, test_project):
109111
self.assertEqual(expected_files, output_files)
110112
self.verify_architecture("WithDefaultsFile.deps.json", "linux-x64", version)
111113

112-
@parameterized.expand(
113-
[
114-
("dotnet6", "6.0", "WithDefaultsFile6"),
115-
("dotnet8", "8.0", "WithDefaultsFile8"),
116-
]
117-
)
114+
@parameterized.expand(DOTNET_RUNTIME_CONFIGS)
118115
def test_with_defaults_file_arm64(self, runtime, version, test_project):
119116
source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)
120117

@@ -135,12 +132,7 @@ def test_with_defaults_file_arm64(self, runtime, version, test_project):
135132
self.assertEqual(expected_files, output_files)
136133
self.verify_architecture("WithDefaultsFile.deps.json", "linux-arm64", version)
137134

138-
@parameterized.expand(
139-
[
140-
("dotnet6", "6.0", "CustomRuntime6"),
141-
("dotnet8", "8.0", "CustomRuntime8"),
142-
]
143-
)
135+
@parameterized.expand(DOTNET_CUSTOM_RUNTIME_CONFIGS)
144136
def test_with_custom_runtime(self, runtime, version, test_project):
145137
source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)
146138

tests/integration/workflows/go_modules/test_go.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313

1414
from aws_lambda_builders.builder import LambdaBuilder
1515
from aws_lambda_builders.exceptions import WorkflowFailedError
16+
from aws_lambda_builders.supported_runtimes import GO_RUNTIMES, CUSTOM_RUNTIMES
1617

1718
from tests.integration.workflows.go_modules.utils import get_executable_arch
1819
from tests.integration.workflows.go_modules.utils import get_md5_hexdigest
1920

21+
# Go runtime configurations: (runtime, expected_binary_name)
22+
GO_RUNTIME_CONFIGS = [("provided", "bootstrap"), ("go1.x", "helloWorld")]
23+
2024

2125
class TestGoWorkflow(TestCase):
2226
"""
@@ -199,7 +203,7 @@ def test_builds_project_with_nested_dir(self):
199203
output_files = set(os.listdir(self.artifacts_dir))
200204
self.assertEqual(expected_files, output_files)
201205

202-
@parameterized.expand([("provided", "bootstrap"), ("go1.x", "helloWorld")])
206+
@parameterized.expand(GO_RUNTIME_CONFIGS)
203207
def test_binary_named_bootstrap_for_provided_runtime(self, runtime, expected_binary):
204208
source_dir = os.path.join(self.TEST_DATA_FOLDER, "no-deps")
205209
self.builder.build(

tests/integration/workflows/java_gradle/test_java_gradle.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from aws_lambda_builders.builder import LambdaBuilder
1414
from aws_lambda_builders.exceptions import WorkflowFailedError
15+
from aws_lambda_builders.supported_runtimes import JAVA_RUNTIMES
1516
from tests.integration.workflows.common_test_utils import (
1617
does_folder_contain_all_files,
1718
does_folder_contain_file,
@@ -21,12 +22,7 @@
2122

2223
@parameterized_class(
2324
("runtime",),
24-
[
25-
["java8"],
26-
["java11"],
27-
["java17"],
28-
["java21"],
29-
],
25+
[[runtime] for runtime in JAVA_RUNTIMES],
3026
)
3127
class TestJavaGradle(TestCase):
3228
# Have to use str(Path(__file__).resolve()) here to workaround a Windows VSCode issue

tests/integration/workflows/java_maven/test_java_maven.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from aws_lambda_builders.builder import LambdaBuilder
1212
from aws_lambda_builders.exceptions import WorkflowFailedError
13+
from aws_lambda_builders.supported_runtimes import JAVA_RUNTIMES
1314
from tests.integration.workflows.common_test_utils import (
1415
does_folder_contain_all_files,
1516
does_folder_contain_file,
@@ -19,12 +20,7 @@
1920

2021
@parameterized_class(
2122
("runtime",),
22-
[
23-
["java8"],
24-
["java11"],
25-
["java17"],
26-
["java21"],
27-
],
23+
[[runtime] for runtime in JAVA_RUNTIMES],
2824
)
2925
class TestJavaMaven(TestCase):
3026
# Have to use str(Path(__file__).resolve()) here to workaround a Windows VSCode issue

tests/integration/workflows/python_pip/test_python_pip.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111

1212
from aws_lambda_builders.builder import LambdaBuilder
1313
from aws_lambda_builders.exceptions import WorkflowFailedError
14+
from aws_lambda_builders.supported_runtimes import PYTHON_RUNTIMES
1415
from aws_lambda_builders.utils import which
1516
from aws_lambda_builders.workflows.python_pip.utils import EXPERIMENTAL_FLAG_BUILD_PERFORMANCE
1617

1718
logger = logging.getLogger("aws_lambda_builders.workflows.python_pip.workflow")
1819
IS_WINDOWS = platform.system().lower() == "windows"
1920
NOT_ARM = platform.processor() != "aarch64"
20-
ARM_RUNTIMES = {"python3.8", "python3.9", "python3.10", "python3.11", "python3.12", "python3.13", "python3.14"}
21+
ARM_RUNTIMES = set(PYTHON_RUNTIMES)
2122

2223

2324
@parameterized_class(("experimental_flags",), [([]), ([EXPERIMENTAL_FLAG_BUILD_PERFORMANCE])])

tests/integration/workflows/ruby_bundler/test_ruby.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from aws_lambda_builders.builder import LambdaBuilder
1010
from aws_lambda_builders.exceptions import WorkflowFailedError
11+
from aws_lambda_builders.supported_runtimes import RUBY_RUNTIMES
1112

1213
import logging
1314

@@ -17,11 +18,7 @@
1718

1819
@parameterized_class(
1920
("runtime",),
20-
[
21-
("ruby3.2",),
22-
("ruby3.3",),
23-
("ruby3.4",),
24-
],
21+
[(runtime,) for runtime in RUBY_RUNTIMES],
2522
)
2623
class TestRubyWorkflow(TestCase):
2724
"""

0 commit comments

Comments
 (0)