1
1
mirror of https://github.com/walles/moar.git synced 2024-10-26 13:00:40 +03:00

Verify code formatting in ./test.sh

This commit is contained in:
Johan Walles 2021-04-19 07:16:58 +02:00
parent 0795329ac5
commit ede1a8cbb3
2 changed files with 14 additions and 4 deletions

View File

@ -2,7 +2,7 @@
if [ -z ${CI+x} ]; then
# Local build, not in CI, format source
go fmt ./... .
go fmt .
fi
VERSION="$(git describe --tags --dirty --always)"

16
test.sh
View File

@ -6,6 +6,19 @@ set -e -o pipefail
grep -En 'Foreground\([1-9]' ./*.go ./*/*.go && exit 1
grep -En 'Background\([1-9]' ./*.go ./*/*.go && exit 1
# Compile test first
./build.sh
# Linting first
MISFORMATTED="$(gofmt -l .)"
if [ -n "$MISFORMATTED" ]; then
echo >&2 "==="
echo >&2 "ERROR: The following files are not formatted, run './build.sh', './test.sh' or 'go fmt .' to fix:"
echo >&2 "$MISFORMATTED"
echo >&2 "==="
exit 1
fi
# Unit tests first
go test -timeout 20s github.com/walles/moar/m
@ -14,9 +27,6 @@ go test -timeout 20s github.com/walles/moar/m
GOOS=linux GOARCH=386 ./build.sh
GOOS=darwin GOARCH=amd64 ./build.sh
# Make sure we have a runnable binary for the current platform when done
./build.sh
# Verify sending the output to a file
RESULT="$(mktemp)"
function cleanup {