Skip to content

Commit

Permalink
Merge pull request #366 from aws/develop
Browse files Browse the repository at this point in the history
chore: merge develop to master
  • Loading branch information
mndeveci authored May 25, 2022
2 parents fffe6e4 + 3cfd5e1 commit 080ca89
Show file tree
Hide file tree
Showing 18 changed files with 92 additions and 76 deletions.
14 changes: 0 additions & 14 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Bug report
about: Create an issue to report a bug for AWS Lambda Builders
title: "Bug: TITLE"
labels: ['type/bug', 'stage/needs-triage']
assignees: ''

---

<!-- Make sure we don't have an existing Issue that reports the bug you are seeing (both open and closed).
If you do find an existing Issue, re-open or add a comment to that Issue instead of creating a new one. -->

### Description:
<!-- Briefly describe the bug you are facing.-->



### Steps to reproduce:
<!-- Provide detailed steps to replicate the bug, including steps from third party tools (CDK, etc.) -->



### Observed result:
<!-- Please provide command output with `--debug` flag set.-->



### Expected result:
<!-- Describe what you expected.-->



### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

1. OS:
2. If using SAM CLI, `sam --version`:
3. AWS region:

`Add --debug flag to any SAM CLI commands you are running`
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Feature request
about: Suggest an idea/feature/enhancement for AWS Lambda Builders
title: "Feature request: TITLE"
labels: ['type/feature', 'stage/needs-triage']
assignees: ''

---

<!-- Make sure we don't have an existing Issue for that feature request (open or closed). -->

### Describe your idea/feature/enhancement

Provide a clear description.

Ex: I wish the AWS Lambda Builders would [...]

### Proposal

Add details on how to add this to the product.

### Additional Details
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/other.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Other
about: Choose if your issue doesn't apply to the other templates
title: ''
labels: ['stage/needs-triage']
assignees: ''

