kibana/.buildkite/scripts/bootstrap.sh
Kibana Machine 6a103fef39
[CI] Improve reliability of macos bazel cache jobs (#138554) (#138567)
(cherry picked from commit 1019295b09)

Co-authored-by: Brian Seeders <brian.seeders@elastic.co>
2022-08-10 14:27:08 -07:00

49 lines
1.6 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
source .buildkite/scripts/common/util.sh
source .buildkite/scripts/common/setup_bazel.sh
echo "--- yarn install and bootstrap"
BOOTSTRAP_PARAMS=()
if [[ "${BOOTSTRAP_ALWAYS_FORCE_INSTALL:-}" ]]; then
BOOTSTRAP_PARAMS+=(--force-install)
fi
# Use the node_modules that is baked into the agent image, if it exists, as a cache
# But only for agents not mounting the workspace on a local ssd or in memory
# It actually ends up being slower to move all of the tiny files between the disks vs extracting archives from the yarn cache
if [[ -d ~/.kibana/node_modules && "$(pwd)" != *"/local-ssd/"* && "$(pwd)" != "/dev/shm"* ]]; then
echo "Using ~/.kibana/node_modules as a starting point"
mv ~/.kibana/node_modules ./
fi
if ! yarn kbn bootstrap "${BOOTSTRAP_PARAMS[@]}"; then
echo "bootstrap failed, trying again in 15 seconds"
sleep 15
# Most bootstrap failures will result in a problem inside node_modules that does not get fixed on the next bootstrap
# So, we should just delete node_modules in between attempts
rm -rf node_modules
echo "--- yarn install and bootstrap, attempt 2"
yarn kbn bootstrap --force-install
fi
if [[ "$DISABLE_BOOTSTRAP_VALIDATION" != "true" ]]; then
check_for_changed_files 'yarn kbn bootstrap'
fi
###
### upload ts-refs-cache artifacts as quickly as possible so they are available for download
###
if [[ "${BUILD_TS_REFS_CACHE_CAPTURE:-}" == "true" ]]; then
echo "--- Build ts-refs-cache"
node scripts/build_ts_refs.js --ignore-type-failures
echo "--- Upload ts-refs-cache"
cd "$KIBANA_DIR/target/ts_refs_cache"
gsutil cp "*.zip" 'gs://kibana-ci-ts-refs-cache/'
cd "$KIBANA_DIR"
fi