-
Notifications
You must be signed in to change notification settings - Fork 0
/
lint.sh
executable file
·54 lines (44 loc) · 1.19 KB
/
lint.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
#!/bin/sh
set -e
LINTER_VERSION=v1.61.0
USER_UID=$(id -u)
case "$1" in
"")
;;
"coverage")
COVERAGE=1
;;
"lint")
LINT=1
;;
*)
echo "Usage: $0 [coverage|lint]"
echo " coverage: run test coverage"
echo " lint: run linter only, skip tests"
exit 1
esac
if docker volume ls | grep -q squirreldb-buildcache; then
GO_MOUNT_CACHE="-v squirreldb-buildcache:/go/pkg"
fi
if [ "${COVERAGE}" = "1" ]; then
docker run --rm -v "$(pwd)":/app ${GO_MOUNT_CACHE} -e HOME=/go/pkg \
-w /app golangci/golangci-lint:${LINTER_VERSION} \
sh -exc "
go test ./... --coverprofile=coverage.out
go tool cover -html=coverage.out -o coverage.html
chown $USER_UID coverage.out coverage.html
"
exit
fi
if [ "${LINT}" != "1" ]; then
docker run --rm -v "$(pwd)":/app ${GO_MOUNT_CACHE} -e HOME=/go/pkg \
-w /app golangci/golangci-lint:${LINTER_VERSION} \
sh -exc "
go test ./...
go test -race ./... -short
"
fi
docker run --rm -v "$(pwd)":/app ${GO_MOUNT_CACHE} -e HOME=/go/pkg \
-e GOOS=linux -e GOARCH=amd64 -w /app golangci/golangci-lint:${LINTER_VERSION} \
golangci-lint run
echo "Success"