forked from aws/aws-lambda-builders
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactions.py
More file actions
59 lines (45 loc) · 1.99 KB
/
Copy pathactions.py
File metadata and controls
59 lines (45 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
Actions for Ruby dependency resolution with Bundler
"""
import logging
from aws_lambda_builders.actions import ActionFailedError, BaseAction, Purpose
from .bundler import BundlerExecutionError
LOG = logging.getLogger(__name__)
class RubyBundlerInstallAction(BaseAction):
"""
A Lambda Builder Action which runs bundle install in order to build a full Gemfile.lock
"""
NAME = "RubyBundle"
DESCRIPTION = "Resolving dependencies using Bundler"
PURPOSE = Purpose.RESOLVE_DEPENDENCIES
def __init__(self, source_dir, subprocess_bundler):
super(RubyBundlerInstallAction, self).__init__()
self.source_dir = source_dir
self.subprocess_bundler = subprocess_bundler
def execute(self):
try:
LOG.debug("Running bundle install in %s", self.source_dir)
self.subprocess_bundler.run(
["config", "set", "--local", "without", "development:test"], cwd=self.source_dir
)
self.subprocess_bundler.run(["install"], cwd=self.source_dir)
except BundlerExecutionError as ex:
raise ActionFailedError(str(ex))
class RubyBundlerVendorAction(BaseAction):
"""
A Lambda Builder Action which vendors dependencies to the vendor/bundle directory.
"""
NAME = "RubyBundleDeployment"
DESCRIPTION = "Package dependencies for deployment."
PURPOSE = Purpose.RESOLVE_DEPENDENCIES
def __init__(self, source_dir, subprocess_bundler):
super(RubyBundlerVendorAction, self).__init__()
self.source_dir = source_dir
self.subprocess_bundler = subprocess_bundler
def execute(self):
try:
LOG.debug("Running bundle install with deployment enabled in %s", self.source_dir)
self.subprocess_bundler.run(["config", "set", "--local", "deployment", "true"], cwd=self.source_dir)
self.subprocess_bundler.run(["install"], cwd=self.source_dir)
except BundlerExecutionError as ex:
raise ActionFailedError(str(ex))