-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
197 lines (160 loc) · 5.01 KB
/
Taskfile.yml
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
version: "3"
#
# sub namespace: https://taskfile.dev/#/usage?id=including-other-taskfiles
#
includes:
# way: global path
# - https://github.com/better-sre/config
std:
taskfile: ~/.local/task/better-sre/config/Taskfile.yml # TODO: please create `~/.task/` first before use
dir: ~/.local/task/better-sre/config # global path
optional: true # safeguard, if not found, no error
auto:
aliases: [ "automation" ]
taskfile: packages/go-automation/
dir: packages/go-automation/
gui:
taskfile: packages/go-gui/
dir: packages/go-gui
crawler:
aliases: [ "cr" ]
taskfile: packages/go-crawler/
dir: packages/go-crawler
crypto:
aliases: [ "cry", "cp" ]
taskfile: packages/go-crypto/
dir: packages/go-crypto
try:zero:
taskfile: packages/try/go-zero/
dir: packages/try/go-zero/
try:kratos:
taskfile: packages/try/go-kratos/
dir: packages/try/go-kratos/
try:fiber:
taskfile: packages/try/fiber/
dir: packages/try/fiber/
optional: true
#
# global vars: https://taskfile.dev/#/usage?id=variables
#
vars:
VAR1: "some-var"
# global env:
env:
ENV1: testing
# env file:
dotenv:
- .env
################################################################################################
tasks:
default:
cmds:
- echo "hello world"
init:
cmds:
- cp .env.local .env
- task: install
- task: install:pkg
install:
cmds:
- brew install cookiecutter
- brew install go-task/tap/go-task
- brew install protobuf
- go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
install:pkg:
cmds:
- go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
- go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
- go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
- go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest
- go install github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2@latest
- go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest
################################################################################
#
# 创建 monorepo + go-kratos:
#
new:mono:
cmds:
- cookiecutter https://github.com/better-go/cookiecutter-go.git --directory="mono-repo/go-kratos"
new:app:
cmds:
# - cd ${NEW_APP_RELATIVE_PATH}; kratos new ${NEW_APP_NAME}
- cd ${NEW_APP_RELATIVE_PATH}; kratos new ${NEW_APP_NAME} -r https://github.com/better-go/kratos-layout.git -b app
- echo ${NEW_APP_RELATIVE_PATH}${NEW_APP_NAME}
- cd ${NEW_APP_RELATIVE_PATH}${NEW_APP_NAME}; rm -rf cmd/${NEW_APP_NAME};
- cd ${NEW_APP_RELATIVE_PATH}${NEW_APP_NAME}; task tidy
- cd ${NEW_APP_RELATIVE_PATH}${NEW_APP_NAME}; task proto:gen
################################################################################
work:add:
cmds:
- go work use packages/try/go-zero
work:sync:
cmds:
- go work sync
api:test:rpc:
cmds:
- curl -i 'http://127.0.0.1:8000/helloworld/kratos'
- curl -i 'http://127.0.0.1:8001/helloworld/kratos'
ignore_error: true
api:test:
cmds:
- curl -i 'http://127.0.0.1:8001/helloworld/kratos'
open:docs:
cmds:
- open https://entgo.io/zh/docs/code-gen/
open:infra:
cmds:
- task std:docker:local:open:infra
up:infra:
cmds:
- task: std:docker:local:up:mysql
- task: std:docker:local:up:redis
- task: std:docker:local:up:consul:v3 # 服务发现/服务注册
- task: std:docker:local:up:jaeger # 链路追踪 # https://go-kratos.dev/docs/component/middleware/tracing
# - task: std:docker:local:up:prometheus
################################################################################
count:
cmds:
- tokei # 代码统计: https://github.com/XAMPPRocky/tokei
# 项目全局 + 批量生成:
proto:gen:all:
cmds:
- |
find ./app -iname "*.proto" -exec \
protoc --proto_path=. \
--proto_path=$(pwd)/pkg/x \
--go_out=paths=source_relative:. \
--go-http_out=paths=source_relative:. \
--go-grpc_out=paths=source_relative:. \
--validate_out=paths=source_relative,lang=go:. \
--openapi_out==paths=source_relative:. \
{} \;
################################################################################
pull:
cmds:
- git config pull.rebase false
- git pull origin main
fetch:
cmds:
- git fetch
- git rebase
- git merge origin/main
quick:
aliases: [ "q" ]
cmds:
- task: commit
# - task: pull
- task: push
ignore_error: true
commit:
aliases: [ "c" ]
cmds:
- git add .
- |
git commit -m 'chore: update' --no-verify
ignore_error: true
push:
aliases: [ "p" ]
cmds:
- git push origin main --tags
- repo_url=`git remote -v | grep push | awk -F ":" '{print $2}' | awk -F ".git" '{print "https://github.com/"$1}'`; open $repo_url