Skip to content

Commit

Permalink
internal/kokoro: add apidiff
Browse files Browse the repository at this point in the history
Change-Id: Ibb8ec6321921c2decff833a0abb0a535e0f186a1
Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/37671
Reviewed-by: kokoro <[email protected]>
Reviewed-by: Chris Broadfoot <[email protected]>
  • Loading branch information
jeanbza committed Mar 18, 2019
1 parent 5d9fb94 commit aee6717
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ provide a commit message, and use `git codereview mail` to create a Gerrit CL.
1. Keep amending to the change with `git codereview change` and mail as your
receive feedback. Each new mailed amendment will create a new patch set for
your change in Gerrit.
- Note: if your change includes a breaking change, our breaking change
detector will cause CI/CD to fail. If your breaking change is acceptable
in some way, add BREAKING_CHANGE_ACCEPTABLE=<reason> to cause the
detector not to be run and to make it clear why that is acceptable.

## Integration Tests

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024
go.opencensus.io v0.19.1
golang.org/x/build v0.0.0-20190314133821-5284462c4bec
golang.org/x/exp v0.0.0-20190121172915-509febef88a4
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ golang.org/x/build v0.0.0-20190314133821-5284462c4bec/go.mod h1:atTaCNAy0f16Ah5a
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4 h1:c2HOrn5iMezYjSlGPncknSEr/8x5LELb/ilJbXi9DEA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 h1:x/bBzNauLQAlE3fLku/xy92Y8QwKX5HZymrMz2IiKFc=
Expand Down
41 changes: 41 additions & 0 deletions internal/kokoro/check_incompat_changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

# Display commands being run
set -x

# Only run apidiff checks on go1.12 (we only need it once).
if [[ `go version` != *"go1.12"* ]]; then
exit 0
fi

if git log -1 | grep BREAKING_CHANGE_ACCEPTABLE; then
exit 0
fi

go install golang.org/x/exp/cmd/apidiff

# We compare against master@HEAD. This is unfortunate in some cases: if you're
# working on an out-of-date branch, and master gets some new feature (that has
# nothing to do with your work on your branch), you'll get an error message.
# Thankfully the fix is quite simple: rebase your branch.
git clone https://code.googlesource.com/gocloud /tmp/gocloud

V1_DIRS=`find . -type d -regex '.*v1$'`
V1_SUBDIRS=`find . -type d -regex '.*v1\/.*'`
for dir in $V1_DIRS $V1_SUBDIRS; do
# turns things like ./foo/bar into foo/bar
dir_without_junk=`echo $dir | sed -n "s#\(\.\/\)\(.*\)#\2#p"`
pkg="cloud.google.com/go/$dir_without_junk"
echo "Testing $pkg"

cd /tmp/gocloud
apidiff -w /tmp/pkg.master $pkg
cd - > /dev/null

# TODO(deklerk) there's probably a nicer way to do this that doesn't require
# two invocations
if ! apidiff -incompatible /tmp/pkg.master $pkg | (! read); then
apidiff -incompatible /tmp/pkg.master $pkg
exit 1
fi
done
1 change: 1 addition & 0 deletions internal/kokoro/continuous.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ download_deps() {
download_deps
go install github.com/jstemmer/go-junit-report
./internal/kokoro/vet.sh
./internal/kokoro/check_incompat_changes.sh

mkdir $KOKORO_ARTIFACTS_DIR/tests

Expand Down
1 change: 1 addition & 0 deletions internal/kokoro/presubmit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ download_deps() {
download_deps
go install github.com/jstemmer/go-junit-report
./internal/kokoro/vet.sh
./internal/kokoro/check_incompat_changes.sh

mkdir $KOKORO_ARTIFACTS_DIR/tests

Expand Down
1 change: 1 addition & 0 deletions tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package cloud
import (
_ "github.com/golang/protobuf/protoc-gen-go"
_ "github.com/jstemmer/go-junit-report"
_ "golang.org/x/exp/cmd/apidiff"
_ "golang.org/x/lint/golint"
_ "golang.org/x/tools/cmd/goimports"
_ "honnef.co/go/tools/cmd/staticcheck"
Expand Down

0 comments on commit aee6717

Please sign in to comment.