ci: Run base install at most once

This should avoid errors when running it twice. For example, network
errors on the second invocation of 'apt update'; or unguarded
modifications such as APPEND_APT_SOURCES_LIST, which will append the
same string repeatedly.

The base install may be run twice in Cirrus CI with dockerfiles, or
locally when running twice with DANGER_RUN_CI_ON_HOST specified.
pull/27429/head
MarcoFalke 2 years ago
parent 5a8bd45056
commit fa5af94de6
No known key found for this signature in database

@ -6,6 +6,12 @@
export LC_ALL=C.UTF-8 export LC_ALL=C.UTF-8
CFG_DONE="ci.base-install-done" # Use a global git setting to remember whether this script ran to avoid running it twice
if [ "$(git config --global ${CFG_DONE})" == "true" ]; then
echo "Skip base install"
exit 0
fi
if [ -n "$DPKG_ADD_ARCH" ]; then if [ -n "$DPKG_ADD_ARCH" ]; then
dpkg --add-architecture "$DPKG_ADD_ARCH" dpkg --add-architecture "$DPKG_ADD_ARCH"
@ -51,11 +57,9 @@ if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then
fi fi
if [[ "${RUN_TIDY}" == "true" ]]; then if [[ "${RUN_TIDY}" == "true" ]]; then
if [ ! -d "${DIR_IWYU}" ]; then git clone --depth=1 https://github.com/include-what-you-use/include-what-you-use -b clang_16 "${DIR_IWYU}"/include-what-you-use
git clone --depth=1 https://github.com/include-what-you-use/include-what-you-use -b clang_16 "${DIR_IWYU}"/include-what-you-use cmake -B "${DIR_IWYU}"/build/ -G 'Unix Makefiles' -DCMAKE_PREFIX_PATH=/usr/lib/llvm-16 -S "${DIR_IWYU}"/include-what-you-use
cmake -B "${DIR_IWYU}"/build/ -G 'Unix Makefiles' -DCMAKE_PREFIX_PATH=/usr/lib/llvm-16 -S "${DIR_IWYU}"/include-what-you-use make -C "${DIR_IWYU}"/build/ install "$MAKEJOBS"
make -C "${DIR_IWYU}"/build/ install "$MAKEJOBS"
fi
fi fi
mkdir -p "${DEPENDS_DIR}/SDKs" "${DEPENDS_DIR}/sdk-sources" mkdir -p "${DEPENDS_DIR}/SDKs" "${DEPENDS_DIR}/sdk-sources"
@ -80,3 +84,5 @@ if [ -n "$ANDROID_HOME" ] && [ ! -d "$ANDROID_HOME" ]; then
unzip -o "$ANDROID_TOOLS_PATH" -d "$ANDROID_HOME" unzip -o "$ANDROID_TOOLS_PATH" -d "$ANDROID_HOME"
yes | "${ANDROID_HOME}"/cmdline-tools/bin/sdkmanager --sdk_root="${ANDROID_HOME}" --install "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" "platform-tools" "platforms;android-${ANDROID_API_LEVEL}" "ndk;${ANDROID_NDK_VERSION}" yes | "${ANDROID_HOME}"/cmdline-tools/bin/sdkmanager --sdk_root="${ANDROID_HOME}" --install "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" "platform-tools" "platforms;android-${ANDROID_API_LEVEL}" "ndk;${ANDROID_NDK_VERSION}"
fi fi
git config --global ${CFG_DONE} "true"

@ -55,14 +55,8 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
$CONTAINER_NAME) $CONTAINER_NAME)
export CI_CONTAINER_ID export CI_CONTAINER_ID
export CI_EXEC_CMD_PREFIX="docker exec ${CI_CONTAINER_ID}" export CI_EXEC_CMD_PREFIX="docker exec ${CI_CONTAINER_ID}"
$CI_EXEC_CMD_PREFIX rsync --archive --stats --human-readable /ci_base_install/ "${BASE_ROOT_DIR}"
$CI_EXEC_CMD_PREFIX rsync --archive --stats --human-readable /ro_base/ "$BASE_ROOT_DIR"
# Fixes permission issues when there is a container UID/GID mismatch with the owner
# of the mounted bitcoin src dir.
$CI_EXEC_CMD_PREFIX git config --global --add safe.directory "*"
else else
echo "Running on host system without docker wrapper" echo "Running on host system without docker wrapper"
"${BASE_ROOT_DIR}/ci/test/01_base_install.sh"
fi fi
CI_EXEC () { CI_EXEC () {
@ -70,6 +64,13 @@ CI_EXEC () {
} }
export -f CI_EXEC export -f CI_EXEC
CI_EXEC rsync --archive --stats --human-readable /ci_base_install/ "${BASE_ROOT_DIR}" || echo "/ci_base_install/ missing"
CI_EXEC "${BASE_ROOT_DIR}/ci/test/01_base_install.sh"
CI_EXEC rsync --archive --stats --human-readable /ro_base/ "${BASE_ROOT_DIR}" || echo "Nothing to copy from ro_base"
# Fixes permission issues when there is a container UID/GID mismatch with the owner
# of the git source code directory.
CI_EXEC git config --global --add safe.directory \"*\"
CI_EXEC mkdir -p "${BINS_SCRATCH_DIR}" CI_EXEC mkdir -p "${BINS_SCRATCH_DIR}"
if [ "$CI_OS_NAME" == "macos" ]; then if [ "$CI_OS_NAME" == "macos" ]; then

Loading…
Cancel
Save