Skip to content

Commit

Permalink
feat: Support Java11, Python3.8, and Nodejs12.x runtimes (#1549)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfuss authored Nov 21, 2019
1 parent 75dff8b commit 612eb40
Show file tree
Hide file tree
Showing 20 changed files with 124 additions and 55 deletions.
4 changes: 3 additions & 1 deletion appveyor-windows-build-java-inprocess.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ install:
test_script:
# Reactivate virtualenv before running tests
- "venv\\Scripts\\activate"
- "pytest -vv tests/integration/buildcmd/test_build_cmd.py -k test_building_java_in_process"
- "pytest -vv tests/integration/buildcmd/test_build_cmd.py -k test_building_java8_in_process"
- "SET JAVA_HOME=C:\\Program Files\\Java\\jdk11"
- "pytest -vv tests/integration/buildcmd/test_build_cmd.py -k test_building_java11_in_process"
7 changes: 6 additions & 1 deletion appveyor-windows-build-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ init:
install:

# Make sure the temp directory exists for Python to use.
# Install python3.8
- "choco install python3 --version 3.8.0"
- "C:\\Python38\\python.exe -m pip freeze"
- "refreshenv"

- ps: "mkdir -Force D:\\tmp"
- "SET PATH=%PYTHON_HOME%;%PATH%"
- "SET PATH=%PYTHON_HOME%;%PATH%;C:\\Python37-x64;C:\\Python27-x64;C:\\Python38"
- "echo %PYTHON_HOME%"
- "echo %PATH%"
- "python --version"
Expand Down
26 changes: 25 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ environment:
PYTHON_VERSION: '3.6.8'
PYTHON_ARCH: '64'
NOSE_PARAMETERIZED_NO_WARN: 1
INSTALL_PY_37_PIP: 1

- PYTHON_HOME: "C:\\Python37-x64"
PYTHON_VERSION: '3.7.4'
PYTHON_ARCH: '64'
RUN_SMOKE: 1
NOSE_PARAMETERIZED_NO_WARN: 1
INSTALL_PY_36_PIP: 1

for:
-
Expand Down Expand Up @@ -98,6 +100,25 @@ for:
- sh: "./aws_cli/bin/python -m pip install awscli"
- sh: "PATH=$(echo $PWD'/aws_cli/bin'):$PATH"

- sh: "sudo apt-get -y install python3.6"
- sh: "sudo apt-get -y install python2.7"
- sh: "sudo apt-get -y install python3.7"
- sh: "sudo apt-get update"
- sh: "sudo apt-get -y install python3.8"

- sh: "which python3.8"
- sh: "which python3.6"
- sh: "which python3.7"
- sh: "which python2.7"

- sh: "PATH=$PATH:/usr/bin/python3.8:/usr/bin/python3.7"
- sh: "curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py"

- sh: "sudo apt-get -y install python3-distutils"
- sh: "python3.8 get-pip.py --user"
- ps: "If ($env:INSTALL_PY_37_PIP) {python3.7 get-pip.py --user}"
- ps: "If ($env:INSTALL_PY_36_PIP) {python3.6 get-pip.py --user}"

build_script:
- "python -c \"import sys; print(sys.executable)\""
- "pip install -e \".[dev]\""
Expand All @@ -113,7 +134,10 @@ for:
- sh: "pytest -vv tests/integration"
- sh: "pytest -vv -n 4 tests/regression"
- sh: "/tmp/black --check setup.py tests samcli scripts"
- sh: "python scripts/check-isolated-needs-update.py"

# Set JAVA_HOME to java11
- sh: "JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64"
- sh: "pytest -vv tests/integration/buildcmd/test_build_cmd.py -k test_building_java11_in_process"

# Smoke tests run in parallel - it runs on both Linux & Windows
# Presence of the RUN_SMOKE envvar will run the smoke tests
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ dateparser~=0.7
python-dateutil~=2.6, <2.8.1
requests==2.22.0
serverlessrepo==0.1.9
aws_lambda_builders==0.5.0
aws_lambda_builders==0.6.0
# https://github.com/mhammond/pywin32/issues/1439
pywin32 < 226; sys_platform == 'win32'
8 changes: 8 additions & 0 deletions samcli/lib/build/workflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ def get_workflow_config(runtime, code_dir, project_dir):
"python2.7": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"python3.6": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"python3.7": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"python3.8": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"nodejs4.3": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"nodejs6.10": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"nodejs8.10": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"nodejs10.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"nodejs12.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"ruby2.5": BasicWorkflowSelector(RUBY_BUNDLER_CONFIG),
"dotnetcore2.0": BasicWorkflowSelector(DOTNET_CLIPACKAGE_CONFIG),
"dotnetcore2.1": BasicWorkflowSelector(DOTNET_CLIPACKAGE_CONFIG),
Expand All @@ -111,6 +113,12 @@ def get_workflow_config(runtime, code_dir, project_dir):
JAVA_KOTLIN_GRADLE_CONFIG._replace(executable_search_paths=[code_dir, project_dir]),
JAVA_MAVEN_CONFIG
]),
"java11": ManifestWorkflowSelector([
# Gradle builder needs custom executable paths to find `gradlew` binary
JAVA_GRADLE_CONFIG._replace(executable_search_paths=[code_dir, project_dir]),
JAVA_KOTLIN_GRADLE_CONFIG._replace(executable_search_paths=[code_dir, project_dir]),
JAVA_MAVEN_CONFIG
]),
}

