You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

40 lines
1.1 KiB

  1. #!/bin/bash
  2. # Fail on any error
  3. set -eo pipefail
  4. # Display commands being run
  5. set -x
  6. # Only run the linter on go1.11, since it needs type aliases (and we only care about its output once).
  7. # TODO(deklerk) We should pass an environment variable from kokoro to decide this logic instead.
  8. if [[ `go version` != *"go1.12"* ]]; then
  9. exit 0
  10. fi
  11. export GO111MODULE=on
  12. go install \
  13. github.com/golang/protobuf/proto \
  14. github.com/golang/protobuf/protoc-gen-go \
  15. golang.org/x/lint/golint \
  16. golang.org/x/tools/cmd/goimports \
  17. honnef.co/go/tools/cmd/staticcheck
  18. # Fail if a dependency was added without the necessary go.mod/go.sum change
  19. # being part of the commit.
  20. go mod tidy
  21. git diff go.mod | tee /dev/stderr | (! read)
  22. git diff go.sum | tee /dev/stderr | (! read)
  23. # Easier to debug CI.
  24. pwd
  25. # Look at all .go files (ignoring .pb.go files) and make sure they have a Copyright. Fail if any don't.
  26. git ls-files "*[^.pb].go" | xargs grep -L "\(Copyright [0-9]\{4,\}\)" 2>&1 | tee /dev/stderr | (! read)
  27. gofmt -s -d -l . 2>&1 | tee /dev/stderr | (! read)
  28. goimports -l . 2>&1 | tee /dev/stderr | (! read)
  29. golint ./... 2>&1 | tee /dev/stderr | (! read)
  30. staticcheck ./...