-
Notifications
You must be signed in to change notification settings - Fork 25
/
Taskfile.yaml
103 lines (90 loc) · 3.25 KB
/
Taskfile.yaml
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
version: '3'
vars:
APP_BIN_PATH: bin/app
APP_MAIN_DIR: cmd
# wire
WIRE_ENTRY_DIR: ./internal/command
# swagger
API_SWAGGER_SCAN_DIR: internal/app/facade/server/http
API_SWAGGER_SCAN_ENTRY: http.go
API_SWAGGER_OUT_DIR: internal/app/facade/server/http/api/docs
# proto
API_PROTO_GENERATE_FILE: internal/app/facade/server/grpc/api/generate.go
tasks:
build:
desc: automatically compile binaries according to the platform
cmds:
- task: generate
- |
{{- if eq OS "windows" -}}
CGO_ENABLED=0 GOOS=windows go build {{.FLAGS}} -o {{.APP_BIN_PATH}}.exe {{.APP_MAIN_DIR}}/main.go
{{- else -}}
CGO_ENABLED=0 go build {{.FLAGS}} -o {{.APP_BIN_PATH}} {{.APP_MAIN_DIR}}/main.go
{{- end -}}
build-linux:
desc: compile the binaries for the linux platform
cmds:
- task: generate
- CGO_ENABLED=0 GOOS=linux go build {{.FLAGS}} -o {{.APP_BIN_PATH}}_linux {{.APP_MAIN_DIR}}/main.go
build-windows:
desc: compile the binaries for the windows platform
cmds:
- task: generate
- CGO_ENABLED=0 GOOS=windows go build {{.FLAGS}} -o {{.APP_BIN_PATH}}_windows.exe {{.APP_MAIN_DIR}}/main.go
build-mac:
desc: compile the binaries for the mac platform
cmds:
- task: generate
- CGO_ENABLED=0 GOOS=darwin go build {{.FLAGS}} -o {{.APP_BIN_PATH}}_darwin {{.APP_MAIN_DIR}}/main.go
generate:
desc: build the files required for the application
cmd: go generate ./...
wire:
desc: automatically inject dependencies
cmd: wire {{.WIRE_ENTRY_DIR}}
download:
desc: download the dependencies required for compilation
run: once
cmds:
- go env -w GOPROXY=https://goproxy.cn,direct
- go mod download
- go get -u github.com/davecgh/go-spew/spew
- go get github.com/google/wire/cmd/wire@main
- go install github.com/google/wire/cmd/wire@main
- go install github.com/air-verse/air@latest
- go install github.com/swaggo/swag/cmd/swag@latest
- go install github.com/golang/mock/mockgen@latest
- go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
- go install github.com/envoyproxy/protoc-gen-validate@latest
- go install github.com/favadi/protoc-go-inject-tag@latest
- go install entgo.io/ent/cmd/ent@latest
- go install github.com/incu6us/goimports-reviser/v3@latest
clean:
desc: clean up the binaries generated by the compilation
silent: true
prompt: This command will remove the generated binaries, Do you want to continue?
cmd: |
for f in {{.APP_BIN_PATH}}*
do
rm -rf ${f}
done
test:
desc: unit tests
cmd: go test -gcflags=-l -v {{.FLAGS}} ./...
doc:
desc: generate documentation
silent: true
cmds:
- defer: rm -rf openapi.yaml
- swag fmt -d {{.API_SWAGGER_SCAN_DIR}} -g {{.API_SWAGGER_SCAN_ENTRY}}
- swag init -d {{.API_SWAGGER_SCAN_DIR}} -g {{.API_SWAGGER_SCAN_ENTRY}} -o {{.API_SWAGGER_OUT_DIR}} --parseInternal
proto:
desc: generate the proto file
silent: true
cmd: go generate {{.API_PROTO_GENERATE_FILE}}
format:
desc: format all go files
silent: true
cmds:
- gofmt -w .
- goimports-reviser -imports-order std,company,general,project -format -recursive ./...