-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvet.sh
executable file
·85 lines (70 loc) · 1.85 KB
/
vet.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
#!/bin/bash
set -ex # Exit on error; debugging enabled.
set -o pipefail # Fail a pipe if any sub-command fails.
# not makes sure the command passed to it does not exit with a return code of 0.
not() {
# This is required instead of the earlier (! $COMMAND) because subshells and
# pipefail don't work the same on Darwin as in Linux.
! "$@"
}
die() {
echo "$@" >&2
exit 1
}
check_status() {
# Check to make sure it's safe to modify the user's git repo.
local out=$(git status --porcelain)
if [ ! -z "$out" ]; then
echo "status not clean"
echo $out
exit 1
fi
}
check_status
# Undo any edits made by this script.
cleanup() {
git reset --hard HEAD
}
trap cleanup EXIT
PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"
if [[ "$1" = "-install" ]]; then
# Check for module support
if go help mod >& /dev/null; then
pushd ./test/tools
# Install the pinned versions as defined in module tools.
go install \
golang.org/x/tools/cmd/goimports@latest
go install \
github.com/client9/misspell/cmd/misspell@latest
go install \
github.com/gogo/protobuf/protoc-gen-gogoslick@latest
go install \
honnef.co/go/tools/cmd/[email protected]
go install \
github.com/itchyny/gojq/cmd/gojq@latest
go install \
github.com/mgechev/[email protected]
go install \
github.com/daixiang0/[email protected]
go install \
github.com/golangci/golangci-lint/cmd/[email protected]
go install \
github.com/abice/[email protected]
go install \
go.uber.org/mock/mockgen@latest
go install \
github.com/segmentio/golines@latest
popd
else
echo "we don't support old go get anymore"
exit 1
fi
exit 0
elif [[ "$#" -ne 0 ]]; then
die "Unknown argument(s): $*"
fi
make fmt check &&
check_status || \
(git status; git --no-pager diff; exit 1)
set +x
echo SUCCESS