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.
 
 
 

42 lines
1.2 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. if [[ `go version` != *"go1.12"* ]]; then
  6. exit 0
  7. fi
  8. if git log -1 | grep BREAKING_CHANGE_ACCEPTABLE; then
  9. exit 0
  10. fi
  11. go install golang.org/x/exp/cmd/apidiff
  12. # We compare against master@HEAD. This is unfortunate in some cases: if you're
  13. # working on an out-of-date branch, and master gets some new feature (that has
  14. # nothing to do with your work on your branch), you'll get an error message.
  15. # Thankfully the fix is quite simple: rebase your branch.
  16. git clone https://github.com/google/go-genproto /tmp/genproto
  17. V1_DIRS=`find . -type d -regex '.*v1$'`
  18. V1_SUBDIRS=`find . -type d -regex '.*v1\/.*'`
  19. for dir in $V1_DIRS $V1_SUBDIRS; do
  20. # turns things like ./foo/bar into foo/bar
  21. dir_without_junk=`echo $dir | sed -n "s#\(\.\/\)\(.*\)#\2#p"`
  22. pkg="google.golang.org/genproto/$dir_without_junk"
  23. echo "Testing $pkg"
  24. cd /tmp/genproto
  25. apidiff -w /tmp/pkg.master $pkg
  26. cd - > /dev/null
  27. # TODO(deklerk) there's probably a nicer way to do this that doesn't require
  28. # two invocations
  29. if ! apidiff -incompatible /tmp/pkg.master $pkg | (! read); then
  30. apidiff -incompatible /tmp/pkg.master $pkg
  31. exit 1
  32. fi
  33. done