1#!/usr/bin/env bash 2# Copyright 2021 The gRPC authors. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16set -ex 17 18if [ "$#" != "1" ] ; then 19 echo "Must supply bazel version to be tested." >/dev/stderr 20 exit 1 21fi 22 23VERSION="$1" 24 25cd "$(dirname "$0")"/../../.. 26 27EXCLUDED_TARGETS=( 28 # iOS platform fails the analysis phase since there is no toolchain available 29 # for it. 30 "-//src/objective-c/..." 31 "-//third_party/objective_c/..." 32 33 # Targets here need C++17 to build via a different configuration, so this is 34 # done separately 35 "-//fuzztest/..." 36 37 # This could be a legitmate failure due to bitrot. 38 "-//src/proto/grpc/testing:test_gen_proto" 39 40 # This appears to be a legitimately broken BUILD file. There's a reference to 41 # a non-existent "link_dynamic_library.sh". 42 "-//third_party/toolchains/rbe_windows_bazel_5.2.0_vs2019:all" 43 "-//third_party/toolchains:rbe_windows_default_toolchain_suite" 44 45 # TODO(jtattermusch): add back once fixed 46 "-//examples/android/binder/..." 47) 48 49TEST_DIRECTORIES=( 50 "cpp" 51 "python" 52) 53 54FAILED_TESTS="" 55 56export OVERRIDE_BAZEL_VERSION="$VERSION" 57# when running under bazel docker image, the workspace is read only. 58export OVERRIDE_BAZEL_WRAPPER_DOWNLOAD_DIR=/tmp 59 60ACTION_ENV_FLAG="--action_env=bazel_cache_invalidate=version_${VERSION}" 61 62tools/bazel version | grep "$VERSION" || { echo "Detected bazel version did not match expected value of $VERSION" >/dev/stderr; exit 1; } 63tools/bazel build "${ACTION_ENV_FLAG}" -- //... "${EXCLUDED_TARGETS[@]}" || FAILED_TESTS="${FAILED_TESTS}buildtest " 64tools/bazel build "${ACTION_ENV_FLAG}" --config fuzztest -- //fuzztest/... || FAILED_TESTS="${FAILED_TESTS}fuzztest_buildtest " 65 66for TEST_DIRECTORY in "${TEST_DIRECTORIES[@]}"; do 67 pushd "test/distrib/bazel/$TEST_DIRECTORY/" 68 69 tools/bazel version | grep "$VERSION" || { echo "Detected bazel version did not match expected value of $VERSION" >/dev/stderr; exit 1; } 70 tools/bazel test "${ACTION_ENV_FLAG}" --test_output=all //:all || FAILED_TESTS="${FAILED_TESTS}distribtest_${TEST_DIRECTORY} " 71 72 popd 73done 74 75if [ "$FAILED_TESTS" != "" ] 76then 77 echo "Failed tests at version ${VERSION}: ${FAILED_TESTS}" 78 exit 1 79fi 80