forked from webdevelop-pro/migration-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
executable file
·110 lines (87 loc) · 1.75 KB
/
make.sh
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
#!/bin/sh
PKG_LIST=`go list ./... | grep -v /vendor/`
GO_FILES=`find . -name '*.go' | grep -v _test.go`
WORK_DIR=`pwd`
COMPANY=webdevelop-pro
SERVICE=migration-service
docker_build() {
docker build -t ${COMPANY}/${SERVICE} .
}
docker_run() {
docker stop ${SERVICE}
docker rm ${SERVICE}
docker run --name ${SERVICE} --env-file .env.dev -d ${COMPANY}/${SERVICE}
}
build() {
go build -ldflags "-s -w" -o app ./cmd/server/*.go &&
chmod +x app
}
build_test() {
go build -ldflags "-s -w" -o test-migration ./cmd/test-migration/*.go &&
chmod +x test-migration
}
case $1 in
install)
go install golang.org/x/lint/golint
go install github.com/lanre-ade/godoc2md
go install github.com/securego/gosec/cmd/gosec
cp etc/pre-commit .git/hooks/pre-commit
;;
lint)
golint -set_exit_status ${PKG_LIST}
;;
test)
go test -count=1 ${PKG_LIST}
;;
race)
go test -race -short ${PKG_LIST}
;;
memory)
CC=clang go test -msan -short ${PKG_LIST}
;;
coverage)
mkdir /tmp/coverage > /dev/null
rm /tmp/coverage/*.cov
for package in ${PKG_LIST}; do
go test -covermode=count -coverprofile "/tmp/coverage/${package##*/}.cov" "$package" ;
done
tail -q -n +2 /tmp/coverage/*.cov >> /tmp/coverage/coverage.cov
go tool cover -func=/tmp/coverage/coverage.cov
;;
run)
build
./app
;;
gosec)
echo "running gosec"
gosec ./...
;;
build)
build
;;
build-test)
build_test
;;
help)
cat make.sh | grep "^[a-z-]*)"
;;
doc)
for f in $PKG_LIST;
do
folder=${f/github.com\/${COMPANY}\/${SERVICE}\//./}
godoc2md $folder > "${folder}/README.md"
done
;;
docker-build)
docker_build
;;
docker-run)
docker_run
;;
gcloud-deploy)
gcloud builds submit --tag gcr.io/${COMPANY}/${SERVICE}:dev
;;
*)
echo "unknown"
;;
esac