devops: speedup initial browser checkout (#4352)
Instead of checking out the whole repository, we now do a shallow clone. We then gradually "unshallow" the clone, looking for the `BASE_REVISION`. This should fix experimental mac-11 builder.
This commit is contained in:
parent
bba8c98c69
commit
b94a7c0e60
|
|
@ -71,7 +71,7 @@ fi
|
||||||
# if there's no checkout folder - checkout one.
|
# if there's no checkout folder - checkout one.
|
||||||
if ! [[ -d $CHECKOUT_PATH ]]; then
|
if ! [[ -d $CHECKOUT_PATH ]]; then
|
||||||
echo "-- $FRIENDLY_CHECKOUT_PATH is missing - checking out.."
|
echo "-- $FRIENDLY_CHECKOUT_PATH is missing - checking out.."
|
||||||
git clone --single-branch --branch $BASE_BRANCH $REMOTE_URL $CHECKOUT_PATH
|
git clone --single-branch --depth 1 --branch $BASE_BRANCH $REMOTE_URL $CHECKOUT_PATH
|
||||||
else
|
else
|
||||||
echo "-- checking $FRIENDLY_CHECKOUT_PATH folder - OK"
|
echo "-- checking $FRIENDLY_CHECKOUT_PATH folder - OK"
|
||||||
fi
|
fi
|
||||||
|
|
@ -102,11 +102,30 @@ else
|
||||||
git remote add $REMOTE_BROWSER_UPSTREAM $REMOTE_URL
|
git remote add $REMOTE_BROWSER_UPSTREAM $REMOTE_URL
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If not, fetch from REMOTE_BROWSER_UPSTREAM and check one more time.
|
# Check if our checkout contains BASE_REVISION.
|
||||||
git fetch $REMOTE_BROWSER_UPSTREAM $BASE_BRANCH
|
# If not, fetch from REMOTE_BROWSER_UPSTREAM and slowly fetch more and more commits
|
||||||
if ! git cat-file -e $BASE_REVISION^{commit}; then
|
# until we find $BASE_REVISION.
|
||||||
echo "ERROR: $FRIENDLY_CHECKOUT_PATH/ does not include the BASE_REVISION (@$BASE_REVISION). Wrong revision number?"
|
# This technique allows us start with a shallow clone.
|
||||||
exit 1
|
if ! git cat-file -e $BASE_REVISION^{commit} 2>/dev/null; then
|
||||||
|
# Detach git head so that we can fetch into branch.
|
||||||
|
git checkout --detach >/dev/null 2>/dev/null
|
||||||
|
|
||||||
|
# Fetch 128 commits first, and then double the amount every iteration.
|
||||||
|
FETCH_DEPTH=128
|
||||||
|
SUCCESS="no"
|
||||||
|
while (( FETCH_DEPTH <= 8192 )); do
|
||||||
|
echo "Fetching ${FETCH_DEPTH} commits to find base revision..."
|
||||||
|
git fetch --depth "${FETCH_DEPTH}" $REMOTE_BROWSER_UPSTREAM $BASE_BRANCH
|
||||||
|
FETCH_DEPTH=$(( FETCH_DEPTH * 2 ));
|
||||||
|
if git cat-file -e $BASE_REVISION^{commit} >/dev/null; then
|
||||||
|
SUCCESS="yes"
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ "${SUCCESS}" == "no" ]]; then
|
||||||
|
echo "ERROR: $FRIENDLY_CHECKOUT_PATH/ does not include the BASE_REVISION (@$BASE_REVISION). Wrong revision number?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "-- checking $FRIENDLY_CHECKOUT_PATH repo has BASE_REVISION (@$BASE_REVISION) commit - OK"
|
echo "-- checking $FRIENDLY_CHECKOUT_PATH repo has BASE_REVISION (@$BASE_REVISION) commit - OK"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue