Skip to content

Commit 9bc19ca

Browse files
authored
Merge pull request #86 from awslabs/develop
Release: v0.1.0
2 parents cb7de0b + d609200 commit 9bc19ca

File tree

140 files changed

+4080
-189
lines changed

Some content is hidden

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

140 files changed

+4080
-189
lines changed

.appveyor.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ version: 1.0.{build}
22
image: Visual Studio 2017
33

44
environment:
5+
GOPATH: c:\gopath
6+
GOVERSION: 1.11
7+
GRADLE_OPTS: -Dorg.gradle.daemon=false
58

69
matrix:
710

@@ -16,12 +19,26 @@ install:
1619
# To run Nodejs workflow integ tests
1720
- ps: Install-Product node 8.10
1821

19-
- "set PATH=%PYTHON%\\Scripts;%PYTHON%\\bin;%PATH%"
22+
- "set PATH=%PYTHON%;%PYTHON%\\Scripts;%PYTHON%\\bin;%PATH%"
2023
- "%PYTHON%\\python.exe -m pip install -r requirements/dev.txt"
2124
- "%PYTHON%\\python.exe -m pip install -e ."
2225
- "set PATH=C:\\Ruby25-x64\\bin;%PATH%"
23-
- "gem install bundler --no-ri --no-rdoc"
26+
- "gem --version"
27+
- "gem install bundler -v 1.17.3"
2428
- "bundler --version"
29+
- "echo %PATH%"
30+
31+
# setup go
32+
- rmdir c:\go /s /q
33+
- "choco install golang"
34+
- "choco install bzr"
35+
- "choco install dep"
36+
- setx PATH "C:\go\bin;C:\gopath\bin;C:\Program Files (x86)\Bazaar\;C:\Program Files\Mercurial;%PATH%;"
37+
- "go version"
38+
- "go env"
39+
40+
# setup Gradle
41+
- "choco install gradle"
2542

2643
test_script:
2744
- "%PYTHON%\\python.exe -m pytest --cov aws_lambda_builders --cov-report term-missing tests/unit tests/functional"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,4 +383,6 @@ $RECYCLE.BIN/
383383

384384
/Dockerfile
385385