if runtime not in selectors_by_runtime:
Expand Down
27 changes: 20 additions & 7 deletions samcli/local/common/runtime_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
RUNTIME_DEP_TEMPLATE_MAPPING = {
"python": [
{
"runtimes": ["python3.7", "python3.6", "python2.7"],
"runtimes": ["python3.8", "python3.7", "python3.6", "python2.7"],
"dependency_manager": "pip",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-python"),
"build": True,
Expand All @@ -30,7 +30,7 @@
],
"nodejs": [
{
"runtimes": ["nodejs10.x", "nodejs8.10"],
"runtimes": ["nodejs12.x", "nodejs10.x", "nodejs8.10"],
"dependency_manager": "npm",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-nodejs"),
"build": True,
Expand Down Expand Up @@ -60,13 +60,13 @@
],
"java": [
{
"runtimes": ["java8"],
"runtimes": ["java11", "java8"],
"dependency_manager": "maven",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-java-maven"),
"build": True,
},
{
"runtimes": ["java8"],
"runtimes": ["java11", "java8"],
"dependency_manager": "gradle",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-java-gradle"),
"build": True,
Expand All @@ -75,10 +75,12 @@
}

RUNTIME_TO_DEPENDENCY_MANAGERS = {
"python3.8": ["pip"],
"python3.7": ["pip"],
"python3.6": ["pip"],
"python2.7": ["pip"],
"ruby2.5": ["bundler"],
"nodejs12.x": ["npm"],
"nodejs10.x": ["npm"],
"nodejs8.10": ["npm"],
"nodejs6.10": ["npm"],
Expand All @@ -87,6 +89,7 @@
"dotnetcore1.0": ["cli-package"],
"go1.x": ["mod"],
"java8": ["maven", "gradle"],
"java11": ["maven", "gradle"],
}

SUPPORTED_DEP_MANAGERS = {
Expand All @@ -99,17 +102,27 @@
itertools.chain(*[c["runtimes"] for c in list(itertools.chain(*(RUNTIME_DEP_TEMPLATE_MAPPING.values())))])
)

# Order here should be a the group of the latest versions of runtimes followed by runtime groups
INIT_RUNTIMES = [
"nodejs10.x",
"python3.7",
# latest of each runtime version
"nodejs12.x",
"python3.8",
"ruby2.5",
"go1.x",
"java8",
"java11",
"dotnetcore2.1",
# older nodejs runtimes
"nodejs10.x",
"nodejs8.10",
"nodejs6.10",
# older python runtimes
"python3.7",
"python3.6",
"python2.7",
# older ruby runtimes
# older java runtimes
"java8",
# older dotnetcore runtimes
"dotnetcore2.0",
"dotnetcore1.0",
]
24 changes: 24 additions & 0 deletions samcli/local/docker/lambda_debug_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,23 @@ def get_entry_point(debug_port, debug_args_list, runtime, options):
]
),
],
Runtime.nodejs12x.value: [
"/var/rapid/init",
"--bootstrap",
"/var/lang/bin/node",
"--bootstrap-args",
json.dumps(
debug_args_list
+ [
"--inspect-brk=0.0.0.0:" + str(debug_port),
"--nolazy",
"--expose-gc",
"--max-http-header-size",
"81920",
"/var/runtime/index.js",
]
),
],
Runtime.python27.value: ["/usr/bin/python2.7"] + debug_args_list + ["/var/runtime/awslambda/bootstrap.py"],
Runtime.python36.value: ["/var/lang/bin/python3.6"]
+ debug_args_list
Expand All @@ -112,6 +129,13 @@ def get_entry_point(debug_port, debug_args_list, runtime, options):
"--bootstrap-args",
json.dumps(debug_args_list + ["/var/runtime/bootstrap"]),
],
Runtime.python38.value: [
"/var/rapid/init",
"--bootstrap",
"/var/lang/bin/python3.8",
"--bootstrap-args",
json.dumps(debug_args_list + ["/var/runtime/bootstrap"]),
],
}
try:
return entrypoint_mapping[runtime]
Expand Down
3 changes: 3 additions & 0 deletions samcli/local/docker/lambda_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ class Runtime(Enum):
nodejs610 = "nodejs6.10"
nodejs810 = "nodejs8.10"
nodejs10x = "nodejs10.x"
nodejs12x = "nodejs12.x"
python27 = "python2.7"
python36 = "python3.6"
python37 = "python3.7"
python38 = "python3.8"
ruby25 = "ruby2.5"
java8 = "java8"
java11 = "java11"
go1x = "go1.x"
dotnetcore20 = "dotnetcore2.0"
dotnetcore21 = "dotnetcore2.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"project_name": "Name of the project",
"runtime": "java8"
"runtime": "java11"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Resources:
Properties:
CodeUri: HelloWorldFunction
Handler: helloworld.App::handleRequest
Runtime: java8
Runtime: {{ cookiecutter.runtime }}
MemorySize: 512
Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
Variables:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"project_name": "Name of the project",
"runtime": "java8"
"runtime": "java11"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Resources:
Properties:
CodeUri: HelloWorldFunction
Handler: helloworld.App::handleRequest
Runtime: java8
Runtime: {{ cookiecutter.runtime }}
MemorySize: 512
Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
Variables:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"project_name": "Name of the project",
"runtime": "nodejs10.x"
"runtime": "nodejs12.x"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ Resources:
Properties:
CodeUri: hello-world/
Handler: app.lambdaHandler
{%- if cookiecutter.runtime == 'nodejs8.10' %}
Runtime: {{ cookiecutter.runtime }}
{%- else %}
Runtime: nodejs10.x
{%- endif %}
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"project_name": "Name of the project",
"runtime": "python3.7"
"runtime": "python3.8"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ Resources:
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
{%- if cookiecutter.runtime == 'python2.7' %}
Runtime: python2.7
{%- elif cookiecutter.runtime == 'python3.6' %}
Runtime: python3.6
{%- else %}
Runtime: python3.7
{%- endif %}
Runtime: {{ cookiecutter.runtime }}
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Expand Down
Loading

0 comments on commit 612eb40

Please sign in to comment.