Skip to content

Commit 8036cae

Browse files
derekmaurocopybara-github
authored andcommitted
CI: Use a cached copy of GoogleTest in CMake builds if possible
to minimize the possibility of errors downloading from GitHub PiperOrigin-RevId: 835321189 Change-Id: I16101c5a5ead106c5a9beb254dde31a2b5e5df75
1 parent 8cd0e44 commit 8036cae

File tree

6 files changed

+30
-2
lines changed

6 files changed

+30
-2
lines changed

ci/cmake_common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
# Keep this in sync with the commit in the MODULE.bazel file.
1717
readonly ABSL_GOOGLETEST_VERSION="1.17.0"
1818

19-
readonly ABSL_GOOGLETEST_DOWNLOAD_URL="https://github.com/google/googletest/releases/download/v${ABSL_GOOGLETEST_VERSION}/googletest-${ABSL_GOOGLETEST_VERSION}.tar.gz"
19+
ABSL_GOOGLETEST_DOWNLOAD_URL="https://github.com/google/googletest/releases/download/v${ABSL_GOOGLETEST_VERSION}/googletest-${ABSL_GOOGLETEST_VERSION}.tar.gz"

ci/cmake_install_test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ fi
2626

2727
source "${ABSEIL_ROOT}/ci/cmake_common.sh"
2828

29+
# Avoid depending on GitHub by looking for a cached copy of GoogleTest.
30+
if [[ -r "${KOKORO_GFILE_DIR:-}/distdir/googletest-${ABSL_GOOGLETEST_VERSION}.tar.gz" ]]; then
31+
ABSL_GOOGLETEST_DOWNLOAD_URL="file:///distdir/googletest-${ABSL_GOOGLETEST_VERSION}.tar.gz"
32+
DOCKER_EXTRA_ARGS="--mount type=bind,source=${KOKORO_GFILE_DIR}/distdir,target=/distdir,readonly ${DOCKER_EXTRA_ARGS:-}"
33+
fi
34+
2935
source "${ABSEIL_ROOT}/ci/linux_docker_containers.sh"
3036
readonly DOCKER_CONTAINER=${LINUX_GCC_LATEST_CONTAINER}
3137

ci/linux_gcc-latest_libstdcxx_cmake.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ fi
2222

2323
source "${ABSEIL_ROOT}/ci/cmake_common.sh"
2424

25+
# Avoid depending on GitHub by looking for a cached copy of GoogleTest.
26+
if [[ -r "${KOKORO_GFILE_DIR:-}/distdir/googletest-${ABSL_GOOGLETEST_VERSION}.tar.gz" ]]; then
27+
ABSL_GOOGLETEST_DOWNLOAD_URL="file:///distdir/googletest-${ABSL_GOOGLETEST_VERSION}.tar.gz"
28+
DOCKER_EXTRA_ARGS="--mount type=bind,source=${KOKORO_GFILE_DIR}/distdir,target=/distdir,readonly ${DOCKER_EXTRA_ARGS:-}"
29+
fi
30+
2531
if [[ -z ${ABSL_CMAKE_CXX_STANDARDS:-} ]]; then
2632
ABSL_CMAKE_CXX_STANDARDS="17 20"
2733
fi

ci/linux_gcc_alpine_cmake.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ fi
2222

2323
source "${ABSEIL_ROOT}/ci/cmake_common.sh"
2424

25+
# Avoid depending on GitHub by looking for a cached copy of GoogleTest.
26+
if [[ -r "${KOKORO_GFILE_DIR:-}/distdir/googletest-${ABSL_GOOGLETEST_VERSION}.tar.gz" ]]; then
27+
ABSL_GOOGLETEST_DOWNLOAD_URL="file:///distdir/googletest-${ABSL_GOOGLETEST_VERSION}.tar.gz"
28+
DOCKER_EXTRA_ARGS="--mount type=bind,source=${KOKORO_GFILE_DIR}/distdir,target=/distdir,readonly ${DOCKER_EXTRA_ARGS:-}"
29+
fi
30+
2531
if [[ -z ${ABSL_CMAKE_CXX_STANDARDS:-} ]]; then
2632
ABSL_CMAKE_CXX_STANDARDS="17"
2733
fi

ci/macos_xcode_cmake.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ ABSEIL_ROOT=$(realpath ${ABSEIL_ROOT})
3131

3232
source "${ABSEIL_ROOT}/ci/cmake_common.sh"
3333

34+
# Avoid depending on GitHub by looking for a cached copy of GoogleTest.
35+
if [[ -r "${KOKORO_GFILE_DIR:-}/distdir/googletest-${ABSL_GOOGLETEST_VERSION}.tar.gz" ]]; then
36+
ABSL_GOOGLETEST_DOWNLOAD_URL="${KOKORO_GFILE_DIR}/distdir/googletest-${ABSL_GOOGLETEST_VERSION}.tar.gz"
37+
fi
38+
3439
if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then
3540
ABSL_CMAKE_BUILD_TYPES="Debug"
3641
fi

ci/windows_msvc_cmake.bat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ SETLOCAL ENABLEDELAYEDEXPANSION
1717
:: The version of GoogleTest to be used in the CMake tests in this directory.
1818
:: Keep this in sync with the version in the WORKSPACE file.
1919
SET ABSL_GOOGLETEST_VERSION=1.17.0
20-
SET ABSL_GOOGLETEST_DOWNLOAD_URL=https://github.com/google/googletest/releases/download/v%ABSL_GOOGLETEST_VERSION%/googletest-%ABSL_GOOGLETEST_VERSION%.tar.gz
20+
21+
IF EXIST %KOKORO_GFILE_DIR%\distdir\googletest-%ABSL_GOOGLETEST_VERSION%.tar.gz (
22+
SET ABSL_GOOGLETEST_DOWNLOAD_URL=file://%KOKORO_GFILE_DIR%\distdir\googletest-%ABSL_GOOGLETEST_VERSION%.tar.gz
23+
) ELSE (
24+
SET ABSL_GOOGLETEST_DOWNLOAD_URL=https://github.com/google/googletest/releases/download/v%ABSL_GOOGLETEST_VERSION%/googletest-%ABSL_GOOGLETEST_VERSION%.tar.gz
25+
)
2126

2227
:: Replace '\' with '/' in Windows paths for CMake.
2328
:: Note that this cannot go inside the IF block above, because BAT files are weird.

0 commit comments

Comments
 (0)