GoogleTest CI Update

* Use abseil-cpp@20250512.0, which requires C++17 and
 removes any/optional/variant polyfills
* Test C++23
* Support/test GCC15
* Use Bazel vendor mode to reduce reliance on GitHub

PiperOrigin-RevId: 759184924
Change-Id: Ifb866cdd7faf1e5be475b44f69870745e21a3104
This commit is contained in:
Derek Mauro
2025-05-15 09:42:16 -07:00
committed by Copybara-Service
parent 9f79a9597a
commit 571930618f
5 changed files with 76 additions and 42 deletions

View File

@@ -31,15 +31,23 @@
set -euox pipefail
readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20241218"
readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20250205"
readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20250430"
readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20250430"
if [[ -z ${GTEST_ROOT:-} ]]; then
GTEST_ROOT="$(realpath $(dirname ${0})/..)"
fi
# Use Bazel Vendor mode to reduce reliance on external dependencies.
# See https://bazel.build/external/vendor and the Dockerfile for
# an explaination of how this works.
if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f "${KOKORO_GFILE_DIR}/distdir/googletest_vendor.tar.gz" ]]; then
DOCKER_EXTRA_ARGS="--mount type=bind,source=${KOKORO_GFILE_DIR}/distdir,target=/distdir,readonly --env=BAZEL_VENDOR_ARCHIVE=/distdir/googletest_vendor.tar.gz ${DOCKER_EXTRA_ARGS:-}"
BAZEL_EXTRA_ARGS="--vendor_dir=/googletest_vendor ${BAZEL_EXTRA_ARGS:-}"
fi
if [[ -z ${STD:-} ]]; then
STD="c++17 c++20"
STD="c++17 c++20 c++23"
fi
# Test CMake + GCC
@@ -93,18 +101,21 @@ time docker run \
--rm \
--env="CC=/usr/local/bin/gcc" \
--env="BAZEL_CXXOPTS=-std=c++17" \
${DOCKER_EXTRA_ARGS:-} \
${LINUX_GCC_FLOOR_CONTAINER} \
/bin/bash --login -c "
/usr/local/bin/bazel test ... \
--copt="-Wall" \
--copt="-Werror" \
--copt="-Wuninitialized" \
--copt="-Wundef" \
--copt="-Wno-error=pragmas" \
--copt=\"-Wall\" \
--copt=\"-Werror\" \
--copt=\"-Wuninitialized\" \
--copt=\"-Wundef\" \
--copt=\"-Wno-error=pragmas\" \
--enable_bzlmod=false \
--features=external_include_paths \
--keep_going \
--show_timestamps \
--test_output=errors
--test_output=errors \
${BAZEL_EXTRA_ARGS:-}"
# Test GCC
for std in ${STD}; do
@@ -115,18 +126,21 @@ for std in ${STD}; do
--rm \
--env="CC=/usr/local/bin/gcc" \
--env="BAZEL_CXXOPTS=-std=${std}" \
${DOCKER_EXTRA_ARGS:-} \
${LINUX_LATEST_CONTAINER} \
/usr/local/bin/bazel test ... \
--copt="-Wall" \
--copt="-Werror" \
--copt="-Wuninitialized" \
--copt="-Wundef" \
--define="absl=${absl}" \
--enable_bzlmod=true \
--features=external_include_paths \
--keep_going \
--show_timestamps \
--test_output=errors
/bin/bash --login -c "
/usr/local/bin/bazel test ... \
--copt=\"-Wall\" \
--copt=\"-Werror\" \
--copt=\"-Wuninitialized\" \
--copt=\"-Wundef\" \
--define=\"absl=${absl}\" \
--enable_bzlmod=true \
--features=external_include_paths \
--keep_going \
--show_timestamps \
--test_output=errors \
${BAZEL_EXTRA_ARGS:-}"
done
done
@@ -139,19 +153,22 @@ for std in ${STD}; do
--rm \
--env="CC=/opt/llvm/clang/bin/clang" \
--env="BAZEL_CXXOPTS=-std=${std}" \
${DOCKER_EXTRA_ARGS:-} \
${LINUX_LATEST_CONTAINER} \
/usr/local/bin/bazel test ... \
--copt="--gcc-toolchain=/usr/local" \
--copt="-Wall" \
--copt="-Werror" \
--copt="-Wuninitialized" \
--copt="-Wundef" \
--define="absl=${absl}" \
--enable_bzlmod=true \
--features=external_include_paths \
--keep_going \
--linkopt="--gcc-toolchain=/usr/local" \
--show_timestamps \
--test_output=errors
/bin/bash --login -c "
/usr/local/bin/bazel test ... \
--copt=\"--gcc-toolchain=/usr/local\" \
--copt=\"-Wall\" \
--copt=\"-Werror\" \
--copt=\"-Wuninitialized\" \
--copt=\"-Wundef\" \
--define=\"absl=${absl}\" \
--enable_bzlmod=true \
--features=external_include_paths \
--keep_going \
--linkopt=\"--gcc-toolchain=/usr/local\" \
--show_timestamps \
--test_output=errors \
${BAZEL_EXTRA_ARGS:-}"
done
done