-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathMakefile
171 lines (127 loc) · 3.67 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
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
#定义变量
GOPROXY=https://goproxy.io
GO111MODULE=on
#GOTHIRDPKG=${HOME}/gopkg/third
VERSION=$(shell git describe --abbrev=0 --tags)
COMMIT=$(shell git rev-parse --short HEAD)
#project:game prize pusher socket
#type:api srv web
.PHONY : ver
ver :
@echo "执行环境变量"
@chmod +x ./scripts/.variables.sh && ./scripts/.variables.sh
@echo "完成环境变量"
.PHONY : install
install :
@echo "安装环境开始"
@chmod +x ./scripts/install.sh && ./scripts/install.sh ${method}
@echo "安装环境结束"
.PHONY : fmt
fmt :
@echo "格式化代码"
@gofmt -l -w ./
.PHONY : vendor
vendor :
@echo "创建vendor"
@go mod vendor
@echo "结束vendor"
.PHONY : test
test : vendor
@echo "代码测试[覆盖率]"
@go test -mod=vendor -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
.PHONY : onlinetest
onlinetest :
@echo "代码测试[覆盖率]"
@go test -race -cover -coverprofile=coverage.txt -covermode=atomic ./...
#代码检查
.PHONY : check
check :
@echo "代码检查"
@echo "代码静态检查开始"
@go vet ./...
@echo "代码静态检查结束"
@chmod +x ./scripts/check.sh && ./scripts/check.sh
# @chmod +x ./scripts/check.sh && ./scripts/check.sh | tee check.log
.PHONY : build
build : proto builddata dockerfile vendor
@echo "部分编译开始:"$(project)_$(type)
@chmod +x ./scripts/build.sh && ./scripts/build.sh build $(type) $(project)
@echo "部分编译结束"
.PHONY : allbuild
allbuild : proto builddata alldockerfile vendor
@echo "全部编译开始"
@chmod +x ./scripts/build.sh && ./scripts/build.sh allbuild
@echo "全部编译结束"
#生成pb文件
.PHONY : proto
proto :
@echo "生成proto开始"
@chmod +x ./scripts/proto.sh && ./scripts/proto.sh
@echo "生成proto结束"
#生成dockerfile
.PHONY : dockerfile
dockerfile :
@echo "部分生成dockerfile开始"
@chmod +x ./scripts/dockerfile.sh && ./scripts/dockerfile.sh df $(type) $(project)
@echo "部分生成Dockerfile结束"
.PHONY : alldockerfile
alldockerfile :
@echo "全部生成dockerfile开始"
@chmod +x ./scripts/dockerfile.sh && ./scripts/dockerfile.sh alldf
@echo "全部生成Dockerfile结束"
#compose命令 bin:up dup stop restart kill rm ps
.PHONY : compose
compose :
@chmod +x ./scripts/docker-compose.sh && ./scripts/docker-compose.sh $(bin)
.PHONY : builddata
builddata :
@echo "打包静态数据"
@chmod +x ./scripts/builddata.sh && ./scripts/builddata.sh
#编辑k8s配置
.PHONY : k8sconfig
k8sconfig :
@echo "配置k8s"
@chmod +x ./scripts/k8sconf.sh && ./scripts/k8sconf.sh
# 代码风格检查
.PHONY : lint
lint :
@golangci-lint run -v ./...
#pprof性能分析
.PHONY : pprofon
pprofon :
@chmod +x ./scripts/pprof.sh && ./scripts/pprof.sh pprofon $(type) $(project)
#pprof性能分析
.PHONY : pprofoff
pprofoff :
@chmod +x ./scripts/pprof.sh && ./scripts/pprof.sh pprofoff $(type) $(project)
#提交代码
.PHONY : push
push : fmt check test
git add -A
git commit -m $(msg)
git push origin master
#清理
.PHONY : clean
clean :
@git clean -dxf -e .idea
#发行版本
#查看下一个版本号
next-version :
@chmod +x ./scripts/version.sh && ./scripts/version.sh
#使用godoc生成markdown文档[godoc2ghmd](https://github.com/GandalfUK/godoc2ghmd)
gendoc :
godoc2ghmd `pwd`/srv/account/ > `pwd`/docs/godoc2md/account.md
godoc2ghmd `pwd`/srv/user/ > `pwd`/docs/godoc2md/user.md
#清理没用的docker镜像
docker-clean:
docker images
docker image prune --force
docker-kill:
docker kill `docker ps -q` || true
docker-remove:
docker rm --force `docker ps -a -q` || true
docker rmi --force `docker images -q` || true
# 使用goreleaser编译项目
.PHONY : release
release:
goreleaser --snapshot --skip-publish --rm-dist