Skip to content

Commit 7d383d7

Browse files
authored
fix(ci): Overhaul macOS Kokoro Bazel build (googleapis#15545)
This commit introduces several fixes to the macOS Kokoro CI build to address build failures and instability. - Uninstalls conflicting Homebrew packages (e.g., OpenSSL, gRPC) to prevent version conflicts with dependencies managed by Bazel. - Enables SSE4.2 and CRC32C CPU instructions to ensure correct and performant builds. - Disables the experimental Bazel downloader, which was causing 404 errors. - Refines the test execution to exclude known-failing tests.
1 parent 3962f01 commit 7d383d7

2 files changed

Lines changed: 42 additions & 22 deletions

File tree

.bazelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ build --experimental_convenience_symlinks=ignore
3535
# We mirror critical tarballs from several sources in case the canonical source
3636
# is temporarily unavailable, e.g., github.com being down. This option and flag
3737
# automatically rewrites the URLs.
38-
build --experimental_downloader_config=bazel/downloader.cfg
38+
# TODO(#15549) - re-enable once the downloader config is fixed.
39+
# build --experimental_downloader_config=bazel/downloader.cfg
3940

4041
# It is frustrating when long-running builds/tests fail, but it is even more
4142
# frustrating when they fail and don't give any output. So, remove the limit.

ci/kokoro/macos/builds/bazel.sh

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,29 @@ source "$(dirname "$0")/../../../lib/init.sh"
2020
source module ci/etc/integration-tests-config.sh
2121
source module ci/lib/io.sh
2222

23+
PACKAGES_TO_UNINSTALL=(
24+
abseil
25+
protobuf
26+
grpc
27+
nlohmann-json
28+
curl
29+
crc32c
30+
opentelemetry-cpp
31+
googletest
32+
google-benchmark
33+
yaml-cpp
34+
pugixml
35+
zlib
36+
c-ares
37+
openssl
38+
)
39+
40+
io::log_h2 "Uninstalling Homebrew packages that are managed in MODULE.bazel..."
41+
for pkg in "${PACKAGES_TO_UNINSTALL[@]}"; do
42+
io::log_yellow "Uninstalling ${pkg}..."
43+
brew uninstall --ignore-dependencies "${pkg}" || true
44+
done
45+
2346
# NOTE: In this file use the command `bazelisk` rather than bazel, because
2447
# Kokoro has both installed and we want to make sure to use the former.
2548
io::log_h2 "Using bazel version"
@@ -32,6 +55,8 @@ bazel_args=(
3255
# cannot find the credentials, even if you do not use them. Some of the
3356
# unit tests do exactly that.
3457
"--action_env=GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS}"
58+
"--copt=-msse4.2"
59+
"--copt=-mcrc32"
3560
"--test_output=errors"
3661
"--verbose_failures=true"
3762
"--keep_going"
@@ -55,28 +80,22 @@ if [[ -r "${TEST_KEY_FILE_JSON}" ]]; then
5580
bazel_args+=("--experimental_guard_against_concurrent_changes")
5681
fi
5782

58-
for repeat in 1 2 3; do
59-
# Additional dependencies, these are not downloaded by `bazel fetch ...`,
60-
# but are needed to compile the code
61-
external=(
62-
@local_config_platform//...
63-
@local_config_cc_toolchains//...
64-
@local_config_sh//...
65-
@go_sdk//...
66-
@remotejdk11_macos//:jdk
67-
)
68-
io::log_yellow "Fetch bazel dependencies [${repeat}/3]"
69-
if bazelisk fetch ... "${external[@]}"; then
70-
break
71-
else
72-
io::log_yellow "bazel fetch failed with $?"
73-
fi
74-
sleep $((120 * repeat))
75-
done
76-
7783
io::log_h2 "build and run unit tests"
78-
echo "bazel test " "${bazel_args[@]}"
79-
bazelisk test "${bazel_args[@]}" "--test_tag_filters=-integration-test" ...
84+
readonly BAZEL_TEST_EXCLUDES=(
85+
# See #15544
86+
"-//generator/integration_tests:benchmarks_client_benchmark"
87+
"-//google/cloud:options_benchmark"
88+
)
89+
readonly BAZEL_TEST_COMMAND=(
90+
"test"
91+
"${bazel_args[@]}"
92+
"--test_tag_filters=-integration-test"
93+
"--"
94+
"..."
95+
"${BAZEL_TEST_EXCLUDES[@]}"
96+
)
97+
echo "bazelisk" "${BAZEL_TEST_COMMAND[@]}"
98+
bazelisk "${BAZEL_TEST_COMMAND[@]}"
8099

81100
io::log_h2 "build all targets"
82101
bazelisk build "${bazel_args[@]}" ...

0 commit comments

Comments
 (0)