| 1 | #!/bin/bashscip-shell filesystem . . `/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 | goscip-shell system . . go. mod tidy |
| 16 | gitscip-shell system . . git. diff go.mod | teescip-shell system . . tee. /dev/stderrscip-shell filesystem . . `/dev/stderr`. | (! read) |
| 17 | gitscip-shell system . . git. diff go.sum | teescip-shell system . . tee. /dev/stderrscip-shell filesystem . . `/dev/stderr`. | (! read) |
| 18 | |
| 19 | # Easier to debug CI. |
| 20 | pwdscip-shell system . . 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 | findscip-shell system . . find. . -type f -name "*.go" ! -name "*.pb.go" -exec grep -L "\(Copyright [0-9]\{4,\}\)" {} \; 2>&1 | teescip-shell system . . tee. /dev/stderrscip-shell filesystem . . `/dev/stderr`. | (! read) |
| 24 | |
| 25 | gofmtscip-shell system . . gofmt. -s -d -l . 2>&1 | teescip-shell system . . tee. /dev/stderrscip-shell filesystem . . `/dev/stderr`. | (! read) |
| 26 | goimports -l . 2>&1 | teescip-shell system . . tee. /dev/stderrscip-shell filesystem . . `/dev/stderr`. | (! read) |
| 27 | |
| 28 | # No need to golint / staticcheck when it's just proto-generated files |