-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
54 lines (43 loc) · 1.48 KB
/
build.py
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
import os
from pybuilder.core import use_plugin, init, task, depends
from pybuilder.errors import BuildFailedException
# Core Plugins
use_plugin("python.core")
use_plugin("python.unittest")
use_plugin("python.install_dependencies")
use_plugin("python.flake8")
use_plugin("python.coverage")
use_plugin('pypi:pybuilder_aws_plugin')
# IDE Plugin
# Run pyb pycharm_generate to configure IDE
use_plugin('python.pycharm')
# Properties
name = "mylawn"
default_task = "publish"
version = "0.2"
lambda_name = "myLawn"
bucket_name = "mylawn-code"
latest_code = "code/latest/mylawn.zip"
@init
def set_properties(project):
project.depends_on_requirements("requirements.txt")
project.build_depends_on_requirements("requirements-dev.txt")
# AWS Properties
project.set_property("bucket_name", bucket_name)
project.set_property("bucket_prefix", "code/")
project.set_property("coverage_break_build", False)
@depends('clean', 'package_lambda_code', 'upload_zip_to_s3', 'lambda_release')
@task
def deploy(logger):
pass
@task
def update_lambda(logger):
upload_cmd = "aws lambda update-function-code --function-name %s --s3-bucket %s --s3-key %s"
final_cmd = upload_cmd % (lambda_name,bucket_name,latest_code)
logger.info("Updating lambda")
logger.info(final_cmd)
exit_code = os.system(final_cmd)
if exit_code:
err_msg = "Failed with exit code: %d" % exit_code
logger.error(err_msg)
raise BuildFailedException(message="Unable to update lamdba!")