aboutsummaryrefslogtreecommitdiff
path: root/verify
diff options
context:
space:
mode:
authorEric Paris <[email protected]>2015-09-23 15:37:00 -0400
committerEric Paris <[email protected]>2015-09-23 16:19:34 -0400
commitb02994d092faae574c4b87f516f6d7928f739da2 (patch)
tree014098de374523548d92dd8173d155b60d0a2f6a /verify
parent5a13a75b13d132dc7d07dd19fd260257cd9c0290 (diff)
Add more CI checks forcing code cleanliness
Diffstat (limited to 'verify')
-rwxr-xr-xverify/all.sh69
-rwxr-xr-xverify/gofmt.sh19
-rwxr-xr-xverify/golint.sh15
3 files changed, 103 insertions, 0 deletions
diff --git a/verify/all.sh b/verify/all.sh
new file mode 100755
index 0000000..739f89c
--- /dev/null
+++ b/verify/all.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+ROOT=$(dirname "${BASH_SOURCE}")/..
+
+# Some useful colors.
+if [[ -z "${color_start-}" ]]; then
+ declare -r color_start="\033["
+ declare -r color_red="${color_start}0;31m"
+ declare -r color_yellow="${color_start}0;33m"
+ declare -r color_green="${color_start}0;32m"
+ declare -r color_norm="${color_start}0m"
+fi
+
+SILENT=true
+
+function is-excluded {
+ for e in $EXCLUDE; do
+ if [[ $1 -ef ${BASH_SOURCE} ]]; then
+ return
+ fi
+ if [[ $1 -ef "$ROOT/hack/$e" ]]; then
+ return
+ fi
+ done
+ return 1
+}
+
+while getopts ":v" opt; do
+ case $opt in
+ v)
+ SILENT=false
+ ;;
+ \?)
+ echo "Invalid flag: -$OPTARG" >&2
+ exit 1
+ ;;
+ esac
+done
+
+if $SILENT ; then
+ echo "Running in the silent mode, run with -v if you want to see script logs."
+fi
+
+EXCLUDE="all.sh"
+
+ret=0
+for t in `ls $ROOT/verify/*.sh`
+do
+ if is-excluded $t ; then
+ echo "Skipping $t"
+ continue
+ fi
+ if $SILENT ; then
+ echo -e "Verifying $t"
+ if bash "$t" &> /dev/null; then
+ echo -e "${color_green}SUCCESS${color_norm}"
+ else
+ echo -e "${color_red}FAILED${color_norm}"
+ ret=1
+ fi
+ else
+ bash "$t" || ret=1
+ fi
+done
+exit $ret
diff --git a/verify/gofmt.sh b/verify/gofmt.sh
new file mode 100755
index 0000000..f66acf8
--- /dev/null
+++ b/verify/gofmt.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+ROOT=$(dirname "${BASH_SOURCE}")/..
+
+pushd "${ROOT}" > /dev/null
+
+GOFMT=${GOFMT:-"gofmt"}
+bad_files=$(find . -name '*.go' | xargs $GOFMT -s -l)
+if [[ -n "${bad_files}" ]]; then
+ echo "!!! '$GOFMT' needs to be run on the following files: "
+ echo "${bad_files}"
+ exit 1
+fi
+
+# ex: ts=2 sw=2 et filetype=sh
diff --git a/verify/golint.sh b/verify/golint.sh
new file mode 100755
index 0000000..685c177
--- /dev/null
+++ b/verify/golint.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+ROOT=$(dirname "${BASH_SOURCE}")/..
+GOLINT=${GOLINT:-"golint"}
+
+pushd "${ROOT}" > /dev/null
+ bad_files=$($GOLINT -min_confidence=0.9 ./...)
+ if [[ -n "${bad_files}" ]]; then
+ echo "!!! '$GOLINT' problems: "
+ echo "${bad_files}"
+ exit 1
+ fi
+popd > /dev/null
+
+# ex: ts=2 sw=2 et filetype=sh