-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtest
executable file
·42 lines (30 loc) · 893 Bytes
/
test
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
#!/usr/bin/env bash
set -eu
ORG_PATH="github.com/flatcar"
REPO_PATH="${ORG_PATH}/container-linux-config-transpiler"
if [ ! -h gopath/src/${REPO_PATH} ]; then
mkdir -p gopath/src/${ORG_PATH}
ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
fi
export GOPATH=${PWD}/gopath
SRC=$(find . -name '*.go' \
-not -path "./vendor/*")
PKGS=$(cd gopath/src/${REPO_PATH}; go list ./... | \
grep --invert-match /vendor)
FORMATTABLE=$(cd gopath/src/${REPO_PATH}; ls -d */ | \
grep --invert-match --extended-regexp '(vendor/)')
echo "Checking gofix..."
go tool fix -diff $SRC
echo "Checking gofmt..."
fmtRes=$(gofmt -d -l $FORMATTABLE)
if [ -n "${fmtRes}" ]; then
echo -e "gofmt checking failed:\n${fmtRes}"
exit 2
fi
echo "Checking govet..."
go vet $PKGS
echo "Running tests..."
go test $PKGS -cover
echo "Checking documentation..."
go run internal/util/tools/docs.go
echo "Success"