Skip to content

Commit

Permalink
Add bazel distribtests (minimalist version that only tests with bazel…
Browse files Browse the repository at this point in the history
… 3.x and 4.x) (grpc#27486)

* Make repo globally buildable

* Add initial distrib test script

* Add test script

* Support multiple versions

* Split out a separate latest version test

* Integrate with kokoro

* make tools/bazel version overridable

* added simplified test_single_bazel_version.sh

* cleanup .bazelignore

* only test 3.x and 4.x

* always test all the bazel versions

* revert unnecessary changes

* revert unnecessary changes

* fix shellcheck error

Co-authored-by: Richard Belleville <[email protected]>
  • Loading branch information
jtattermusch and gnossen authored Sep 28, 2021
1 parent 044253e commit fa8a122
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
36 changes: 36 additions & 0 deletions test/distrib/bazel/run_bazel_distrib_test.sh
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions test/distrib/bazel/test_latest_bazel_version.sh
Original file line number Diff line number Diff line change
@@ -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"
45 changes: 45 additions & 0 deletions test/distrib/bazel/test_single_bazel_version.sh
Original file line number Diff line number Diff line change
@@ -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[@]}"
2 changes: 1 addition & 1 deletion tools/bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions tools/internal_ci/linux/grpc_bazel_distribtest.cfg
Original file line number Diff line number Diff line change
@@ -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/**"
}
}
25 changes: 25 additions & 0 deletions tools/internal_ci/linux/grpc_bazel_distribtest.sh
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions tools/internal_ci/linux/grpc_bazel_distribtest_latest.cfg
Original file line number Diff line number Diff line change
@@ -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/**"
}
}
25 changes: 25 additions & 0 deletions tools/internal_ci/linux/grpc_bazel_distribtest_latest.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fa8a122

Please sign in to comment.