Skip to content

Commit

Permalink
Release 0.7.0
Browse files Browse the repository at this point in the history
Merge to master
  • Loading branch information
awood45 authored Feb 4, 2020
2 parents 7fe9671 + 7d718d4 commit 5133086
Show file tree
Hide file tree
Showing 113 changed files with 2,071 additions and 2,285 deletions.
28 changes: 9 additions & 19 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ environment:
matrix:

- PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: '2.7.16'
PYTHON_VERSION: '2.7.17'
PYTHON_ARCH: '64'
LINE_COVERAGE: '91'
NEW_FLAKE8: 0
JAVA_HOME: "C:\\Program Files\\Java\\jdk11"
- PYTHON: "C:\\Python36-x64"
PYTHON_VERSION: '3.6.8'
PYTHON_VERSION: '3.6.9'
PYTHON_ARCH: '64'
LINE_COVERAGE: '91'
NEW_FLAKE8: 0
Expand Down Expand Up @@ -100,6 +100,11 @@ for:
- sh: "sudo unzip -d /opt/gradle /tmp/gradle-*.zip"
- sh: "PATH=/opt/gradle/gradle-5.5/bin:$PATH"

# Install black
- sh: "wget -O /tmp/black https://github.com/python/black/releases/download/19.10b0/black"
- sh: "chmod +x /tmp/black"
- sh: "/tmp/black --version"

build_script:
- "python -c \"import sys; print(sys.executable)\""
- "LAMBDA_BUILDERS_DEV=1 pip install -e \".[dev]\""
Expand All @@ -111,20 +116,5 @@ for:
# Runs only in Linux
- "LAMBDA_BUILDERS_DEV=1 pytest -vv tests/integration"

-
matrix:
only:
- OLD_FLAKE8: 1

test_script:
- "flake8 lambda_builders"
- "flake8 tests/unit tests/integration"

-
matrix:
only:
- NEW_FLAKE8: 0

test_script:
- "flake8 lambda_builders"
- "flake8 tests/unit tests/integration --extend-ignore=W504"
# Validate Code was formatted with Black
- "/tmp/black --check setup.py tests aws_lambda_builders"
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ wheels/
# Installer logs
pip-log.txt
pip-delete-this-directory.txt

pip-wheel-metadata/
# Unit test / coverage reports
htmlcov/
.tox/
Expand Down Expand Up @@ -389,4 +389,4 @@ $RECYCLE.BIN/

