Check more stuff in CI

This commit is contained in:
Brandon Dyck 2019-04-17 21:05:49 -06:00
parent a8e4c6bc8b
commit 7d00bc0452
2 changed files with 27 additions and 2 deletions

View File

@ -1,4 +1,3 @@
test: test:
script: script:
- go vet -v ./... - ./ci_check
- go test -v ./...

26
ci_check Executable file
View File

@ -0,0 +1,26 @@
#!/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 ./...