-
Notifications
You must be signed in to change notification settings - Fork 719
/
Copy pathcheck.sh
executable file
·59 lines (51 loc) · 1.19 KB
/
check.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
#!/bin/bash
set -e
ACTION=$1
function format() {
echo "Running gofmt ..."
if [[ $1 == "-w" ]]; then
gofmt -w $(find . -type f -name '*.go' -not -path "./vendor/*")
elif [[ $1 == "-l" ]]; then
gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*")
else
UNFORMATTED=$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))
if [[ ! -z "$UNFORMATTED" ]]; then
echo "The following files are not properly formatted:"
echo "$UNFORMATTED"
exit 1
fi
fi
}
function lint() {
echo "Running golint ..."
go install golang.org/x/lint/golint
golint -set_exit_status ./...
}
function vet() {
echo "Running go vet ..."
(
cd v2
go vet ./...
)
}
function unittest() {
echo "Running go test ..."
(
cd v2
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
)
}
function integration() {
echo "Running integration test ..."
cd v2
go test -v -tags=integration -race -coverprofile=coverage.txt -covermode=atomic ./...
}
if [[ -z $ACTION ]]; then
format
# lint
vet
unittest
else
shift
$ACTION "$@"
fi