---
2 changes: 1 addition & 1 deletion .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['pr/external']
labels: ['pr/external', 'stage/needs-triage']
})
}
2 changes: 1 addition & 1 deletion aws_lambda_builders/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
AWS Lambda Builder Library
"""
__version__ = "1.16.0"
__version__ = "1.17.0"
RPC_PROTOCOL_VERSION = "0.3"
10 changes: 0 additions & 10 deletions aws_lambda_builders/workflows/java/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
from aws_lambda_builders.utils import which, copytree


EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG = "experimentalMavenScopeAndLayer"


class OSUtils(object):
"""
Convenience wrapper around common system functions
Expand Down Expand Up @@ -63,10 +60,3 @@ def jar_file_filter(file_name):
Name of the file that will be checked against if it ends with .jar or not
"""
return bool(file_name) and isinstance(file_name, str) and file_name.endswith(".jar")


def is_experimental_maven_scope_and_layers_active(experimental_flags):
"""
A function which will determine if experimental maven scope and layer changes are active
"""
return bool(experimental_flags) and EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG in experimental_flags
4 changes: 2 additions & 2 deletions aws_lambda_builders/workflows/java_gradle/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from aws_lambda_builders.actions import CleanUpAction
from aws_lambda_builders.workflow import BaseWorkflow, Capability
from aws_lambda_builders.workflows.java.actions import JavaCopyDependenciesAction, JavaMoveDependenciesAction
from aws_lambda_builders.workflows.java.utils import OSUtils, is_experimental_maven_scope_and_layers_active
from aws_lambda_builders.workflows.java.utils import OSUtils

from .actions import JavaGradleBuildAction, JavaGradleCopyArtifactsAction, JavaGradleCopyLayerArtifactsAction
from .gradle import SubprocessGradle
Expand Down Expand Up @@ -36,7 +36,7 @@ def __init__(self, source_dir, artifacts_dir, scratch_dir, manifest_path, **kwar
copy_artifacts_action = JavaGradleCopyArtifactsAction(
source_dir, artifacts_dir, self.build_output_dir, self.os_utils
)
if self.is_building_layer and is_experimental_maven_scope_and_layers_active(self.experimental_flags):
if self.is_building_layer:
copy_artifacts_action = JavaGradleCopyLayerArtifactsAction(
source_dir, artifacts_dir, self.build_output_dir, self.os_utils
)
Expand Down
5 changes: 2 additions & 3 deletions aws_lambda_builders/workflows/java_maven/maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ def __init__(self, **kwargs):


class SubprocessMaven(object):
def __init__(self, maven_binary, os_utils=None, is_experimental_maven_scope_enabled=False):
def __init__(self, maven_binary, os_utils=None):
if maven_binary is None:
raise ValueError("Must provide Maven BinaryPath")
self.maven_binary = maven_binary
if os_utils is None:
raise ValueError("Must provide OSUtils")
self.os_utils = os_utils
self.is_experimental_maven_scope_enabled = is_experimental_maven_scope_enabled

def build(self, scratch_dir):
args = ["clean", "install"]
Expand All @@ -35,7 +34,7 @@ def build(self, scratch_dir):
raise MavenExecutionError(message=stdout.decode("utf8").strip())

def copy_dependency(self, scratch_dir):
include_scope = "runtime" if self.is_experimental_maven_scope_enabled else "compile"
include_scope = "runtime"
LOG.debug("Running copy_dependency with scope: %s", include_scope)
args = ["dependency:copy-dependencies", f"-DincludeScope={include_scope}", "-Dmdep.prependGroupId=true"]
ret_code, stdout, _ = self._run(args, scratch_dir)
Expand Down
8 changes: 2 additions & 6 deletions aws_lambda_builders/workflows/java_maven/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from aws_lambda_builders.workflow import BaseWorkflow, Capability
from aws_lambda_builders.actions import CopySourceAction, CleanUpAction
from aws_lambda_builders.workflows.java.actions import JavaCopyDependenciesAction, JavaMoveDependenciesAction
from aws_lambda_builders.workflows.java.utils import OSUtils, is_experimental_maven_scope_and_layers_active
from aws_lambda_builders.workflows.java.utils import OSUtils

from .actions import (
JavaMavenBuildAction,
Expand Down Expand Up @@ -34,17 +34,13 @@ def __init__(self, source_dir, artifacts_dir, scratch_dir, manifest_path, **kwar
self.os_utils = OSUtils()
# Assuming root_dir is the same as source_dir for now
root_dir = source_dir
is_experimental_maven_scope_and_layers_enabled = is_experimental_maven_scope_and_layers_active(
self.experimental_flags
)
subprocess_maven = SubprocessMaven(
maven_binary=self.binaries["mvn"],
os_utils=self.os_utils,
is_experimental_maven_scope_enabled=is_experimental_maven_scope_and_layers_enabled,
)

copy_artifacts_action = JavaMavenCopyArtifactsAction(scratch_dir, artifacts_dir, self.os_utils)
if self.is_building_layer and is_experimental_maven_scope_and_layers_enabled:
if self.is_building_layer:
copy_artifacts_action = JavaMavenCopyLayerArtifactsAction(scratch_dir, artifacts_dir, self.os_utils)

self.actions = [
Expand Down
3 changes: 0 additions & 3 deletions tests/integration/workflows/java_gradle/test_java_gradle.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from aws_lambda_builders.builder import LambdaBuilder
from aws_lambda_builders.exceptions import WorkflowFailedError
from aws_lambda_builders.workflows.java.utils import EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG
from tests.integration.workflows.common_test_utils import (
does_folder_contain_all_files,
does_folder_contain_file,
Expand Down Expand Up @@ -204,7 +203,6 @@ def validate_layer_build(self):
layer_manifest_path,
runtime=self.runtime,
is_building_layer=True,
experimental_flags=[EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG],
)
artifact_expected_files = [
join("lib", "aws-lambda-java-core-1.2.0.jar"),
Expand All @@ -223,7 +221,6 @@ def validate_function_build(self):
function_manifest_path,
runtime=self.runtime,
is_building_layer=False,
experimental_flags=[EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG],
)
artifact_expected_files = [
join("aws", "lambdabuilders", "Main.class"),
Expand Down
3 changes: 0 additions & 3 deletions tests/integration/workflows/java_maven/test_java_maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from aws_lambda_builders.builder import LambdaBuilder
from aws_lambda_builders.exceptions import WorkflowFailedError
from aws_lambda_builders.workflows.java.utils import EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG
from tests.integration.workflows.common_test_utils import (
does_folder_contain_all_files,
does_folder_contain_file,
Expand Down Expand Up @@ -134,7 +133,6 @@ def validate_layer_build(self):
layer_manifest_path,
runtime=self.runtime,
is_building_layer=True,
experimental_flags=[EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG],
)
artifact_expected_files = [
join("lib", "com.amazonaws.aws-lambda-java-core-1.2.0.jar"),
Expand All @@ -154,7 +152,6 @@ def validate_function_build(self):
function_manifest_path,
runtime=self.runtime,
is_building_layer=False,
experimental_flags=[EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG],
)
artifact_expected_files = [
join("aws", "lambdabuilders", "Main.class"),
Expand Down
11 changes: 10 additions & 1 deletion tests/integration/workflows/python_pip/test_python_pip.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import shutil
import six
import sys
import platform
import tempfile
Expand Down Expand Up @@ -137,7 +138,15 @@ def test_mismatch_runtime_python_project(self):
runtime=self.runtime_mismatch[self.runtime],
)
except WorkflowFailedError as ex:
self.assertIn("Binary validation failed", str(ex))
# handle both e.g. missing /usr/bin/python2.7 and situation where
# python2.7 does not have pip installed (as is the case in some
# Mac environments)
ex_s = str(ex)
if (
"Binary validation failed" not in ex_s
and "pip executable not found in your python environment" not in ex_s
):
six.raise_from(AssertionError("Unexpected exception"), ex)

def test_runtime_validate_python_project_fail_open_unsupported_runtime(self):
with self.assertRaises(WorkflowFailedError):
Expand Down
13 changes: 0 additions & 13 deletions tests/unit/workflows/java/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

from aws_lambda_builders.workflows.java.utils import (
jar_file_filter,
EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG,
is_experimental_maven_scope_and_layers_active,
)


Expand All @@ -20,14 +18,3 @@ class TestJavaUtils(TestCase):
)
def test_jar_file_filter(self, file_name, expected):
self.assertEqual(jar_file_filter(file_name), expected)

@parameterized.expand(
[
(None, False),
([], False),
([EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG], True),
([EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG, "SomeOtherFlag"], True),
]
)
def test_experimental_maven_scope_and_layers_check(self, experimental_flags, expected):
self.assertEqual(is_experimental_maven_scope_and_layers_active(experimental_flags), expected)
4 changes: 1 addition & 3 deletions tests/unit/workflows/java_gradle/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from aws_lambda_builders.actions import CleanUpAction
from aws_lambda_builders.workflows.java.actions import JavaMoveDependenciesAction, JavaCopyDependenciesAction
from aws_lambda_builders.workflows.java.utils import EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG
from aws_lambda_builders.workflows.java_gradle.workflow import JavaGradleWorkflow
from aws_lambda_builders.workflows.java_gradle.actions import (
JavaGradleBuildAction,
Expand Down Expand Up @@ -98,14 +97,13 @@ def test_must_validate_architecture(self):
self.assertEqual(workflow.architecture, "x86_64")
self.assertEqual(workflow_with_arm.architecture, "arm64")

def test_workflow_sets_up_gradle_actions_for_layers_experimental(self):
def test_workflow_sets_up_gradle_actions_for_layers(self):
workflow = JavaGradleWorkflow(
"source",
"artifacts",
"scratch_dir",
"manifest",
is_building_layer=True,
experimental_flags=[EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG],
)

self.assertEqual(len(workflow.actions), 2)
Expand Down
14 changes: 1 addition & 13 deletions tests/unit/workflows/java_maven/test_maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_copy_dependency(self):
maven = SubprocessMaven(maven_binary=self.maven_binary, os_utils=self.os_utils)
maven.copy_dependency(self.source_dir)
self.os_utils.popen.assert_called_with(
[self.maven_path, "dependency:copy-dependencies", "-DincludeScope=compile", "-Dmdep.prependGroupId=true"],
[self.maven_path, "dependency:copy-dependencies", "-DincludeScope=runtime", "-Dmdep.prependGroupId=true"],
cwd=self.source_dir,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
Expand All @@ -74,15 +74,3 @@ def test_copy_dependency_raises_exception_if_retcode_not_0(self):
with self.assertRaises(MavenExecutionError) as err:
maven.copy_dependency(self.source_dir)
self.assertEqual(err.exception.args[0], "Maven Failed: Some Error Message")

def test_experimental_scope(self):
maven = SubprocessMaven(
maven_binary=self.maven_binary, os_utils=self.os_utils, is_experimental_maven_scope_enabled=True
)
maven.copy_dependency(self.source_dir)
self.os_utils.popen.assert_called_with(
[self.maven_path, "dependency:copy-dependencies", "-DincludeScope=runtime", "-Dmdep.prependGroupId=true"],
cwd=self.source_dir,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
)
5 changes: 2 additions & 3 deletions tests/unit/workflows/java_maven/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from mock import patch, ANY

from aws_lambda_builders.workflows.java.actions import JavaCopyDependenciesAction, JavaMoveDependenciesAction
from aws_lambda_builders.workflows.java.utils import EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG
from aws_lambda_builders.workflows.java_maven.workflow import JavaMavenWorkflow
from aws_lambda_builders.workflows.java_maven.actions import (
JavaMavenBuildAction,
Expand Down Expand Up @@ -114,11 +113,11 @@ def test_workflow_sets_up_maven_actions_with_combine_dependencies(self, patched_
"scratch_dir",
"manifest",
is_building_layer=True,
experimental_flags=[EXPERIMENTAL_MAVEN_SCOPE_AND_LAYER_FLAG],
)

patched_maven_process.assert_called_with(
maven_binary=ANY, os_utils=ANY, is_experimental_maven_scope_enabled=True
maven_binary=ANY,
os_utils=ANY,
)

self.assertEqual(len(workflow.actions), 4)
Expand Down

0 comments on commit 080ca89

Please sign in to comment.