From 6306deac42789a4db1b8c9491f9beb024d2e4553 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Sat, 31 Oct 2026 00:53:59 -0700 Subject: [PATCH] fix(circleci): retry the checkout's file download with the fetch, since a dropped download failed the job outside the retry --- .circleci/config.yml | 3 +-- tests/unit/test_circleci_checkout.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ac057aaa7dc..67b6b6bc598 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: diff --git a/tests/unit/test_circleci_checkout.py b/tests/unit/test_circleci_checkout.py index ee474d99fc6..8e74516c33e 100644 --- a/tests/unit/test_circleci_checkout.py +++ b/tests/unit/test_circleci_checkout.py @@ -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