| 1 | #!/bin/bash |
| 2 | |
| 3 | # Fail on any error |
| 4 | set -eo |
| 5 | |
| 6 | # Display commands being run |
| 7 | set -x |
| 8 | |
| 9 | if [[ $KOKORO_JOB_NAME != *"latest-version"* ]]; then |
| 10 | exit 0 |
| 11 | fi |
| 12 | |
| 13 | # Fail if a dependency was added without the necessary go.mod/go.sum change |
| 14 | # being part of the commit. |
| 15 | go mod tidy |
| 16 | git diff go.mod | tee /dev/stderr | (! read) |
| 17 | git diff go.sum | tee /dev/stderr | (! read) |
| 18 | |
| 19 | # Easier to debug CI. |
| 20 | pwd |
| 21 | |
| 22 | # Look at all .go files (ignoring .pb.go files) and make sure they have a Copyright. Fail if any don't. |
| 23 | find . -type f -name "*.go" ! -name "*.pb.go" -exec grep -L "\(Copyright [0-9]\{4,\}\)" {} \; 2>&1 | tee /dev/stderr | (! read) |
| 24 | |
| 25 | gofmt -s -d -l . 2>&1 | tee /dev/stderr | (! read) |
| 26 | goimports -l . 2>&1 | tee /dev/stderr | (! read) |
| 27 | |
| 28 | # No need to golint / staticcheck when it's just proto-generated files |