Skip to content

Commit

Permalink
Make Bazel CI failures clearer
Browse files Browse the repository at this point in the history
- don't try to run tests if the BUILD files are out-of-date
- run buildifier even if the tests fail, as it may still be useful
- use a parameter to hold Bazel config to simplify config.yml
- ignore the vendor/ directory when running Gazelle
  (otherwise it will fail if you've used `dep` to create vendor/)
  • Loading branch information
drigz committed Nov 14, 2018
1 parent a7c0cd0 commit 9695cc6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
36 changes: 22 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,32 @@ jobs:
- run: dep ensure --vendor-only
- run: go get golang.org/x/lint/golint
- run: make lint
bazel_lint:
bazel:
docker:
- image: l.gcr.io/google/bazel:latest
working_directory: /go/src/github.com/grpc-ecosystem/grpc-gateway
steps:
- checkout
- run: 'bazel --output_base=$HOME/.cache/_grpc_gateway_bazel run //:buildifier_check ||
(echo "Bazel files not formatted, please run \`bazel run :buildifier\`"; exit 1)'
- run: 'test -z "$(bazel --output_base=$HOME/.cache/_grpc_gateway_bazel run //:gazelle_diff)" ||
(echo "Bazel files out-of-date, please run \`bazel run :gazelle_diff\`"; exit 1)'
bazel_test:
docker:
- image: l.gcr.io/google/bazel:latest
working_directory: /go/src/github.com/grpc-ecosystem/grpc-gateway
steps:
- checkout
- run: bazel --output_base=$HOME/.cache/_grpc_gateway_bazel test --test_output=errors --features=race //...
- run:
name: Create Bazel config file (.bazelrc)
command: |
cat > .bazelrc << EOF
startup --output_base $HOME/.cache/_grpc_gateway_bazel
build --test_output errors
build --features race
EOF
- run:
name: Check that Bazel BUILD files are up-to-date
command: 'test -z "$(bazel run //:gazelle_diff)" ||
(echo "ERROR: Bazel files out-of-date, please run \`bazel run :gazelle_fix\`" >&2; exit 1)'
- run:
name: Run tests with Bazel
command: bazel test //...
- run:
name: Check formatting of Bazel BUILD files
command: 'bazel run //:buildifier_check ||
(echo "ERROR: Bazel files not formatted, please run \`bazel run :buildifier\`" >&2; exit 1)'
when: always
build_linux_release:
docker:
- image: jfbrandhorst/grpc-gateway-build-env
Expand Down Expand Up @@ -153,8 +162,7 @@ workflows:
- node_test
- generate
- lint
- bazel_lint
- bazel_test
- bazel
- build_linux_release:
filters:
branches:
Expand Down
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ buildifier(
)

# gazelle:exclude third_party
# gazelle:exclude vendor

gazelle(
name = "gazelle_diff",
Expand Down

0 comments on commit 9695cc6

Please sign in to comment.