fix(circleci): retry the checkout's file download with the fetch, since a dropped download failed the job outside the retry

This commit is contained in:
mateo-berri 2026-10-31 00:53:59 -07:00
parent eb5ba48757
commit 6306deac42
2 changed files with 10 additions and 8 deletions

View file

@ -41,11 +41,10 @@ commands:
git init
git remote add origin https://github.com/BerriAI/litellm.git
for attempt in 1 2 3; do
git fetch --filter=blob:none origin "$revision" && break
git fetch --filter=blob:none origin "$revision" && git checkout --detach FETCH_HEAD && break
[[ $attempt -lt 3 ]] || exit 1
sleep 5
done
git checkout --detach FETCH_HEAD
skip_if_unrelated_changes:
parameters:
category:

View file

@ -197,9 +197,12 @@ def test_a_docs_only_pr_job_still_skips_backend_work_after_the_checkout(tmp_path
@pytest.mark.parametrize("shell", (LINUX_SHELL, WINDOWS_SHELL), ids=("linux", "windows-bash-exe"))
@pytest.mark.parametrize(("failing_fetches", "checked_out"), ((2, True), (3, False)))
def test_a_fetch_that_fails_is_retried_and_the_step_stops_at_the_fetch_once_retries_run_out(
tmp_path: Path, shell: tuple[str, ...], failing_fetches: int, checked_out: bool
@pytest.mark.parametrize(
("failing_step", "failures", "checkouts", "checked_out"),
(("fetch", 2, 1, True), ("fetch", 3, 0, False), ("checkout", 2, 3, True), ("checkout", 3, 3, False)),
)
def test_a_failed_fetch_or_blob_download_is_retried_and_the_step_stops_on_its_error_once_retries_run_out(
tmp_path: Path, shell: tuple[str, ...], failing_step: str, failures: int, checkouts: int, checked_out: bool
) -> None:
upstream: Final = _publish_two_commits(tmp_path)
calls: Final = tmp_path / "calls"
@ -208,14 +211,14 @@ def test_a_fetch_that_fails_is_retried_and_the_step_stops_at_the_fetch_once_retr
tmp_path / "bin",
"git",
f'''echo "$1" >> "{calls}"
if [ "$1" = fetch ] && [ "$(grep -c '^fetch$' "{calls}")" -le {failing_fetches} ]; then exit 128; fi
if [ "$1" = {failing_step} ] && [ "$(grep -c '^{failing_step}$' "{calls}")" -le {failures} ]; then exit 128; fi
exec "{shutil.which("git")}" "$@"''',
)
result: Final = _run_checkout(tmp_path, upstream, {"CIRCLE_SHA1": upstream.older}, shell)
assert (result.returncode == 0) is checked_out, result.stderr
steps: Final = calls.read_text().splitlines()
assert steps.count("fetch") == min(failing_fetches + 1, 3)
assert steps.count("fetch") == min(failures + 1, 3)
assert steps.count("sleep") == steps.count("fetch") - 1
assert ("checkout" in steps) is checked_out
assert steps.count("checkout") == checkouts
head: Final = subprocess.run(["git", "rev-parse", "HEAD"], cwd=tmp_path / "job", capture_output=True, text=True)
assert (head.stdout.strip() == upstream.older) is checked_out