-
Notifications
You must be signed in to change notification settings - Fork 109
/
test.sh
executable file
·45 lines (40 loc) · 1.04 KB
/
test.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
#!/usr/bin/env bash
echo '-----add_go_license-----'
if command -v add_go_license >/dev/null 2>&1; then
add_go_license -d ./ -e 191201771@qq.com -n Chef
else
echo 'CHEFNOTICEME add_go_license not exist!'
fi
echo '-----gofmt-----'
if command -v gofmt >/dev/null 2>&1; then
gofmt -l ./
gofmt -w ./
else
echo 'CHEFNOTICEME gofmt not exist!'
fi
echo '-----goimports-----'
if command -v goimports >/dev/null 2>&1; then
goimports -l ./
goimports -w ./
else
echo 'CHEFNOTICEME goimports not exist!'
fi
echo '-----go vet-----'
for d in $(go list ./... | grep -v vendor); do
if command -v go >/dev/null 2>&1; then
go vet $d
else
echo 'CHEFNOTICEME go vet not exist'
fi
done
# 跑 go test 生成测试覆盖率
echo "-----CI coverage-----"
echo "" > coverage.txt
for d in $(go list ./... | grep -v vendor | grep pkg); do
go test -race -coverprofile=profile.out -covermode=atomic $d
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done
echo 'done.'