This repository has been archived by the owner on Mar 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
80 lines (64 loc) · 2.52 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
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
BUILD_DIR = build
EXAMPLES = api-gateway kinesis s3 sns dhall wai
.PHONY: build
build: ## compile and test
stack build --docker --test --copy-bins --local-bin-path ${BUILD_DIR}
.PHONY: dev
dev: ## automatically compile and test when a file is written
stack build --fast --test --file-watch
.PHONY: clean
clean: ## remove all cached files
stack clean --full
sam-tests: sam-template-all package-all ## compile, test, and invoke each example with a generated event
sam local generate-event apigateway aws-proxy | \
sam local invoke "APIGatewayEcho" -t build/api-gateway.yaml --event -
sam local generate-event kinesis get-records | \
sam local invoke "KinesisEcho" -t build/kinesis.yaml --event -
sam local generate-event s3 delete | \
sam local invoke "S3Echo" -t build/s3.yaml --event -
sam local generate-event sns notification | \
sam local invoke "SNSEcho" -t build/sns.yaml --event -
sam local invoke "DhallEcho" -t build/dhall.yaml --event events/example.json
cat examples/wai/request-get-hello.json | \
sam local invoke "LambdaWaiTest" -t build/wai.yaml --event -
.PHONY: package-all
package-all: build
$(foreach EXAMPLE,$(EXAMPLES),NAME=$(EXAMPLE) $(MAKE) package;)
.PHONY: package
package:
cp ${BUILD_DIR}/${NAME}-exe ${BUILD_DIR}/bootstrap
cd ${BUILD_DIR} && zip ${NAME}.zip bootstrap && rm bootstrap
.PHONY: upload
upload: sam-template ## upload lambda to S3 using SAM CLI
sam package \
--template-file ${BUILD_DIR}/${NAME}.yaml \
--s3-bucket ${S3_BUCKET} \
--output-template-file ${BUILD_DIR}/${NAME}-S3.yaml
.PHONY: sam-template-all
sam-template-all:
$(foreach EXAMPLE,$(EXAMPLES),NAME=$(EXAMPLE) $(MAKE) sam-template;)
.PHONY: sam-template
sam-template:
sed -e "s/{{ZIP_FILE_PATH}}/${NAME}.zip/g" examples/${NAME}/template.yaml > ${BUILD_DIR}/${NAME}.yaml
sam validate -t ${BUILD_DIR}/${NAME}.yaml
.PHONY: deploy
deploy: upload ## deploy lambda to AWS using SAM CLI
sam deploy \
--template-file ${BUILD_DIR}/${NAME}-S3.yaml \
--stack-name yambda-${NAME} \
--capabilities CAPABILITY_IAM
.PHONY: linted
linted: ## run linter
hlint -j --git
.PHONY: stylish
stylish: ## run stylish haskell code formatter
find . -name '*.hs' | xargs stylish-haskell -i
PACKAGES = stylish-haskell hlint
.PHONY: ready
ready: ## pull the docker image used to build, install code formatter, etc
stack docker pull
for i in $(PACKAGES); do stack install $$i ; done
.PHONY: help
help: ## help
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-18s\033[0m %s\n", $$1, $$2}'