feat: checktidy will check the go.mod and go.sum files in circleci

pull/10616/head
Jonathan A. Sternberg 2018-10-10 11:31:37 -05:00
parent bbd7153cca
commit 0e14b63425
No known key found for this signature in database
GPG Key ID: 4A0C1200CB8B9D2E
3 changed files with 20 additions and 2 deletions

View File

@ -44,6 +44,7 @@ jobs:
- run: make test-go # This uses the test cache so it may succeed or fail quickly.
- run: make vet
- run: make checkfmt
- run: make checktidy
- run: make test-go-race # This doesn't use the test cache, and will not complete quickly.
# TODO add these checks to the Makefile
# - run: go get -v -t -d ./...

View File

@ -107,9 +107,15 @@ chronograf/ui/build:
fmt: $(SOURCES_NO_VENDOR)
gofmt -w -s $^
checkfmt: $(SOURCES_NO_VENDOR)
checkfmt:
./etc/checkfmt.sh
tidy:
GO111MODULE=on go mod tidy
checktidy:
./etc/checktidy.sh
chronograf/dist/dist_gen.go: chronograf/ui/build $(UISOURCES)
$(GO_GENERATE) ./chronograf/dist/...
@ -167,4 +173,4 @@ run: chronogiraffe
# .PHONY targets represent actions that do not create an actual file.
.PHONY: all subdirs $(SUBDIRS) chronograf/ui run fmt test test-go test-js test-go-race bench clean node_modules vet nightly chronogiraffe
.PHONY: all subdirs $(SUBDIRS) chronograf/ui run fmt checkfmt tidy checktidy test test-go test-js test-go-race bench clean node_modules vet nightly chronogiraffe

11
etc/checktidy.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
set -e
export GO111MODULE=on
go mod tidy
if ! git --no-pager diff --exit-code -- go.mod go.sum; then
>&2 echo "modules are not tidy, please run 'go mod tidy'"
exit 1
fi