-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (67 loc) · 3.32 KB
/
Makefile
File metadata and controls
88 lines (67 loc) · 3.32 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
SHELL := /bin/sh
PY_VERSION := 3.8
export PYTHONUNBUFFERED := 1
SRC_DIR := src
BIN_DIR := bin
SAM_DIR := .aws-sam
SRC_TEMPLATE_NAME := comprehend-semi-structured-documents-annotation-template
# Required environment variables (user must override)
# user can optionally override the following by setting environment variables with the same names before running make
# Path to system pip
PIP ?= pip
# Default AWS CLI region
AWS_REGION ?= us-west-2
# AWS CLI profile names
AWS_PROFILE ?= default
# Default value for prehuman lambda timeout in second
PRE_HUMAN_LAMBDA_TIMEOUT_IN_SECONDS ?= 300
# Default value for consolidation lambda timeout in second
CONSOLIDATION_LAMBDA_TIMEOUT_IN_SECONDS ?= 300
PYTHON := $(shell /usr/bin/which python$(PY_VERSION))
.DEFAULT_GOAL := build
clean:
rm -f $(SRC_DIR)/requirements.txt
rm -rf $(SAM_DIR)
rm -rf samconfig.toml
rm -rf .pytest_cache
rm -rf src/__pycache__
# Use this command after checking out the package to install tools and dependencies from pipfile.lock
bootstrap:
$(PYTHON) -m $(PIP) install aws-sam-cli
$(PYTHON) -m $(PIP) install pipenv
$(PYTHON) -m $(PIP) install awscli
$(PYTHON) -m pipenv sync -d # Install locked dependencies
# Activate
activate:
$(PYTHON) -m pipenv shell # activate the virtualenv
# Update the dependency
update:
$(PYTHON) -m pipenv install # Install dependencies and update the pipfile.lock file
$(PYTHON) -m pipenv sync --dev # Install locked dependencies from pipfile.lock
$(PYTHON) -m pipenv requirements > $(SRC_DIR)/requirements.txt
# Run basic python checkstyle and cnf-lint, and build the CFN template using sam cli
build:
$(PYTHON) -m pipenv requirements > $(SRC_DIR)/requirements.txt
$(PYTHON) -m pipenv run flake8 $(SRC_DIR) $(BIN_DIR)
$(PYTHON) -m pipenv run pydocstyle $(SRC_DIR) $(BIN_DIR)
$(PYTHON) -m pipenv run cfn-lint $(SRC_TEMPLATE_NAME).yml
sam build --profile $(AWS_PROFILE) --template $(SRC_TEMPLATE_NAME).yml
unit-testing: build
$(PYTHON) -m pipenv run py.test --cov=$(SRC_DIR) --cov=$(BIN_DIR) --cov-fail-under=80 -vv test/unit -s --cov-report html
# can be triggered as `make integ-testing LAMBDA_NAME=access-control`
integ-testing: unit-testing
$(PYTHON) -m pipenv run py.test -s -vv test/integ/test_$(LAMBDA_NAME).py
# Deploy the sam packaged CFN template with --guided option
deploy-guided:
sam deploy -g --profile $(AWS_PROFILE) --region $(AWS_REGION) --parameter-overrides "ParameterKey=PreHumanLambdaTimeoutInSeconds,ParameterValue=$(PRE_HUMAN_LAMBDA_TIMEOUT_IN_SECONDS) ParameterKey=ConsolidationLambdaTimeoutInSeconds,ParameterValue=$(CONSOLIDATION_LAMBDA_TIMEOUT_IN_SECONDS)" --capabilities CAPABILITY_IAM
# Deploy the sam packaged CFN template without --guided option, use default samconfig.toml if present
deploy:
sam deploy --profile $(AWS_PROFILE) --region $(AWS_REGION) --parameter-overrides "ParameterKey=PreHumanLambdaTimeoutInSeconds,ParameterValue=$(PRE_HUMAN_LAMBDA_TIMEOUT_IN_SECONDS) ParameterKey=ConsolidationLambdaTimeoutInSeconds,ParameterValue=$(CONSOLIDATION_LAMBDA_TIMEOUT_IN_SECONDS)" --capabilities CAPABILITY_IAM
# chain bootstrap, build, and deploy-guided commands
ready-and-deploy-guided:
make bootstrap
make build
make deploy-guided || true # skip errors with 'true' in case stack already exists
make activate