-
Notifications
You must be signed in to change notification settings - Fork 9
/
check.sh
executable file
·59 lines (46 loc) · 1.15 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
#!/usr/bin/env bash
set -e
if [ -t 1 ]
then
YELLOW='\033[0;33m'
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
fi
yellow() { printf "${YELLOW}%s${NC}" "$*"; }
green() { printf "${GREEN}%s${NC}" "$*"; }
red() { printf "${RED}%s${NC}" "$*"; }
good() {
echo "$(green "● success:")" "$@"
}
bad() {
ret=$1
shift
echo "$(red "● failed:")" "$@"
exit $ret
}
try() {
"$@" || bad $? "$@" && good "$@"
}
echo "Running go fmt..."
gofmt -s -w ./..
echo "Running unit tests..."
go test -cover -race ./... || exit
{
{
opt='shopt -s extglob nullglob'
gofmt='gofmt -s -w -l !(vendor)/ *.go'
notice=" running: ( $opt; $gofmt; )"
prefix=" $(yellow modified)"
trap 'echo "$notice"; $opt; $gofmt | sed -e "s#^#$prefix #g"' EXIT
}
# comma separate linters (e.g. "gofmt,stylecheck")
additional_linters="gofmt"
try golangci-lint run --enable $additional_linters ./...
trap '' EXIT
}
echo "Running fuzz test..."
go test -fuzz=FuzzIndexAllIgnoreCase -fuzztime 30s
echo -e "${GREEN}================================================="
echo -e "ALL CHECKS PASSED"
echo -e "=================================================${NC}"