This repository has been archived by the owner on Dec 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (46 loc) · 2.14 KB
/
Makefile
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
.PHONY: all install test deploy lambda
all: install deploy
# The directory that the external Python modules are installed into. If this is changed, it should
# also be updated in .gitignore, .coveragerc, AND the PYTHONPATH environment variable in the Lambda
# function configuration.
modules_directory = vendor
# Using a fresh virtualenv, installs dependencies for the Lambda function as defined in
# requirements.txt. This makes it ready to package up into a zip as required for deployment.
install:
cd lambda/*/ && \
virtualenv venv && \
. venv/bin/activate && \
mkdir -p $(modules_directory) && \
pip install --requirement requirements.txt --target $(modules_directory) && \
deactivate && \
rm -rf venv && \
rm -rf $(modules_directory)/*.dist-info
# Runs tests, installing relevant dependencies if they're not already present.
test:
pip list | grep -E '^pytest\s' || pip install pytest
pip list | grep -E '^pytest-cov\s' || pip install pytest-cov
pip list | grep -E '^boto3\s' || pip install boto3
pip list | grep -E '^ask-sdk-core\s' || pip install ask_sdk_core
PYTHONPATH="$(shell pwd)/$(shell find lambda/* -maxdepth 0 -type d | head -n1)/$(modules_directory):${PYTHONPATH}" \
pytest
# Submits coverage to coveralls. Requires COVERALLS_REPO_TOKEN to be available in the environment,
# if not being run in Travis CI or Circle CI.
coverage:
pip list | grep -E '^coveralls\s' || pip install coveralls
coveralls
# Prepares for packaging and deployment by removing unneeded folders, and installing the ASK CLI if
# it is not already present.
prepare-deploy:
cd lambda/*/ && \
rm -rf __pycache__
command -v ask || npm install -g ask-cli
# Does a forced deployment of the Alexa Skill and Lambda function. This overrides any changes made
# directly in the Alexa/AWS consoles. Dependencies must be installed first.
#
# Requires the ASK CLI, which will be installed if it isn't already:
# https://developer.amazon.com/docs/smapi/quick-start-alexa-skills-kit-command-line-interface.html
deploy: prepare-deploy
ask deploy --force
# Like the above, but for the Lambda function only.
lambda: prepare-deploy
ask deploy --force --target lambda