1
0
mirror of https://github.com/openshift/source-to-image.git synced 2026-02-05 12:44:54 +01:00

Added govet

This commit is contained in:
Maciej Szulik
2015-08-25 16:11:55 +02:00
parent b012dca728
commit 276652b512
6 changed files with 96 additions and 9 deletions

View File

@@ -5,14 +5,12 @@ go:
- 1.5
install:
- go get golang.org/x/tools/cmd/cover
- go get -u github.com/golang/lint/golint
- ./hack/verify-gofmt.sh
- ./hack/verify-golint.sh || true
- ./hack/build-go.sh
- make install-travis
script:
- STI_RACE="-race" STI_COVER="-cover -covermode=atomic" ./hack/test-go.sh "" -p=4
- make check TESTFLAGS="-p=4" TESTS="''" # empty quotes are because hack/test-go.sh requires 2 args
notifications:
irc: "chat.freenode.net#openshift-dev"
sudo: false

View File

@@ -24,6 +24,26 @@ all build:
hack/build-go.sh
.PHONY: all build
# Verify code is properly organized.
#
# Example:
# make verify
verify: build
hack/verify-gofmt.sh
hack/verify-golint.sh || true
hack/verify-govet.sh || true
.PHONY: verify
# Install travis dependencies
#
# Example:
# make install-travis
install-travis:
hack/install-tools.sh
.PHONY: install-travis
# Build and run tests.
#
# Args:
@@ -36,8 +56,8 @@ all build:
# make check
# make test
# make check WHAT=pkg/build GOFLAGS=-v
check test:
hack/test-go.sh $(WHAT) $(TESTS)
check test: verify
STI_COVER="-cover -covermode=atomic" STI_RACE="-race" hack/test-go.sh $(WHAT) $(TESTS)
.PHONY: check test
# Remove all build artifacts.

11
hack/install-tools.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -e
STI_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${STI_ROOT}/hack/common.sh"
GO_VERSION=($(go version))
echo "Detected go version: $(go version)"
go get golang.org/x/tools/cmd/cover github.com/golang/lint/golint golang.org/x/tools/cmd/vet

View File

@@ -46,7 +46,7 @@ if [ -z ${STI_RACE+x} ]; then
STI_RACE=""
fi
STI_TIMEOUT=${STI_TIMEOUT:--timeout 30s}
STI_TIMEOUT=${STI_TIMEOUT:--timeout 60s}
if [ "${1-}" != "" ]; then
test_packages="$STI_GO_PACKAGE/$1"

17
hack/util.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
# Provides simple utility functions
find_files() {
find . -not \( \
\( \
-wholename './_output' \
-o -wholename './_tools' \
-o -wholename './.*' \
-o -wholename './pkg/assets/bindata.go' \
-o -wholename './pkg/assets/*/bindata.go' \
-o -wholename './openshift.local.*' \
-o -wholename '*/Godeps/*' \
\) -prune \
\) -name '*.go' | sort -u
}

41
hack/verify-govet.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
set -o nounset
set -o pipefail
GO_VERSION=($(go version))
if [[ -z $(echo "${GO_VERSION[2]}" | grep -E 'go1.4|go1.5') ]]; then
echo "Unknown go version '${GO_VERSION}', skipping go vet."
exit 0
fi
STI_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${STI_ROOT}/hack/common.sh"
source "${STI_ROOT}/hack/util.sh"
cd "${STI_ROOT}"
mkdir -p _output/govet
FAILURE=false
test_dirs=$(find_files | cut -d '/' -f 1-2 | sort -u)
for test_dir in $test_dirs
do
go tool vet -shadow=false \
$test_dir
if [ "$?" -ne 0 ]
then
FAILURE=true
fi
done
# We don't want to exit on the first failure of go vet, so just keep track of
# whether a failure occured or not.
if $FAILURE
then
echo "FAILURE: go vet failed!"
exit 1
else
echo "SUCCESS: go vet succeded!"
exit 0
fi