add Travis CI, and pre-commit hooks

This commit is contained in:
Amrit Panesar committed 2017-12-27 22:55:29 -08:00
1 parent 325a21f38d
commit 8d951f617b
3 files changed
+58 -11

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash
GOFMT_FILES=$(gofmt -l .)
if [ -n "${GOFMT_FILES}" ]; then
printf >&2 'gofmt failed for the following files:\n%s\n\nplease run "gofmt -w ." on your changes before committing.\n' "${GOFMT_FILES}"
exit 1
fi
GOLINT_ERRORS=$(golint ./... | grep -v "Id should be")
if [ -n "${GOLINT_ERRORS}" ]; then
printf >&2 'golint failed for the following reasons:\n%s\n\nplease run "golint ./..." on your changes before committing.\n' "${GOLINT_ERRORS}"
exit 1
fi
GOVET_ERRORS=$(go tool vet *.go 2>&1)
if [ -n "${GOVET_ERRORS}" ]; then
printf >&2 'go vet failed for the following reasons:\n%s\n\nplease run "go tool vet *.go" on your changes before committing.\n' "${GOVET_ERRORS}"
exit 1
fi
#if [ -z "${NOTEST}" ]; then
# printf >&2 'Running short tests...\n'
# env GOTEST_ERRORS= go test -short -v | egrep 'PASS|ok'
#
# if [ $? -ne 0 ]; then
# printf >&2 'go test failed, please fix before committing.\n'
# exit 1
# fi
#fi