1#!/bin/bash
2# Copyright 2017 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
16# Build portability tests with an updated submodule
17
18set -ex
19
20# change to grpc repo root
21cd $(dirname $0)/../../..
22
23source tools/internal_ci/helper_scripts/prepare_build_linux_rc
24
25# Submodule name is passed as the RUN_TESTS_FLAGS variable
26SUBMODULE_NAME="${RUN_TESTS_FLAGS}"
27
28# Name of branch to checkout is passed as BAZEL_FLAGS variable
29# If unset, "master" is used by default.
30SUBMODULE_BRANCH_NAME="${BAZEL_FLAGS:-master}"
31
32# Update submodule to be tested at HEAD
33(cd "third_party/${SUBMODULE_NAME}" && git fetch origin && git checkout "origin/${SUBMODULE_BRANCH_NAME}")
34
35echo "This suite tests whether gRPC HEAD builds with HEAD of submodule '${SUBMODULE_NAME}'"
36echo "If a test breaks, either"
37echo "1) some change in the grpc repository has caused the failure"
38echo "2) some change that was just merged in the submodule head has caused the failure."
39
40echo ""
41echo "submodule '${SUBMODULE_NAME}' is at commit: $(cd third_party/${SUBMODULE_NAME}; git rev-parse --verify HEAD)"
42echo ""
43
44# Update bazel for generate_projects
45case "$SUBMODULE_NAME" in
46  abseil-cpp)
47    BAZEL_DEP_NAME="com_google_absl"
48    ;;
49  boringssl)
50    BAZEL_DEP_NAME="boringssl"
51    ;;
52  protobuf)
53    BAZEL_DEP_NAME="com_google_protobuf"
54    ;;
55esac
56if [ -z "$BAZEL_DEP_NAME" ]
57then
58   echo "No bazel dependency is specified so skipping bazel reconfiguration."
59else
60   BAZEL_DEP_PATH="$(pwd)/third_party/${SUBMODULE_NAME}"
61   echo "bazel override_repository is set for ${BAZEL_DEP_NAME} to ${BAZEL_DEP_PATH}"
62   echo "build --override_repository=${BAZEL_DEP_NAME}=${BAZEL_DEP_PATH}" >> "tools/bazel.rc"
63   echo "query --override_repository=${BAZEL_DEP_NAME}=${BAZEL_DEP_PATH}" >> "tools/bazel.rc"
64fi
65echo ""
66
67if [ "${SUBMODULE_NAME}" == "abseil-cpp" ]
68then
69  src/abseil-cpp/preprocessed_builds.yaml.gen.py
70fi
71
72tools/buildgen/generate_projects.sh
73
74if [ "${SUBMODULE_NAME}" == "abseil-cpp" ] || [ "${SUBMODULE_NAME}" == "protobuf" ]
75then
76  tools/distrib/python/make_grpcio_tools.py
77fi
78
79# commit so that changes are passed to Docker
80git -c user.name='foo' -c user.email='[email protected]' commit -a -m 'Update submodule' --allow-empty
81
82tools/run_tests/run_tests_matrix.py -f linux --exclude c sanity basictests_arm64 --inner_jobs 16 -j 2 --internal_ci --build_only
83