-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
86 lines (64 loc) · 2.19 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
82
83
84
85
86
OS=linux
ARCH=amd64
ROOT=$(GOPATH)/src/github.com/hidenari-yuda/go-docker-template
.PHONY: setup build wire run up down enc-envfile migrate-new migrate-up migrate-down test test-all repository-test entity-test mock repository-mock interactor-mock driver-mock usecase-mock
setup:
go install -v github.com/google/wire/cmd/[email protected]
go install -v github.com/rubenv/sql-migrate/[email protected]
go install -v github.com/golang/mock/[email protected]
go install -v github.com/cosmtrek/[email protected]
make mock
.PHONY: build go
build:
cd cmd
go mod tidy
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /go/bin/app
.PHONY: wire
wire:
wire ./infra/di/wire.go
.PHONY: run
run:
# export APP_ENV=local
air -c .conf/.air.toml
up:
docker-compose -f docker-compose.yml up --build -d --log-opt max-size=100m --log-opt max-file=10 my-docker-image
down:
docker-compose -f docker-compose.yml down --volumes
# encode envfile
encode-envfile:
cat .env | base64 > env.pem
# decode envfile
# cat env.pem | base64 -d | xargs -I{} echo {} > .env
decode-envfile:
cat env.pem | base64 -d > .env
migrate-new:
sql-migrate new -env=local -config=.conf/dbconfig.yml ${FILE}
migrate-up:
sql-migrate up -config=.conf/dbconfig.yml -env=local
migrate-down:
sql-migrate down -config=.conf/dbconfig.yml -env=local
## Test Command
test:
make down-test-db
make up-test-db
make test-all
make down-test-db
test-all:
make mock
make repository-test
# make entity-test
repository-test:
DB_NAME=go-docker-template_test go test -v ./tests/repository/*_test.go
#entity-test:
#go test -v ./tests/entity/*_test.go
## Mock
mock: repository-mock interactor-mock driver-mock # usecase-mock
repository-mock:
mockgen -source ./usecase/repository.go -destination ./mock/mock_usecase/mock_repository.go
interactor-mock:
basename -a ./usecase/interactor/*.go | sed 's/.go//' | xargs -IFILE mockgen -source ./usecase/interactor/FILE.go -destination ./mock/mock_interactor/mock_FILE.go
rm ./mock/mock_interactor/mock_wire_set.go
driver-mock:
mockgen -source ./usecase/driver.go -destination ./mock/mock_usecase/mock_driver.go
usecase-mock:
mockgen -source ./usecase/usecase.go -destination ./mock/mock_usecase/mock_usecase.go