k3s/scripts/validate

30 lines
694 B
Bash
Executable File

#!/bin/bash
set -e
cd $(dirname $0)/..
echo Running validation
if grep -r '^[[:space:]]*\[\[.*]][[:space:]]*$' tests; then
echo "Add \"|| false\" to bats tests in any place you use [[ ... ]]"
exit 1
fi
PACKAGES="$(go list ./...)"
echo Running: go vet
go vet ${PACKAGES}
echo Running: gometalinter
for i in ${PACKAGES}; do
if [ -n "$(gometalinter $i | \
grep -v 'should have comment.*or be unexported' | \
grep -v 'cli/cmd.*don.t use underscores in Go name' | \
grep -v 'cli/cmd.*should be DNS' | \
tee /dev/stderr)" ]; then
failed=true
fi
done
test -z "$failed"
echo Running: go fmt
test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)"