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.
 
 
 

44 lines
1.3 KiB

  1. #!/usr/bin/env bash
  2. # Display commands being run
  3. set -x
  4. # Only run apidiff checks on go1.12 (we only need it once).
  5. # TODO(deklerk) We should pass an environment variable from kokoro to decide
  6. # this logic instead.
  7. if [[ `go version` != *"go1.12"* ]]; then
  8. exit 0
  9. fi
  10. if git log -1 | grep BREAKING_CHANGE_ACCEPTABLE; then
  11. exit 0
  12. fi
  13. export GO111MODULE=on
  14. go install golang.org/x/exp/cmd/apidiff
  15. # We compare against master@HEAD. This is unfortunate in some cases: if you're
  16. # working on an out-of-date branch, and master gets some new feature (that has
  17. # nothing to do with your work on your branch), you'll get an error message.
  18. # Thankfully the fix is quite simple: rebase your branch.
  19. git clone https://github.com/googleapis/gax-go /tmp/gax
  20. for dir in "" "/v2"; do
  21. pkg="github.com/googleapis/gax-go$dir"
  22. echo "Testing $pkg"
  23. # cd to the exact directory that specifies the go module so that it doesn't
  24. # use the module cache. https://go-review.googlesource.com/c/exp/+/155058
  25. cd "/tmp/gax$dir"
  26. apidiff -w /tmp/pkg.master $pkg
  27. cd - > /dev/null
  28. # TODO(deklerk) there's probably a nicer way to do this that doesn't require
  29. # two invocations
  30. if ! apidiff -incompatible /tmp/pkg.master $pkg | (! read); then
  31. apidiff -incompatible /tmp/pkg.master $pkg
  32. exit 1
  33. fi
  34. done