Skip to content

Commit 5133086

Browse files
authored
Release 0.7.0
Merge to master
2 parents 7fe9671 + 7d718d4 commit 5133086

File tree

113 files changed

+2071
-2285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+2071
-2285
lines changed

.appveyor.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ environment:
1212
matrix:
1313

1414
- PYTHON: "C:\\Python27-x64"
15-
PYTHON_VERSION: '2.7.16'
15+
PYTHON_VERSION: '2.7.17'
1616
PYTHON_ARCH: '64'
1717
LINE_COVERAGE: '91'
1818
NEW_FLAKE8: 0
1919
JAVA_HOME: "C:\\Program Files\\Java\\jdk11"
2020
- PYTHON: "C:\\Python36-x64"
21-
PYTHON_VERSION: '3.6.8'
21+
PYTHON_VERSION: '3.6.9'
2222
PYTHON_ARCH: '64'
2323
LINE_COVERAGE: '91'
2424
NEW_FLAKE8: 0
@@ -100,6 +100,11 @@ for:
100100
- sh: "sudo unzip -d /opt/gradle /tmp/gradle-*.zip"
101101
- sh: "PATH=/opt/gradle/gradle-5.5/bin:$PATH"
102102

103+
# Install black
104+
- sh: "wget -O /tmp/black https://github.com/python/black/releases/download/19.10b0/black"
105+
- sh: "chmod +x /tmp/black"
106+
- sh: "/tmp/black --version"
107+
103108
build_script:
104109
- "python -c \"import sys; print(sys.executable)\""
105110
- "LAMBDA_BUILDERS_DEV=1 pip install -e \".[dev]\""
@@ -111,20 +116,5 @@ for:
111116
# Runs only in Linux
112117
- "LAMBDA_BUILDERS_DEV=1 pytest -vv tests/integration"
113118

114-
-
115-
matrix:
116-
only:
117-
- OLD_FLAKE8: 1
118-
119-
test_script:
120-
- "flake8 lambda_builders"
121-
- "flake8 tests/unit tests/integration"
122-
123-
-
124-
matrix:
125-
only:
126-
- NEW_FLAKE8: 0
127-
128-
test_script:
129-
- "flake8 lambda_builders"
130-
- "flake8 tests/unit tests/integration --extend-ignore=W504"
119+
# Validate Code was formatted with Black
120+
- "/tmp/black --check setup.py tests aws_lambda_builders"

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ wheels/
257257
# Installer logs
258258
pip-log.txt
259259
pip-delete-this-directory.txt
260-
260+
pip-wheel-metadata/
261261
# Unit test / coverage reports
262262
htmlcov/
263263
.tox/
@@ -389,4 +389,4 @@ $RECYCLE.BIN/
389389

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

392-
# End of https://www.gitignore.io/api/osx,node,macos,linux,python,windows,pycharm,intellij,sublimetext,visualstudiocode
392+
# End of https://www.gitignore.io/api/osx,node,macos,linux,python,windows,pycharm,intellij,sublimetext,visualstudiocode

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ integ-test:
1313
# Integration tests don't need code coverage
1414
LAMBDA_BUILDERS_DEV=1 pytest tests/integration
1515

16-
flake:
17-
# Make sure code conforms to PEP8 standards
18-
flake8 lambda_builders
19-
flake8 tests/unit tests/integration --extend-ignore=W504
20-
2116
lint:
2217
# Liner performs static analysis to catch latent bugs
2318
pylint --rcfile .pylintrc aws_lambda_builders
2419

