diff --git a/.circleci/config.yml b/.circleci/config.yml index 150455b5c21..b4189cd4638 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 @@ -153,8 +162,7 @@ workflows: - node_test - generate - lint - - bazel_lint - - bazel_test + - bazel - build_linux_release: filters: branches: diff --git a/BUILD b/BUILD index b72e9743bd8..a9997cb5a0e 100644 --- a/BUILD +++ b/BUILD @@ -11,6 +11,7 @@ buildifier( ) # gazelle:exclude third_party +# gazelle:exclude vendor gazelle( name = "gazelle_diff", diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8bcfb2794ca..a7d09ce6cb0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,10 +24,12 @@ All submissions, including submissions by project members, require review. Great, it should be as simple as thus (run from the root of the directory): ```bash -$ docker run -v $(pwd):/go/src/github.com/grpc-ecosystem/grpc-gateway --rm jfbrandhorst/grpc-gateway-build-env \ +docker run -v $(pwd):/go/src/github.com/grpc-ecosystem/grpc-gateway --rm jfbrandhorst/grpc-gateway-build-env \ /bin/bash -c 'cd /go/src/github.com/grpc-ecosystem/grpc-gateway && \ make realclean && \ make examples SWAGGER_CODEGEN="${SWAGGER_CODEGEN}"' +docker run -itv $(pwd):/grpc-gateway -w /grpc-gateway --entrypoint /bin/bash --rm \ + l.gcr.io/google/bazel -c 'bazel run :gazelle_fix; bazel run :buildifier' ``` If this has resulted in some file changes in the repo, please ensure you check those in with your merge request.