hatmill/ci_check

27 lines
413 B
Plaintext
Raw Normal View History

2019-04-18 03:05:49 +00:00
#!/bin/sh
set -e
old_dir=$PWD
new_dir=`mktemp -d`
cleanup() {
rm -rf "$new_dir"
}
trap cleanup EXIT
cp -r . "$new_dir"
cd "$new_dir"
checkgen() {
$1
if ! diff -r . "$old_dir"
then
echo $2 1>&2
return 1
fi
}
checkgen 'go generate ./...' 'Generated files not up-to-date. Please run go generate.'
checkgen 'go fmt ./...' '.go files not formatted. Please run go fmt.'
go vet ./...
go test ./...