[CI] Authenticate and retry git clones in install scripts (#37647)
This commit is contained in:
@@ -135,38 +135,8 @@ ensure_httpx() {
|
||||
install_with_retry docker exec ci_sglang pip install --cache-dir=/sgl-data/pip-cache --upgrade 'httpx>=0.25.0'
|
||||
}
|
||||
|
||||
# Helper function to git clone with retries
|
||||
git_clone_with_retry() {
|
||||
local repo_url="$1"
|
||||
local dest_dir="${2:-}"
|
||||
local branch_args="${3:-}"
|
||||
local max_attempts=3
|
||||
|
||||
for attempt in $(seq 1 $max_attempts); do
|
||||
echo "Git clone attempt $attempt/$max_attempts: $repo_url"
|
||||
|
||||
# prevent from partial clone
|
||||
if [ -n "$dest_dir" ] && [ -d "$dest_dir" ]; then
|
||||
rm -rf "$dest_dir"
|
||||
fi
|
||||
|
||||
if git \
|
||||
-c http.lowSpeedLimit=1000 \
|
||||
-c http.lowSpeedTime=30 \
|
||||
clone --depth 1 ${branch_args:+$branch_args} "$repo_url" "$dest_dir"; then
|
||||
echo "Git clone succeeded."
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ $attempt -lt $max_attempts ]; then
|
||||
echo "Git clone failed, retrying in 5 seconds..."
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Git clone failed after $max_attempts attempts: $repo_url"
|
||||
return 1
|
||||
}
|
||||
# shellcheck source=scripts/ci/utils/git_clone_with_retry.sh
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/../utils/git_clone_with_retry.sh"
|
||||
|
||||
# Install checkout sglang
|
||||
if [ -n "$SKIP_SGLANG_BUILD" ]; then
|
||||
|
||||
@@ -8,6 +8,9 @@ set -euxo pipefail
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"
|
||||
|
||||
# shellcheck source=scripts/ci/utils/git_clone_with_retry.sh
|
||||
source "${SCRIPT_DIR}/../utils/git_clone_with_retry.sh"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Timing helper
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -207,9 +210,7 @@ install_gdrcopy() {
|
||||
done
|
||||
}
|
||||
|
||||
rm -rf "${gdrcopy_root}"
|
||||
git clone --branch "v${gdrcopy_version}" --depth 1 \
|
||||
https://github.com/NVIDIA/gdrcopy.git "${gdrcopy_root}"
|
||||
git_clone_with_retry https://github.com/NVIDIA/gdrcopy.git "${gdrcopy_root}" "--branch v${gdrcopy_version}"
|
||||
(
|
||||
cd "${gdrcopy_root}/packages"
|
||||
CUDA=/usr/local/cuda ./build-deb-packages.sh
|
||||
@@ -762,7 +763,7 @@ install_extra_deps() {
|
||||
fi
|
||||
|
||||
if [ "$IS_BLACKWELL" != "1" ]; then
|
||||
git clone --branch v0.5 --depth 1 https://github.com/EvolvingLMMs-Lab/lmms-eval.git
|
||||
git_clone_with_retry https://github.com/EvolvingLMMs-Lab/lmms-eval.git lmms-eval "--branch v0.5"
|
||||
$PIP_CMD install -e lmms-eval/ $PIP_INSTALL_SUFFIX
|
||||
# lmms-eval v0.5 pulls antlr4-python3-runtime==4.7.2, clobbering the
|
||||
# 4.9.3 that sgl-eval's latex2sympy2_extended needs (4.7.2 ImportError
|
||||
@@ -784,7 +785,7 @@ install_test_tools() {
|
||||
|
||||
# Install human-eval (subshell keeps cd local)
|
||||
$PIP_CMD install "setuptools==70.0.0" $PIP_INSTALL_SUFFIX
|
||||
[ -d human-eval ] || git clone https://github.com/merrymercy/human-eval.git
|
||||
[ -d human-eval ] || git_clone_with_retry https://github.com/merrymercy/human-eval.git human-eval
|
||||
(
|
||||
cd human-eval
|
||||
$PIP_CMD install -e . --no-build-isolation $PIP_INSTALL_SUFFIX
|
||||
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
# GitHub rate limits anonymous git-over-HTTPS per source IP; shared runner egress
|
||||
# trips it as "could not read Username for 'https://github.com'".
|
||||
|
||||
_git_with_github_auth() {
|
||||
# Disable xtrace before touching the auth header so it is not echoed.
|
||||
local xtrace=0
|
||||
[[ $- == *x* ]] && xtrace=1
|
||||
{ set +x; } 2>/dev/null
|
||||
|
||||
local repo_root
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
|
||||
# Persisted by actions/checkout; absent under persist-credentials: false, and
|
||||
# the clone then stays anonymous by design.
|
||||
local header
|
||||
header="$(git -C "$repo_root" config --local --get http.https://github.com/.extraheader 2>/dev/null || true)"
|
||||
|
||||
local rc=0
|
||||
if [ -z "$header" ]; then
|
||||
"$@" || rc=$?
|
||||
else
|
||||
GIT_CONFIG_COUNT=1 \
|
||||
GIT_CONFIG_KEY_0="http.https://github.com/.extraheader" \
|
||||
GIT_CONFIG_VALUE_0="$header" \
|
||||
"$@" || rc=$?
|
||||
fi
|
||||
|
||||
[ "$xtrace" = 1 ] && set -x
|
||||
return $rc
|
||||
}
|
||||
|
||||
# Helper function to git clone with retries
|
||||
git_clone_with_retry() {
|
||||
local repo_url="$1"
|
||||
local dest_dir="${2:-}"
|
||||
local branch_args="${3:-}"
|
||||
local max_attempts=3
|
||||
|
||||
for attempt in $(seq 1 $max_attempts); do
|
||||
echo "Git clone attempt $attempt/$max_attempts: $repo_url"
|
||||
|
||||
# prevent from partial clone
|
||||
if [ -n "$dest_dir" ] && [ -d "$dest_dir" ]; then
|
||||
rm -rf "$dest_dir"
|
||||
fi
|
||||
|
||||
if _git_with_github_auth git \
|
||||
-c http.lowSpeedLimit=1000 \
|
||||
-c http.lowSpeedTime=30 \
|
||||
clone --depth 1 ${branch_args:+$branch_args} "$repo_url" "$dest_dir"; then
|
||||
echo "Git clone succeeded."
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ $attempt -lt $max_attempts ]; then
|
||||
echo "Git clone failed, retrying in 5 seconds..."
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Git clone failed after $max_attempts attempts: $repo_url"
|
||||
return 1
|
||||
}
|
||||
Reference in New Issue
Block a user