386-
# End of https://www.gitignore.io/api/osx,node,macos,linux,python,windows,pycharm,intellij,sublimetext,visualstudiocode
386+
tests/integration/workflows/go_dep/data/src/*/vendor/*
387+
388+
# End of https://www.gitignore.io/api/osx,node,macos,linux,python,windows,pycharm,intellij,sublimetext,visualstudiocode

.pylintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
# Add files or directories to the blacklist. They should be base names, not
1111
# paths.
12-
ignore=compat.py
12+
ignore=compat.py, utils.py
1313

1414
# Pickle collected data for later comparisons.
1515
persistent=yes
@@ -360,4 +360,4 @@ int-import-graph=
360360

361361
# Exceptions that will emit a warning when being caught. Defaults to
362362
# "Exception"
363-
overgeneral-exceptions=Exception
363+
overgeneral-exceptions=Exception

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ install:
1515
# To run Nodejs workflow integ tests
1616
- nvm install 8.10.0
1717
- nvm use 8.10.0
18+
# To run Ruby workflow integ tests
19+
- rvm install ruby-2.5.3
20+
- rvm use ruby-2.5.3
21+
22+
# Go workflow integ tests require Go 1.11+
23+
- eval "$(gimme 1.11.2)"
24+
- go version
25+
26+
- go get -u github.com/golang/dep/cmd/dep
1827

1928
# Install the code requirements
2029
- make init

DESIGN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ If your build action implementation requires 3rd party libraries, here is how yo
3939

4040
Each build action has its own design document.
4141

42-
* [python-pip](./lambda_builders/actions/python_pip/DESIGN.md)
42+
* [python-pip](./aws_lambda_builders/workflows/python_pip/DESIGN.md)
4343

4444

4545
### Builders Library

NOTICE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
AWS Lambda Builders
22
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
4+
The function "which" at aws_lambda_builders/utils.py was copied from https://github.com/python/cpython/blob/3.7/Lib/shutil.py
5+
SPDX-License-Identifier: Python-2.0
6+
Copyright 2019 by the Python Software Foundation

aws_lambda_builders/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
22
AWS Lambda Builder Library
33
"""
4-
__version__ = '0.0.5'
5-
RPC_PROTOCOL_VERSION = "0.1"
4+
__version__ = '0.1.0'
5+
RPC_PROTOCOL_VERSION = "0.2"

aws_lambda_builders/__main__.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
import json
1111
import os
1212
import logging
13+
import re
1314

1415
from aws_lambda_builders.builder import LambdaBuilder
1516
from aws_lambda_builders.exceptions import WorkflowNotFoundError, WorkflowUnknownError, WorkflowFailedError
16-
17+
from aws_lambda_builders import RPC_PROTOCOL_VERSION as lambda_builders_protocol_version
1718

1819
log_level = int(os.environ.get("LAMBDA_BUILDERS_LOG_LEVEL", logging.INFO))
1920

@@ -24,6 +25,8 @@
2425

2526
LOG = logging.getLogger(__name__)
2627

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

2831
def _success_response(request_id, artifacts_dir):
2932
return json.dumps({
@@ -46,6 +49,31 @@ def _error_response(request_id, http_status_code, message):
4649
})
4750

4851

52+
def _parse_version(version_string):
53+
54+
if VERSION_REGEX.match(version_string):
55+
return float(version_string)
56+
else:
57+
ex = "Protocol Version does not match : {}".format(VERSION_REGEX.pattern)
58+
LOG.debug(ex)
59+
raise ValueError(ex)
60+
61+
62+
def version_compatibility_check(version):
63+
# The following check is between current protocol version vs version of the protocol
64+
# with which aws-lambda-builders is called.
65+
# Example:
66+
# 0.2 < 0.2 comparison will fail, don't throw a value Error saying incompatible version.
67+
# 0.2 < 0.3 comparison will pass, throwing a ValueError
68+
# 0.2 < 0.1 comparison will fail, don't throw a value Error saying incompatible version
69+
70+
if _parse_version(lambda_builders_protocol_version) < version:
71+
ex = "Incompatible Protocol Version : {}, " \
72+
"Current Protocol Version: {}".format(version, lambda_builders_protocol_version)
73+
LOG.error(ex)
74+
raise ValueError(ex)
75+
76+
4977
def _write_response(response, exit_code):
5078
sys.stdout.write(response)
5179
sys.stdout.flush() # Make sure it is written
@@ -77,11 +105,20 @@ def main(): # pylint: disable=too-many-statements
77105
response = _error_response(request_id, -32601, "Method unavailable")
78106
return _write_response(response, 1)
79107

108+
try:
109+
protocol_version = _parse_version(params.get("__protocol_version"))
110+
version_compatibility_check(protocol_version)
111+
112+
except ValueError:
113+
response = _error_response(request_id, 505, "Unsupported Protocol Version")
114+
return _write_response(response, 1)
115+
80116
capabilities = params["capability"]
81117
supported_workflows = params.get("supported_workflows")
82118

83119
exit_code = 0
84120
response = None
121+
85122
try:
86123
builder = LambdaBuilder(language=capabilities["language"],
87124
dependency_manager=capabilities["dependency_manager"],
@@ -93,6 +130,7 @@ def main(): # pylint: disable=too-many-statements
93130
params["artifacts_dir"],
94131
params["scratch_dir"],
95132
params["manifest_path"],
133+
executable_search_paths=params.get('executable_search_paths', None),
96134
runtime=params["runtime"],
97135
optimizations=params["optimizations"],
98136
options=params["options"])

aws_lambda_builders/binary_path.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
Class containing resolved path of binary given a validator and a resolver and the name of the binary.
3+
"""
4+
5+
6+
class BinaryPath(object):
7+
8+
def __init__(self, resolver, validator, binary, binary_path=None):
9+
self.resolver = resolver
10+
self.validator = validator
11+
self.binary = binary
12+
self._binary_path = binary_path
13+
self.path_provided = True if self._binary_path else False
14+
15+
@property
16+
def binary_path(self):
17+
return self._binary_path
18+
19+
@binary_path.setter
20+
def binary_path(self, binary_path):
21+
self._binary_path = binary_path

aws_lambda_builders/builder.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import logging
88

99
from aws_lambda_builders.registry import get_workflow, DEFAULT_REGISTRY
10-
from aws_lambda_builders.validate import RuntimeValidator
1110
from aws_lambda_builders.workflow import Capability
1211

1312
LOG = logging.getLogger(__name__)
@@ -57,7 +56,7 @@ def __init__(self, language, dependency_manager, application_framework, supporte
5756
LOG.debug("Found workflow '%s' to support capabilities '%s'", self.selected_workflow_cls.NAME, self.capability)
5857

5958
def build(self, source_dir, artifacts_dir, scratch_dir, manifest_path,
60-
runtime=None, optimizations=None, options=None):
59+
runtime=None, optimizations=None, options=None, executable_search_paths=None):
6160
"""
6261
Actually build the code by running workflows
6362
@@ -90,9 +89,11 @@ def build(self, source_dir, artifacts_dir, scratch_dir, manifest_path,
9089
:type options: dict
9190
:param options:
9291
Optional dictionary of options ot pass to build action. **Not supported**.
92+
93+
:type executable_search_paths: list
94+
:param executable_search_paths:
95+
Additional list of paths to search for executables required by the workflow.
9396
"""
94-
if runtime:
95-
self._validate_runtime(runtime)
9697

9798
if not os.path.exists(scratch_dir):
9899
os.makedirs(scratch_dir)
@@ -103,20 +104,10 @@ def build(self, source_dir, artifacts_dir, scratch_dir, manifest_path,
103104
manifest_path,
104105
runtime=runtime,
105106
optimizations=optimizations,
106-
options=options)
107+
options=options,
108+
executable_search_paths=executable_search_paths)
107109

108110
return workflow.run()
109111

110-
def _validate_runtime(self, runtime):
111-
"""
112-
validate runtime and local runtime version to make sure they match
113-
114-
:type runtime: str
115-
:param runtime:
116-
String matching a lambda runtime eg: python3.6
117-
"""
118-
RuntimeValidator.validate_runtime(required_language=self.capability.language,
119-
required_runtime=runtime)
120-
121112
def _clear_workflows(self):
122113
DEFAULT_REGISTRY.clear()

0 commit comments

Comments
 (0)