Skip to content
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
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ docker~=4.2.0
dateparser~=1.0
requests==2.25.1
serverlessrepo==0.1.10
aws_lambda_builders==1.16.0
aws_lambda_builders==1.17.0
tomlkit==0.7.2
watchdog==2.1.2

Expand Down
8 changes: 4 additions & 4 deletions requirements/reproducible-linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ attrs==20.3.0 \
--hash=sha256:31b2eced602aa8423c2aea9c76a724617ed67cf9513173fd3a4f03e3a929c7e6 \
--hash=sha256:832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700
# via jsonschema
aws-lambda-builders==1.16.0 \
--hash=sha256:227977e143e626087638989957d3443e11a93837318cfb377c88c231d6950f66 \
--hash=sha256:417b7709d9941d38b4d6ba8615d1416acd50c3fa137b4a4e818609c7c7c5b4ab \
--hash=sha256:f81c5835cf49a904e3bf66343238a2b7e46ea5a00ee519234402388446be5fc4
aws-lambda-builders==1.17.0 \
--hash=sha256:1d296dc521f3f3f356ffbe290ca204713b1e8a24612262cf1c9283ffe34dc443 \
--hash=sha256:3eb7ca5ab71761766586db080a8b80ab81346b307fa72d5cea64ccd69fb41efe \
--hash=sha256:abae4ccfc419fc5cd8eebd4cc81e335ec7610f53804ce1aa2b655159ce339610
# via aws-sam-cli (setup.py)
aws-sam-translator==1.45.0 \
--hash=sha256:40a6dd5a0aba32c7b38b0f5c54470396acdcd75e4b64251b015abdf922a18b5f \
Expand Down
3 changes: 0 additions & 3 deletions samcli/commands/_utils/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ class ExperimentalFlag:

All = ExperimentalEntry("experimentalAll", EXPERIMENTAL_ENV_VAR_PREFIX + "FEATURES")
Accelerate = ExperimentalEntry("experimentalAccelerate", EXPERIMENTAL_ENV_VAR_PREFIX + "ACCELERATE")
JavaMavenBuildScope = ExperimentalEntry(
"experimentalMavenScopeAndLayer", EXPERIMENTAL_ENV_VAR_PREFIX + "MAVEN_SCOPE_AND_LAYER"
)
Esbuild = ExperimentalEntry("experimentalEsbuild", EXPERIMENTAL_ENV_VAR_PREFIX + "ESBUILD")


Expand Down
29 changes: 1 addition & 28 deletions samcli/commands/build/build_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import click

from samcli.commands._utils.experimental import is_experimental_enabled, ExperimentalFlag, prompt_experimental
from samcli.commands._utils.experimental import ExperimentalFlag, prompt_experimental
from samcli.lib.providers.sam_api_provider import SamApiProvider
from samcli.lib.utils.packagetype import IMAGE

Expand Down Expand Up @@ -186,7 +186,6 @@ def run(self):
raise UserException(str(ex), wrapped_from=ex.__class__.__name__) from ex

try:
self._check_java_warning()
self._check_esbuild_warning()
build_result = builder.build()
artifacts = build_result.artifacts
Expand Down Expand Up @@ -515,38 +514,12 @@ def _is_layer_buildable(layer: LayerVersion):
return False
return True

_JAVA_BUILD_WARNING_MESSAGE = (
"Test the latest build changes for Java runtime 'SAM_CLI_BETA_MAVEN_SCOPE_AND_LAYER=1 sam build'. "
"These changes will replace the existing flow on 1st of April 2022. "
"Check https://github.com/aws/aws-sam-cli/issues/3639 for more information."
)

_ESBUILD_WARNING_MESSAGE = (
"Using esbuild for bundling Node.js and TypeScript is a beta feature.\n"
"Please confirm if you would like to proceed with using esbuild to build your function.\n"
"You can also enable this beta feature with 'sam build --beta-features'."
)

def _check_java_warning(self) -> None:
"""
Prints warning message about upcoming changes to building java functions and layers.
This warning message will only be printed if template contains any buildable functions or layers with one of
the java runtimes.
"""
# display warning message for java runtimes for changing build method
resources_to_build = self.get_resources_to_build()
function_runtimes = {function.runtime for function in resources_to_build.functions if function.runtime}
layer_build_methods = {layer.build_method for layer in resources_to_build.layers if layer.build_method}

is_building_java = False
for runtime_or_build_method in set.union(function_runtimes, layer_build_methods):
if runtime_or_build_method.startswith("java"):
is_building_java = True
break

if is_building_java and not is_experimental_enabled(ExperimentalFlag.JavaMavenBuildScope):
click.secho(self._JAVA_BUILD_WARNING_MESSAGE, fg="yellow")

