-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
81 lines (65 loc) · 3.11 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
80
81
CONFIG = config.mk
include $(CONFIG)
BUILD := build/lambda-go
OUTPUT_TEMPLATE := output.yml
INPUT_TEMPATE := template.yml
VERSIONFILE := ./version.go
MAINFILE := ./main.go
MOCK_IFTTT := mock_ifttt_test.go
DEP := .bin/dep
GOBUMP := .bin/gobump
MOCKGEN := .bin/mockgen
SAMLOCAL := .bin/aws-sam-local
.PHONY: deploy
deploy: $(OUTPUT_TEMPLATE) $(SAMLOCAL) $(BUILD)
$(SAMLOCAL) deploy \
--template-file $< \
--stack-name $(CONFIG_CLOUDFORMATION_STACK_NAME) \
--capabilities CAPABILITY_IAM
$(BUILD): $(MAINFILE) $(VERSIONFILE) Makefile config.toml
$(MAKE) install
GOARCH=amd64 GOOS=linux go build -o $@
cp config.toml build/config.toml
$(OUTPUT_TEMPLATE): $(INPUT_TEMPATE) $(BUILD) $(SAMLOCAL)
$(SAMLOCAL) package \
--template-file $< \
--s3-bucket $(CONFIG_CLOUDFORMATION_PACKAGE_S3_BUCKET_NAME) \
--s3-prefix $(CONFIG_CLOUDFORMATION_PACKAGE_S3_PREFIX) \
--output-template-file $@
.PHONY: setup-go
setup-go:
GOBIN=$(abspath .bin) go get -v \
github.com/golang/dep/cmd/dep \
github.com/golang/mock/gomock \
github.com/golang/mock/mockgen \
github.com/motemen/gobump/cmd/gobump \
github.com/awslabs/aws-sam-local
.PHONY: setup-s3
setup-s3:
aws s3 mb s3://$(CONFIG_CLOUDFORMATION_PACKAGE_S3_BUCKET_NAME)
.bin/%: Makefile
@$(MAKE) setup-go
@touch $@
$(VERSIONFILE): $(MAINFILE) $(GOBUMP)
./.bin/gobump patch -w -v
.PHONY: install
install: $(DEP)
$(DEP) ensure
.PHONY: test
test: $(MOCK_IFTTT) config.toml $(SAMLOCAL)
go test -covermode=count -coverprofile=coverage.out
coverage.html: test
go tool cover -html=coverage.out -o $@
config.toml:
cp -n config.toml.sample config.toml
@echo "\033[92mplease edit config.toml \033[0m"
$(MOCK_IFTTT): $(MOCKGEN) vendor/github.com/lorenzobenvenuti/ifttt/ifttt.go
$(MOCKGEN) -package main -source vendor/github.com/lorenzobenvenuti/ifttt/ifttt.go > $@
.PHONY: start_local_server
start_server: $(BUILD) $(SAMLOCAL)
$(SAMLOCAL) local start-api
# not work
.PHONY: integration_test
integration_test:
$(MAKE) start_server &
curl -XPOST http://localhost:3000/ -d '{"team":{"name":"dekokun","url":"https://dekokun.kibe.la/"},"blog":{"id":20,"url":"https://dekokun.kibe.la/@dekokun/20","title":"このLINE通知が来たら何か おかしい!?dekokunに連絡だ!","boards":[{"id":1,"name":"Home"}],"author":{"id":2,"account":"dekokun","real_name":"","url":"https://dekokun.kibe.la/@dekokun","avatar_photo":{"url":"https://cdn.kibe.la/media/public/1633/W1siZiIsInRlYW1fMTYzMy8yMDE3LzAzLzMxLzRrYTNkdGE0aHNfZ3JhdmF0YXJfMjIweDIyMC5wbmciXSxbInAiLCJlbmNvZGUiLCJwbmciXSxbInAiLCJjb252ZXJ0IiwiLWFscGhhIHNldCAtYmFja2dyb3VuZCBub25lIC12aWduZXR0ZSAweDArMCswIl0sWyJwIiwidGh1bWIiLCI0MHg0MCJdXQ/89f0f820ea4bcc6e/file.png"}},"comments":[]},"resource_type":"blog","action":"delete","action_user":{"id":2,"account":"dekokun","real_name":"","url":"https://dekokun.kibe.la/@dekokun","avatar_photo":{"url":"https://cdn.kibe.la/media/public/1633/W1siZiIsInRlYW1fMTYzMy8yMDE3LzAzLzMxLzRrYTNkdGE0aHNfZ3JhdmF0YXJfMjIweDIyMC5wbmciXSxbInAiLCJlbmNvZGUiLCJwbmciXSxbInAiLCJjb252ZXJ0IiwiLWFscGhhIHNldCAtYmFja2dyb3VuZCBub25lIC12aWduZXR0ZSAweDArMCswIl0sWyJwIiwidGh1bWIiLCI0MHg0MCJdXQ/89f0f820ea4bcc6e/file.png"}}}' --dump-header -