tests/integration/workflows/go_dep/data/src/*/vendor/*

# End of https://www.gitignore.io/api/osx,node,macos,linux,python,windows,pycharm,intellij,sublimetext,visualstudiocode
# End of https://www.gitignore.io/api/osx,node,macos,linux,python,windows,pycharm,intellij,sublimetext,visualstudiocode
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ integ-test:
# Integration tests don't need code coverage
LAMBDA_BUILDERS_DEV=1 pytest tests/integration

flake:
# Make sure code conforms to PEP8 standards
flake8 lambda_builders
flake8 tests/unit tests/integration --extend-ignore=W504

lint:
# Liner performs static analysis to catch latent bugs
pylint --rcfile .pylintrc aws_lambda_builders

# Command to run everytime you make changes to verify everything works
dev: flake lint test
dev: lint test

black:
black setup.py aws_lambda_builders/* tests/*

black-check:
black --check setup.py aws_lambda_builders/* tests/*

# Verifications to run before sending a pull request
pr: init dev
pr: init dev black-check
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
## Lambda Builders

[![AppVeyor Status](https://ci.appveyor.com/api/projects/status/txv6gk69614727nu?svg=true)](https://ci.appveyor.com/project/sanathkr/aws-lambda-builders-3bxwl)
[![Travis Status](https://travis-ci.org/awslabs/aws-lambda-builders.svg?branch=develop)](https://travis-ci.org/awslabs/aws-lambda-builders)
[![Build status](https://ci.appveyor.com/api/projects/status/mrehrn5im0305lje/branch/develop?svg=true)](https://ci.appveyor.com/project/AWSSAMCLI/aws-lambda-builders/branch/develop)

Lambda Builders is a Python library to compile, build and package AWS Lambda functions for several runtimes &
frameworks.
Expand Down
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__ = '0.6.0'
__version__ = "0.7.0"
RPC_PROTOCOL_VERSION = "0.3"
58 changes: 24 additions & 34 deletions aws_lambda_builders/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,19 @@
log_level = int(os.environ.get("LAMBDA_BUILDERS_LOG_LEVEL", logging.INFO))

# Write output to stderr because stdout is used for command response
logging.basicConfig(stream=sys.stderr,
level=log_level,
format='%(message)s')
logging.basicConfig(stream=sys.stderr, level=log_level, format="%(message)s")

LOG = logging.getLogger(__name__)

VERSION_REGEX = re.compile("^([0-9])+.([0-9]+)$")


def _success_response(request_id, artifacts_dir):
return json.dumps({
"jsonrpc": "2.0",
"id": request_id,
"result": {
"artifacts_dir": artifacts_dir
}
})
return json.dumps({"jsonrpc": "2.0", "id": request_id, "result": {"artifacts_dir": artifacts_dir}})


def _error_response(request_id, http_status_code, message):
return json.dumps({
"jsonrpc": "2.0",
"id": request_id,
"error": {
"code": http_status_code,
"message": message
}
})
return json.dumps({"jsonrpc": "2.0", "id": request_id, "error": {"code": http_status_code, "message": message}})


def _parse_version(version_string):
Expand All @@ -68,8 +53,9 @@ def version_compatibility_check(version):
# 0.2 < 0.1 comparison will fail, don't throw a value Error saying incompatible version

if _parse_version(lambda_builders_protocol_version) < version:
ex = "Incompatible Protocol Version : {}, " \
"Current Protocol Version: {}".format(version, lambda_builders_protocol_version)
ex = "Incompatible Protocol Version : {}, " "Current Protocol Version: {}".format(
version, lambda_builders_protocol_version
)
LOG.error(ex)
raise ValueError(ex)

Expand Down Expand Up @@ -120,21 +106,25 @@ def main(): # pylint: disable=too-many-statements
response = None

try:
builder = LambdaBuilder(language=capabilities["language"],
dependency_manager=capabilities["dependency_manager"],
application_framework=capabilities["application_framework"],
supported_workflows=supported_workflows)
builder = LambdaBuilder(
language=capabilities["language"],
dependency_manager=capabilities["dependency_manager"],
application_framework=capabilities["application_framework"],
supported_workflows=supported_workflows,
)

artifacts_dir = params["artifacts_dir"]
builder.build(params["source_dir"],
params["artifacts_dir"],
params["scratch_dir"],
params["manifest_path"],
executable_search_paths=params.get('executable_search_paths', None),
runtime=params["runtime"],
optimizations=params["optimizations"],
options=params["options"],
mode=params.get('mode', None))
builder.build(
params["source_dir"],
params["artifacts_dir"],
params["scratch_dir"],
params["manifest_path"],
executable_search_paths=params.get("executable_search_paths", None),
runtime=params["runtime"],
optimizations=params["optimizations"],
options=params["options"],
mode=params.get("mode", None),
)

# Return a success response
response = _success_response(request_id, artifacts_dir)
Expand All @@ -152,5 +142,5 @@ def main(): # pylint: disable=too-many-statements
_write_response(response, exit_code)


if __name__ == '__main__':
if __name__ == "__main__":
main()
8 changes: 4 additions & 4 deletions aws_lambda_builders/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ActionFailedError(Exception):
"""
Base class for exception raised when action failed to complete. Use this to express well-known failure scenarios.
"""

pass


Expand All @@ -38,12 +39,11 @@ def has_value(item):


class _ActionMetaClass(type):

def __new__(mcs, name, bases, class_dict):

cls = type.__new__(mcs, name, bases, class_dict)

if cls.__name__ == 'BaseAction':
if cls.__name__ == "BaseAction":
return cls

# Validate class variables
Expand Down Expand Up @@ -78,15 +78,15 @@ def execute(self):
:raises lambda_builders.actions.ActionFailedError: Instance of this class if something went wrong with the
action
"""
raise NotImplementedError('execute')
raise NotImplementedError("execute")

def __repr__(self):
return "Name={}, Purpose={}, Description={}".format(self.NAME, self.PURPOSE, self.DESCRIPTION)


class CopySourceAction(BaseAction):

NAME = 'CopySource'
NAME = "CopySource"

DESCRIPTION = "Copying source code while skipping certain commonly excluded files"

Expand Down
1 change: 0 additions & 1 deletion aws_lambda_builders/binary_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class BinaryPath(object):

def __init__(self, resolver, validator, binary, binary_path=None):
self.resolver = resolver
self.validator = validator
Expand Down
44 changes: 27 additions & 17 deletions aws_lambda_builders/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

LOG = logging.getLogger(__name__)

_SUPPORTED_WORKFLOWS = [
"aws_lambda_builders.workflows"
]
_SUPPORTED_WORKFLOWS = ["aws_lambda_builders.workflows"]


class LambdaBuilder(object):
Expand Down Expand Up @@ -49,14 +47,24 @@ def __init__(self, language, dependency_manager, application_framework, supporte
# If a module is already loaded, this call is pretty much a no-op. So it is okay to keep loading again.
importlib.import_module(workflow_module)

self.capability = Capability(language=language,
dependency_manager=dependency_manager,
application_framework=application_framework)
self.capability = Capability(
language=language, dependency_manager=dependency_manager, application_framework=application_framework
)
self.selected_workflow_cls = get_workflow(self.capability)
LOG.debug("Found workflow '%s' to support capabilities '%s'", self.selected_workflow_cls.NAME, self.capability)

def build(self, source_dir, artifacts_dir, scratch_dir, manifest_path,
runtime=None, optimizations=None, options=None, executable_search_paths=None, mode=None):
def build(
self,
source_dir,
artifacts_dir,
scratch_dir,
manifest_path,
runtime=None,
optimizations=None,
options=None,
executable_search_paths=None,
mode=None,
):
"""
Actually build the code by running workflows
Expand Down Expand Up @@ -102,15 +110,17 @@ def build(self, source_dir, artifacts_dir, scratch_dir, manifest_path,
if not os.path.exists(scratch_dir):
os.makedirs(scratch_dir)

workflow = self.selected_workflow_cls(source_dir,
artifacts_dir,
scratch_dir,
manifest_path,
runtime=runtime,
optimizations=optimizations,
options=options,
executable_search_paths=executable_search_paths,
mode=mode)
workflow = self.selected_workflow_cls(
source_dir,
artifacts_dir,
scratch_dir,
manifest_path,
runtime=runtime,
optimizations=optimizations,
options=options,
executable_search_paths=executable_search_paths,
mode=mode,
)

return workflow.run()

Expand Down
21 changes: 14 additions & 7 deletions aws_lambda_builders/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class LambdaBuilderError(Exception):

MESSAGE = ''
MESSAGE = ""

def __init__(self, **kwargs):
Exception.__init__(self, self.MESSAGE.format(**kwargs))
Expand All @@ -16,29 +16,36 @@ class UnsupportedManifestError(LambdaBuilderError):


class MisMatchRuntimeError(LambdaBuilderError):
MESSAGE = "{language} executable found in your path does not " \
"match runtime. " \
"\n Expected version: {required_runtime}, Found version: {runtime_path}. " \
"\n Possibly related: https://github.com/awslabs/aws-lambda-builders/issues/30"
MESSAGE = (
"{language} executable found in your path does not "
"match runtime. "
"\n Expected version: {required_runtime}, Found version: {runtime_path}. "
"\n Possibly related: https://github.com/awslabs/aws-lambda-builders/issues/30"
)


class WorkflowNotFoundError(LambdaBuilderError):
"""
Raised when a workflow matching the given capabilities was not found
"""
MESSAGE = "Unable to find a workflow matching given capability: " \
"{language}, {dependency_manager}, {application_framework}"

MESSAGE = (
"Unable to find a workflow matching given capability: "
"{language}, {dependency_manager}, {application_framework}"
)


class WorkflowFailedError(LambdaBuilderError):
"""
Raised when the build failed, for well-known cases
"""

MESSAGE = "{workflow_name}:{action_name} - {reason}"


class WorkflowUnknownError(LambdaBuilderError):
"""
Raised when the build ran into an unexpected error
"""

MESSAGE = "{workflow_name}:{action_name} - {reason}"
6 changes: 3 additions & 3 deletions aws_lambda_builders/path_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class PathResolver(object):

def __init__(self, binary, runtime, executable_search_paths=None):
self.binary = binary
self.runtime = runtime
Expand All @@ -20,8 +19,9 @@ def _which(self):
exec_paths.extend(paths)

if not exec_paths:
raise ValueError("Path resolution for runtime: {} of binary: "
"{} was not successful".format(self.runtime, self.binary))
raise ValueError(
"Path resolution for runtime: {} of binary: " "{} was not successful".format(self.runtime, self.binary)
)
return exec_paths

@property
Expand Down
Loading

0 comments on commit 5133086

Please sign in to comment.