def _check_esbuild_warning(self) -> None:
"""
Prints warning message and confirms that the user wants to enable beta features
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/buildcmd/build_integ_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import jmespath
from pathlib import Path

from samcli.lib.utils import osutils
from samcli.lib.utils.architecture import X86_64, has_runtime_multi_arch_image
from samcli.local.docker.lambda_build_container import LambdaBuildContainer
from samcli.yamlhelper import yaml_parse
Expand Down Expand Up @@ -499,7 +500,7 @@ def _test_with_building_java(
osutils.convert_to_unix_line_ending(os.path.join(self.test_data_path, self.USING_GRADLEW_PATH, "gradlew"))

LOG.info("Running Command: {}".format(cmdlist))
run_command(cmdlist, cwd=self.working_dir)
run_command(cmdlist, cwd=self.working_dir, timeout=900)

self._verify_built_artifact(
self.default_build_dir, self.FUNCTION_LOGICAL_ID, expected_files, expected_dependencies
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/telemetry/test_experimental_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def test_must_send_experimental_metrics_if_experimental_command(self):
"metricSpecificAttributes": {
"experimentalAccelerate": True,
"experimentalAll": False,
"experimentalMavenScopeAndLayer": False,
"experimentalEsbuild": False,
},
"duration": ANY,
Expand Down Expand Up @@ -107,7 +106,6 @@ def test_must_send_experimental_metrics_if_experimental_option(self):
"metricSpecificAttributes": {
"experimentalAccelerate": True,
"experimentalAll": True,
"experimentalMavenScopeAndLayer": True,
"experimentalEsbuild": True,
},
"duration": ANY,
Expand Down
8 changes: 5 additions & 3 deletions tests/unit/commands/_utils/test_experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
prompt_experimental,
set_experimental,
get_enabled_experimental_flags,
ExperimentalEntry,
ExperimentalFlag,
)


Expand Down Expand Up @@ -56,13 +58,13 @@ def test_set_experimental(self):
self.gc_mock.return_value.set_value.assert_called_once_with(config_entry, False, is_flag=True, flush=False)

def test_get_all_experimental(self):
self.assertEqual(len(get_all_experimental()), 4)
self.assertEqual(len(get_all_experimental()), 3)

def test_get_all_experimental_statues(self):
self.assertEqual(len(get_all_experimental_statues()), 4)
self.assertEqual(len(get_all_experimental_statues()), 3)

def test_get_enabled_experimental_flags(self):
self.assertEqual(len(get_enabled_experimental_flags()), 4)
self.assertEqual(len(get_enabled_experimental_flags()), 3)

@patch("samcli.commands._utils.experimental.set_experimental")
@patch("samcli.commands._utils.experimental.get_all_experimental")
Expand Down
46 changes: 3 additions & 43 deletions tests/unit/commands/buildcmd/test_build_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,9 @@ def test_run_sync_build_context(
print_success_message=False,
) as build_context:
with patch("samcli.commands.build.build_context.BuildContext.gen_success_msg") as mock_message:
with patch("samcli.commands.build.build_context.BuildContext._check_java_warning") as mock_java_warning:
with patch("samcli.commands.build.build_context.BuildContext._check_esbuild_warning"):
build_context.run()
mock_message.assert_not_called()
with patch("samcli.commands.build.build_context.BuildContext._check_esbuild_warning"):
build_context.run()
mock_message.assert_not_called()


class TestBuildContext_setup_build_dir(TestCase):
Expand Down Expand Up @@ -1081,45 +1080,6 @@ def test_must_catch_function_not_found_exception(
self.assertEqual(str(ctx.exception), "Function Not Found")


class TestBuildContext_java_warning(TestCase):
@parameterized.expand(
[
([], [], False),
([DummyFunction("NonJavaFunction", runtime="nodejs14.x")], [], False),
([], [DummyLayer("NonJavaLayer", build_method="nodejs14.x")], False),
(
[DummyFunction("NonJavaFunction", runtime="nodejs14.x")],
[DummyLayer("NonJavaLayer", build_method="nodejs14.x")],
False,
),
([DummyFunction("JavaFunction", runtime="java8")], [], True),
([], [DummyLayer("JavaLayer", build_method="java11")], True),
([DummyFunction("JavaFunction", runtime="java11")], [DummyLayer("JavaLayer", build_method="java8")], True),
]
)
@patch("samcli.commands.build.build_context.click.secho")
def test_check_java_warning(self, functions, layers, should_print, mocked_click):
build_context = BuildContext(
resource_identifier="function_identifier",
template_file="template_file",
base_dir="base_dir",
build_dir="build_dir",
cache_dir="cache_dir",
cached=False,
clean=False,
parallel=False,
mode="mode",
)
with patch.object(build_context, "get_resources_to_build") as mocked_resources_to_build:
mocked_resources_to_build.return_value = Mock(functions=functions, layers=layers)
build_context._check_java_warning()

if should_print:
mocked_click.assert_called_with(BuildContext._JAVA_BUILD_WARNING_MESSAGE, fg="yellow")
else:
mocked_click.assert_not_called()


class TestBuildContext_esbuild_warning(TestCase):
@parameterized.expand(
[
Expand Down