-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.toml
155 lines (155 loc) · 6.39 KB
/
Makefile.toml
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# config
[config]
skip_core_tasks = true
# run
## api server
[tasks."run.server"]
description = "run api server"
script = '''
go run ./app/presentation/api/jrp-server/main.go
'''
# update
## `./CREDITS`
[tasks."update.credits"]
description = "update `./CREDITS`"
script = '''
gocredits -skip-missing . > ./CREDITS
'''
## mocks
[tasks."update.mocks"]
description = "update mocks"
script = '''
# ./app/application
mockgen -source=./app/application/wnjpn/word_query_service.go -destination=./app/application/wnjpn/word_query_service_mock.go -package=wnjpn
# ./app/infrastructure
mockgen -source=./app/infrastructure/database/connection.go -destination=./app/infrastructure/database/connection_mock.go -package=database
mockgen -source=./app/infrastructure/database/connection_manager.go -destination=./app/infrastructure/database/connection_manager_mock.go -package=database
# ./app/domain
mockgen -source=./app/domain/jrp/history/history_repository.go -destination=./app/domain/jrp/history/history_repository_mock.go -package=history
# ./app/presentation/api/jrp-server/server
mockgen -source=./app/presentation/api/jrp-server/server/server.go -destination=./app/presentation/api/jrp-server/server/server_mock.go -package=server
# ./app/presentation/cli/jrp/command
mockgen -source=./app/presentation/cli/jrp/command/command.go -destination=./app/presentation/cli/jrp/command/command_mock.go -package=command
# ./pkg/proxy
mockgen -source=./pkg/proxy/buffer.go -destination=./pkg/proxy/buffer_mock.go -package=proxy
mockgen -source=./pkg/proxy/cobra.go -destination=./pkg/proxy/cobra_mock.go -package=proxy
mockgen -source=./pkg/proxy/debug.go -destination=./pkg/proxy/debug_mock.go -package=proxy
mockgen -source=./pkg/proxy/echo.go -destination=./pkg/proxy/echo_mock.go -package=proxy
mockgen -source=./pkg/proxy/envconfig.go -destination=./pkg/proxy/envconfig_mock.go -package=proxy
mockgen -source=./pkg/proxy/gzip.go -destination=./pkg/proxy/gzip_mock.go -package=proxy
mockgen -source=./pkg/proxy/http.go -destination=./pkg/proxy/http_mock.go -package=proxy
mockgen -source=./pkg/proxy/io.go -destination=./pkg/proxy/io_mock.go -package=proxy
mockgen -source=./pkg/proxy/json.go -destination=./pkg/proxy/json_mock.go -package=proxy
mockgen -source=./pkg/proxy/keyboard.go -destination=./pkg/proxy/keyboard_mock.go -package=proxy
mockgen -source=./pkg/proxy/os.go -destination=./pkg/proxy/os_mock.go -package=proxy
mockgen -source=./pkg/proxy/pflag.go -destination=./pkg/proxy/pflag_mock.go -package=proxy
mockgen -source=./pkg/proxy/promptui.go -destination=./pkg/proxy/promptui_mock.go -package=proxy
mockgen -source=./pkg/proxy/rand.go -destination=./pkg/proxy/rand_mock.go -package=proxy
mockgen -source=./pkg/proxy/spinner.go -destination=./pkg/proxy/spinner_mock.go -package=proxy
mockgen -source=./pkg/proxy/sql.go -destination=./pkg/proxy/sql_mock.go -package=proxy
mockgen -source=./pkg/proxy/tablewriter.go -destination=./pkg/proxy/tablewriter_mock.go -package=proxy
# ./pkg/utility
mockgen -source=./pkg/utility/capture.go -destination=./pkg/utility/capture_mock.go -package=utility
mockgen -source=./pkg/utility/download_util.go -destination=./pkg/utility/download_util_mock.go -package=utility
mockgen -source=./pkg/utility/file_util.go -destination=./pkg/utility/file_util_mock.go -package=utility
mockgen -source=./pkg/utility/json_util.go -destination=./pkg/utility/json_util_mock.go -package=utility
mockgen -source=./pkg/utility/keyboard_util.go -destination=./pkg/utility/keyboard_util_mock.go -package=utility
mockgen -source=./pkg/utility/prompt_util.go -destination=./pkg/utility/prompt_util_mock.go -package=utility
mockgen -source=./pkg/utility/rand_util.go -destination=./pkg/utility/rand_util_mock.go -package=utility
mockgen -source=./pkg/utility/spinner_util.go -destination=./pkg/utility/spinner_util_mock.go -package=utility
mockgen -source=./pkg/utility/strings_util.go -destination=./pkg/utility/strings_util_mock.go -package=utility
mockgen -source=./pkg/utility/tablewriter_util.go -destination=./pkg/utility/tablewriter_util_mock.go -package=utility
mockgen -source=./pkg/utility/version_util.go -destination=./pkg/utility/version_util_mock.go -package=utility
'''
## swagger
[tasks."update.swagger"]
description = "update swagger files"
script = '''
swag init -g ./app/presentation/api/jrp-server/main.go --parseDependency --output ./docs
'''
# container
## build container
[tasks."container.build"]
description = "build container"
script='''
set -e
if [ -f "./container.exist" ]; then
echo "container already exist"
exit 1
fi
docker-compose -f docker-compose.yml build --no-cache
touch ./container.exist
'''
## down container
[tasks."container.down"]
description = "down container"
script='''
set -e
docker-compose down
docker image prune -af
if [ -f "./container.exist" ]; then
rm ./container.exist
fi
'''
# test
## in local
[tasks."test.local"]
description = "execute tests in local"
script='''
set -e
if [ -f "./test.run" ]; then
echo "test already running"
exit 1
fi
touch test.run
go test -v -p 1 ./... -cover -coverprofile=./cover.out
grep -v -E "(_mock\.go|/mock/|/proxy/)" ./cover.out > ./cover.out.tmp && mv ./cover.out.tmp ./cover.out
go tool cover -html=./cover.out -o ./docs/coverage.html
rm ./cover.out
if [ -f "./test.run" ]; then
rm ./test.run
fi
'''
## in container
[tasks."test.container"]
description = "execute tests in container"
script='''
set -e
if ! [ -f "./container.exist" ]; then
echo "container not exist"
exit 1
fi
if [ -f "./test.run" ]; then
echo "test already running"
exit 1
fi
touch test.run
docker-compose -f docker-compose.yml up --abort-on-container-exit jrp-test-container
CONTAINER_ID=$(docker ps -a -q --filter "name=jrp-test-container" --filter "status=exited")
docker cp ${CONTAINER_ID}:/jrp/docs/coverage.html ./docs/coverage.html
rm ./test.run
'''
## in container (once)
[tasks."test.container.once"]
description = "execute tests in container"
script='''
set -e
if [ -f "./container.exist" ]; then
echo "container already exist"
exit 1
fi
if [ -f "./test.run" ]; then
echo "test already running"
exit 1
fi
touch ./container.exist
touch test.run
docker-compose -f docker-compose.yml build --no-cache
docker-compose -f docker-compose.yml up --abort-on-container-exit jrp-test-container
CONTAINER_ID=$(docker ps -a -q --filter "name=jrp-test-container" --filter "status=exited")
docker cp ${CONTAINER_ID}:/jrp/docs/coverage.html ./docs/coverage.html
docker-compose down
docker image prune -af
rm ./test.run
rm ./container.exist
'''