2520
# Command to run everytime you make changes to verify everything works
26-
dev: flake lint test
21+
dev: lint test
22+
23+
black:
24+
black setup.py aws_lambda_builders/* tests/*
25+
26+
black-check:
27+
black --check setup.py aws_lambda_builders/* tests/*
2728

2829
# Verifications to run before sending a pull request
29-
pr: init dev
30+
pr: init dev black-check

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
## Lambda Builders
22

3-
[![AppVeyor Status](https://ci.appveyor.com/api/projects/status/txv6gk69614727nu?svg=true)](https://ci.appveyor.com/project/sanathkr/aws-lambda-builders-3bxwl)
4-
[![Travis Status](https://travis-ci.org/awslabs/aws-lambda-builders.svg?branch=develop)](https://travis-ci.org/awslabs/aws-lambda-builders)
3+
[![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)
54

65
Lambda Builders is a Python library to compile, build and package AWS Lambda functions for several runtimes &
76
frameworks.

aws_lambda_builders/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
22
AWS Lambda Builder Library
33
"""
4-
__version__ = '0.6.0'
4+
__version__ = "0.7.0"
55
RPC_PROTOCOL_VERSION = "0.3"

aws_lambda_builders/__main__.py

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,19 @@
1919
log_level = int(os.environ.get("LAMBDA_BUILDERS_LOG_LEVEL", logging.INFO))
2020

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

2624
LOG = logging.getLogger(__name__)
2725

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

3028

3129
def _success_response(request_id, artifacts_dir):
32-
return json.dumps({
33-
"jsonrpc": "2.0",
34-
"id": request_id,
35-
"result": {
36-
"artifacts_dir": artifacts_dir
37-
}
38-
})
30+
return json.dumps({"jsonrpc": "2.0", "id": request_id, "result": {"artifacts_dir": artifacts_dir}})
3931

4032

4133
def _error_response(request_id, http_status_code, message):
42-
return json.dumps({
43-
"jsonrpc": "2.0",
44-
"id": request_id,
45-
"error": {
46-
"code": http_status_code,
47-
"message": message
48-
}
49-
})
34+
return json.dumps({"jsonrpc": "2.0", "id": request_id, "error": {"code": http_status_code, "message": message}})
5035

5136

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

7055
if _parse_version(lambda_builders_protocol_version) < version:
71-
ex = "Incompatible Protocol Version : {}, " \
72-
"Current Protocol Version: {}".format(version, lambda_builders_protocol_version)
56+
ex = "Incompatible Protocol Version : {}, " "Current Protocol Version: {}".format(
57+
version, lambda_builders_protocol_version
58+
)
7359
LOG.error(ex)
7460
raise ValueError(ex)
7561

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

122108
try:
123-
builder = LambdaBuilder(language=capabilities["language"],
124-
dependency_manager=capabilities["dependency_manager"],
125-
application_framework=capabilities["application_framework"],
126-
supported_workflows=supported_workflows)
109+
builder = LambdaBuilder(
110+
language=capabilities["language"],
111+
dependency_manager=capabilities["dependency_manager"],
112+
application_framework=capabilities["application_framework"],
113+
supported_workflows=supported_workflows,
114+
)
127115

128116
artifacts_dir = params["artifacts_dir"]
129-
builder.build(params["source_dir"],
130-
params["artifacts_dir"],
131-
params["scratch_dir"],
132-
params["manifest_path"],
133-
executable_search_paths=params.get('executable_search_paths', None),
134-
runtime=params["runtime"],
135-
optimizations=params["optimizations"],
136-
options=params["options"],
137-
mode=params.get('mode', None))
117+
builder.build(
118+
params["source_dir"],
119+
params["artifacts_dir"],
120+
params["scratch_dir"],
121+
params["manifest_path"],
122+
executable_search_paths=params.get("executable_search_paths", None),
123+
runtime=params["runtime"],
124+
optimizations=params["optimizations"],
125+
options=params["options"],
126+
mode=params.get("mode", None),
127+
)
138128

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

154144

155-
if __name__ == '__main__':
145+
if __name__ == "__main__":
156146
main()

aws_lambda_builders/actions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class ActionFailedError(Exception):
1515
"""
1616
Base class for exception raised when action failed to complete. Use this to express well-known failure scenarios.
1717
"""
18+
1819
pass
1920

2021

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

3940

4041
class _ActionMetaClass(type):
41-
4242
def __new__(mcs, name, bases, class_dict):
4343

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

46-
if cls.__name__ == 'BaseAction':
46+
if cls.__name__ == "BaseAction":
4747
return cls
4848

4949
# Validate class variables
@@ -78,15 +78,15 @@ def execute(self):
7878
:raises lambda_builders.actions.ActionFailedError: Instance of this class if something went wrong with the
7979
action
8080
"""
81-
raise NotImplementedError('execute')
81+
raise NotImplementedError("execute")
8282

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

8686

8787
class CopySourceAction(BaseAction):
8888

89-
NAME = 'CopySource'
89+
NAME = "CopySource"
9090

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

aws_lambda_builders/binary_path.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
class BinaryPath(object):
7-
87
def __init__(self, resolver, validator, binary, binary_path=None):
98
self.resolver = resolver
109
self.validator = validator

aws_lambda_builders/builder.py

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
LOG = logging.getLogger(__name__)
1313

14-
_SUPPORTED_WORKFLOWS = [
15-
"aws_lambda_builders.workflows"
16-
]
14+
_SUPPORTED_WORKFLOWS = ["aws_lambda_builders.workflows"]
1715

1816

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

52-
self.capability = Capability(language=language,
53-
dependency_manager=dependency_manager,
54-
application_framework=application_framework)
50+
self.capability = Capability(
51+
language=language, dependency_manager=dependency_manager, application_framework=application_framework
52+
)
5553
self.selected_workflow_cls = get_workflow(self.capability)
5654
LOG.debug("Found workflow '%s' to support capabilities '%s'", self.selected_workflow_cls.NAME, self.capability)
5755

58-
def build(self, source_dir, artifacts_dir, scratch_dir, manifest_path,
59-
runtime=None, optimizations=None, options=None, executable_search_paths=None, mode=None):
56+
def build(
57+
self,
58+
source_dir,
59+
artifacts_dir,
60+
scratch_dir,
61+
manifest_path,
62+
runtime=None,
63+
optimizations=None,
64+
options=None,
65+
executable_search_paths=None,
66+
mode=None,
67+
):
6068
"""
6169
Actually build the code by running workflows
6270
@@ -102,15 +110,17 @@ def build(self, source_dir, artifacts_dir, scratch_dir, manifest_path,
102110
if not os.path.exists(scratch_dir):
103111
os.makedirs(scratch_dir)
104112

105-
workflow = self.selected_workflow_cls(source_dir,
106-
artifacts_dir,
107-
scratch_dir,
108-
manifest_path,
109-
runtime=runtime,
110-
optimizations=optimizations,
111-
options=options,
112-
executable_search_paths=executable_search_paths,
113-
mode=mode)
113+
workflow = self.selected_workflow_cls(
114+
source_dir,
115+
artifacts_dir,
116+
scratch_dir,
117+
manifest_path,
118+
runtime=runtime,
119+
optimizations=optimizations,
120+
options=options,
121+
executable_search_paths=executable_search_paths,
122+
mode=mode,
123+
)
114124

115125
return workflow.run()
116126

aws_lambda_builders/exceptions.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class LambdaBuilderError(Exception):
77

8-
MESSAGE = ''
8+
MESSAGE = ""
99

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

1717

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

2426

2527
class WorkflowNotFoundError(LambdaBuilderError):
2628
"""
2729
Raised when a workflow matching the given capabilities was not found
2830
"""
29-
MESSAGE = "Unable to find a workflow matching given capability: " \
30-
"{language}, {dependency_manager}, {application_framework}"
31+
32+
MESSAGE = (
33+
"Unable to find a workflow matching given capability: "
34+
"{language}, {dependency_manager}, {application_framework}"
35+
)
3136

3237

3338
class WorkflowFailedError(LambdaBuilderError):
3439
"""
3540
Raised when the build failed, for well-known cases
3641
"""
42+
3743
MESSAGE = "{workflow_name}:{action_name} - {reason}"
3844

3945

4046
class WorkflowUnknownError(LambdaBuilderError):
4147
"""
4248
Raised when the build ran into an unexpected error
4349
"""
50+
4451
MESSAGE = "{workflow_name}:{action_name} - {reason}"

0 commit comments

Comments
 (0)