From 60c6e070a5b1fbf6c7aad3942cf00383fb1b3568 Mon Sep 17 00:00:00 2001 From: Victor Marmol Date: Mon, 5 Jan 2015 11:28:06 -0800 Subject: [PATCH] Add Travis check for Gofmt. --- .travis.yml | 3 ++- deploy/check_gofmt.sh | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 deploy/check_gofmt.sh diff --git a/.travis.yml b/.travis.yml index 448ae1f6..cb9c78c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ before_script: - sudo service influxdb start script: - export PATH=$PATH:$HOME/gopath/bin + - ./deploy/check_gofmt.sh . + - go vet github.com/google/cadvisor/... - godep go test -v -race -test.short github.com/google/cadvisor/... - godep go build github.com/google/cadvisor - - go vet github.com/google/cadvisor/... diff --git a/deploy/check_gofmt.sh b/deploy/check_gofmt.sh new file mode 100755 index 00000000..34fd9d7c --- /dev/null +++ b/deploy/check_gofmt.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Check usage. +if [ $# -ne 1 ]; then + echo "USAGE: check_gofmt " + exit 1 +fi + +# Check formatting on non Godep'd code. +GOFMT_PATHS=$(find . -not -wholename "*.git*" -not -wholename "*Godeps*" -not -name "." -type d) + +# Find any files with gofmt problems +BAD_FILES=$(gofmt -s -l $GOFMT_PATHS) + +if [ -n "$BAD_FILES" ]; then + echo "The following files are not properly formatted:" + echo $BAD_FILES + exit 1 +fi