diff --git a/.bazelignore b/.bazelignore index 033433445de..15aeae9877e 100644 --- a/.bazelignore +++ b/.bazelignore @@ -6,12 +6,22 @@ bins libs objs third_party/abseil-cpp +third_party/benchmark +third_party/boringssl third_party/bloaty third_party/boringssl-with-bazel +third_party/envoy-api third_party/googleapis third_party/googletest third_party/opencensus-proto third_party/protobuf third_party/protoc-gen-validate +third_party/re2 third_party/udpa third_party/upb + +bazel/test/python_test_repo + +# Directories generated by setuptools build containing BUILD files. +src/python/grpcio_tests/src/ +tools/distrib/python/grpcio_tools/grpc_root/ diff --git a/test/distrib/bazel/run_bazel_distrib_test.sh b/test/distrib/bazel/run_bazel_distrib_test.sh new file mode 100755 index 00000000000..89babec1897 --- /dev/null +++ b/test/distrib/bazel/run_bazel_distrib_test.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# Copyright 2021 The gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +cd "$(dirname "$0")" + +# TODO(jtattermusch): make build work with bazel 2.2.0 and bazel 1.2.1 if that's reasonably simple. +SUPPORTED_VERSIONS=( + "3.7.2" + "4.0.0" +) + +FAILED_VERSIONS="" +for VERSION in "${SUPPORTED_VERSIONS[@]}"; do + echo "Running bazel distribtest with bazel version ${VERSION}" + ./test_single_bazel_version.sh "${VERSION}" || FAILED_VERSIONS="${FAILED_VERSIONS}${VERSION} " +done + +if [ "$FAILED_VERSIONS" != "" ] +then + echo "Bazel distribtest failed: Failed to build with bazel versions ${FAILED_VERSIONS}" + exit 1 +fi diff --git a/test/distrib/bazel/test_latest_bazel_version.sh b/test/distrib/bazel/test_latest_bazel_version.sh new file mode 100755 index 00000000000..fb02a86c5fb --- /dev/null +++ b/test/distrib/bazel/test_latest_bazel_version.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Copyright 2021 The gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +cd "$(dirname "$0")" + +GITHUB_URL="https://github.com" +REPO="bazelbuild/bazel" + +VERSION=$(curl -Ls "${GITHUB_URL}/${REPO}/releases/latest" | \ + grep "href=.*\.tar.gz" | \ + grep -o "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*") + +./test_single_bazel_version.sh "$VERSION" diff --git a/test/distrib/bazel/test_single_bazel_version.sh b/test/distrib/bazel/test_single_bazel_version.sh new file mode 100755 index 00000000000..eefc87d492e --- /dev/null +++ b/test/distrib/bazel/test_single_bazel_version.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# Copyright 2021 The gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +if [ "$#" != "1" ] ; then + echo "Must supply bazel version to be tested." >/dev/stderr + exit 1 +fi + +VERSION="$1" + +cd "$(dirname "$0")"/../../.. + +EXCLUDED_TARGETS=( + # iOS platform fails the analysis phase since there is no toolchain available + # for it. + "-//src/objective-c/..." + "-//third_party/objective_c/..." + + # This could be a legitmate failure due to bitrot. + "-//src/proto/grpc/testing:test_gen_proto" + + # This appears to be a legitimately broken BUILD file. There's a reference to + # a non-existent "link_dynamic_library.sh". + "-//third_party/toolchains/bazel_0.26.0_rbe_windows:all" + + # TODO(jtattermusch): add back once fixed + "-//examples/android/binder/..." +) + +export OVERRIDE_BAZEL_VERSION="$VERSION" +bazel build -- //... "${EXCLUDED_TARGETS[@]}" diff --git a/tools/bazel b/tools/bazel index f701fff3541..e66fee79283 100755 --- a/tools/bazel +++ b/tools/bazel @@ -42,7 +42,7 @@ fi # IMPORTANT: if you update the version here, other parts of infrastructure might needs updating as well # (e.g. win RBE builds, sanity checks, bazel toolchains etc.) -VERSION=4.2.1 +VERSION=${OVERRIDE_BAZEL_VERSION:-4.2.1} echo "INFO: Running bazel wrapper (see //tools/bazel for details), bazel version $VERSION will be used instead of system-wide bazel installation." >&2 # update tools/update_mirror.sh to populate the mirror with new bazel archives diff --git a/tools/internal_ci/linux/grpc_bazel_distribtest.cfg b/tools/internal_ci/linux/grpc_bazel_distribtest.cfg new file mode 100644 index 00000000000..00b398ddf5f --- /dev/null +++ b/tools/internal_ci/linux/grpc_bazel_distribtest.cfg @@ -0,0 +1,26 @@ +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "grpc/tools/internal_ci/linux/grpc_bazel_distribtest.sh" +timeout_mins: 120 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + regex: "github/grpc/artifacts/**" + } +} diff --git a/tools/internal_ci/linux/grpc_bazel_distribtest.sh b/tools/internal_ci/linux/grpc_bazel_distribtest.sh new file mode 100755 index 00000000000..5d148247b78 --- /dev/null +++ b/tools/internal_ci/linux/grpc_bazel_distribtest.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Copyright 2021 The gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Build portability tests with an updated submodule + +set -ex + +# change to grpc repo root +cd $(dirname $0)/../../.. + +source tools/internal_ci/helper_scripts/prepare_build_linux_rc + +./test/distrib/bazel/run_bazel_distrib_test.sh diff --git a/tools/internal_ci/linux/grpc_bazel_distribtest_latest.cfg b/tools/internal_ci/linux/grpc_bazel_distribtest_latest.cfg new file mode 100644 index 00000000000..8e9774f7ce4 --- /dev/null +++ b/tools/internal_ci/linux/grpc_bazel_distribtest_latest.cfg @@ -0,0 +1,26 @@ +# Copyright 2021 The gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Config file for the internal CI (in protobuf text format) + +# Location of the continuous shell script in repository. +build_file: "tools/internal_ci/linux/grpc_bazel_distribtest_latest.sh" +timeout_mins: 120 +action { + define_artifacts { + regex: "**/*sponge_log.*" + regex: "github/grpc/reports/**" + regex: "github/grpc/artifacts/**" + } +} diff --git a/tools/internal_ci/linux/grpc_bazel_distribtest_latest.sh b/tools/internal_ci/linux/grpc_bazel_distribtest_latest.sh new file mode 100755 index 00000000000..4c0d3a6b6f0 --- /dev/null +++ b/tools/internal_ci/linux/grpc_bazel_distribtest_latest.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Copyright 2021 The gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Build portability tests with an updated submodule + +set -ex + +# change to grpc repo root +cd $(dirname $0)/../../.. + +source tools/internal_ci/helper_scripts/prepare_build_linux_rc + +./test/distrib/bazel/test_latest_bazel_version.sh