-
Notifications
You must be signed in to change notification settings - Fork 782
Expand file tree
/
Copy pathcheck.sh
More file actions
executable file
·64 lines (56 loc) · 1.36 KB
/
check.sh
File metadata and controls
executable file
·64 lines (56 loc) · 1.36 KB
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
#!/bin/bash
set -e
ACTION=$1
function format() {
echo "Running gofmt ..."
if [[ $1 == "-w" ]]; then
gofmt -w $(find . -type f -name '*.go')
elif [[ $1 == "-l" ]]; then
gofmt -l $(find . -type f -name '*.go')
elif [[ $1 == "-d" ]]; then
gofmt -d $(find . -type f -name '*.go')
else
UNFORMATTED=$(gofmt -l $(find . -type f -name '*.go'))
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 ./...
}
# There is a bug if we define the same json tag in the struct.
# Disable structtag temporarily.
# see: https://github.com/golang/go/issues/40102
function vet() {
echo "Running go vet ..."
(
cd v2
go vet -structtag=false ./...
)
}
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