fmt check in script; fail build on gofmt problems
This commit is contained in:
parent
9d5449d173
commit
591c2909c6
5
Makefile
5
Makefile
|
@ -1,7 +1,6 @@
|
|||
.PHONY: test race cover robeaux examples deps test_with_coverage fmt_check
|
||||
|
||||
excluding_vendor := $(shell go list ./... | grep -v /vendor/)
|
||||
gofiles_excluding_vendor = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
||||
|
||||
# Run tests on all non-vendor directories
|
||||
test:
|
||||
|
@ -13,11 +12,11 @@ race:
|
|||
|
||||
# Check for code well-formedness
|
||||
fmt_check:
|
||||
gofmt -d $(gofiles_excluding_vendor)
|
||||
./ci/format.sh
|
||||
|
||||
# Test and generate coverage
|
||||
test_with_coverage:
|
||||
./ci/test.sh || exit 1
|
||||
./ci/test.sh
|
||||
|
||||
deps:
|
||||
ifeq (,$(shell which dep))
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
## Only uncomment the below for debugging
|
||||
#set -euxo pipefail
|
||||
|
||||
pushd $PWD/..
|
||||
GO_FILES_EXCLUDING_VENDOR=$(find . -type f -name '*.go' -not -path "./vendor/*")
|
||||
FMT_RESULTS=$(gofmt -l $GO_FILES_EXCLUDING_VENDOR)
|
||||
if [ ${#FMT_RESULTS[@]} -ne 0 ]; then
|
||||
# some files have formatting errors
|
||||
echo "--- gofmt found errors found in the following files:"
|
||||
echo $FMT_RESULTS
|
||||
exit 1
|
||||
else
|
||||
# no files have formatting errors
|
||||
exit 0
|
||||
fi
|
||||
popd
|
Loading…
Reference in New Issue