Skip to content

Commit bfbb80f

Browse files
authored
Make SkillsBench curl retry flag compatible (#1738)
1 parent 13d6993 commit bfbb80f

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

examples/skillsbench-benchmark-run-smoke.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5893,13 +5893,14 @@ def test_skillsbench_docker_task_staging_rewrites_wget_gpg_key_download() -> Non
58935893
encoding="utf-8"
58945894
)
58955895
assert "wget -qO -" not in staged_text, staged_text
5896+
curl_retry_all_errors_arg = skillsbench_loop._dockerfile_curl_retry_all_errors_arg()
58965897
assert (
5897-
"curl -fsSL --retry 8 --retry-all-errors --retry-delay 3 "
5898+
f"curl -fsSL --retry 8 {curl_retry_all_errors_arg} --retry-delay 3 "
58985899
"--connect-timeout 60 --max-time 300 "
58995900
"https://example.invalid/public.key | gpg --dearmor"
59005901
) in staged_text, staged_text
59015902
assert (
5902-
"curl -fsSL --retry 8 --retry-all-errors --retry-delay 3 "
5903+
f"curl -fsSL --retry 8 {curl_retry_all_errors_arg} --retry-delay 3 "
59035904
"--connect-timeout 60 --max-time 300 "
59045905
"https://aquasecurity.github.io/trivy-repo/deb/public.key | "
59055906
"gpg --dearmor"
@@ -5987,7 +5988,7 @@ def test_skillsbench_docker_task_staging_hardens_build_downloads() -> None:
59875988
"apache-druid-0.20.0-bin.tar.gz"
59885989
) in staged_text, staged_text
59895990
assert (
5990-
"curl -fL --retry 5 --retry-all-errors --retry-delay 2 "
5991+
f"curl -fL --retry 5 {skillsbench_loop._dockerfile_curl_retry_all_errors_arg()} --retry-delay 2 "
59915992
"--connect-timeout 60 --max-time 600 "
59925993
"https://github.com/coursier/coursier/releases/download/"
59935994
"v2.1.25-M23/cs-x86_64-pc-linux.gz"
@@ -6043,7 +6044,7 @@ def test_skillsbench_docker_task_staging_patches_dockerfile_uv_bootstrap() -> No
60436044
), staged_text
60446045
assert "uv==${LOOPX_SKILLSBENCH_UV_VERSION}" in staged_text, staged_text
60456046
assert "INSTALLER_DOWNLOAD_URL" in staged_text, staged_text
6046-
assert "--retry-all-errors" in staged_text, staged_text
6047+
assert skillsbench_loop._dockerfile_curl_retry_all_errors_arg() in staged_text, staged_text
60476048
assert (
60486049
"curl -LsSf https://astral.sh/uv/0.9.22/install.sh | sh &&"
60496050
not in staged_text

scripts/skillsbench_automation_loop.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6991,6 +6991,10 @@ def _dockerfile_instruction_block_end(lines: list[str], start: int) -> int:
69916991
return end
69926992

69936993

6994+
def _dockerfile_curl_retry_all_errors_arg() -> str:
6995+
return "$(curl --help all 2>/dev/null | grep -q -- '--retry-all-errors' && printf '%s' '--retry-all-errors' || true)"
6996+
6997+
69946998
def patch_dockerfile_uv_bootstrap_mirror(dockerfile: Path) -> dict[str, Any]:
69956999
"""Make staged Dockerfile uv bootstraps tolerate installer egress failures."""
69967000

@@ -7034,7 +7038,7 @@ def patch_dockerfile_uv_bootstrap_mirror(dockerfile: Path) -> dict[str, Any]:
70347038
" fi; \\\n"
70357039
" if ! command -v uvx >/dev/null 2>&1; then \\\n"
70367040
" export INSTALLER_DOWNLOAD_URL=\"${LOOPX_SKILLSBENCH_UV_RELEASE_MIRROR}/${LOOPX_SKILLSBENCH_UV_VERSION}\"; \\\n"
7037-
" curl -LsSf --retry 5 --retry-all-errors --retry-delay 2 --connect-timeout 30 \\\n"
7041+
f" curl -LsSf --retry 5 {_dockerfile_curl_retry_all_errors_arg()} --retry-delay 2 --connect-timeout 30 \\\n"
70387042
" \"https://astral.sh/uv/${LOOPX_SKILLSBENCH_UV_VERSION}/install.sh\" | sh; \\\n"
70397043
" fi; \\\n"
70407044
" if [ -x \"${HOME}/.local/bin/uv\" ]; then install -m 0755 \"${HOME}/.local/bin/uv\" /usr/local/bin/uv; fi; \\\n"
@@ -7171,7 +7175,8 @@ def patch_dockerfile_wget_gpg_key_retry(dockerfile: Path) -> bool:
71717175

71727176
def gpg_key_curl_command(url: str) -> str:
71737177
return (
7174-
"curl -fsSL --retry 8 --retry-all-errors --retry-delay 3 "
7178+
"curl -fsSL --retry 8 "
7179+
f"{_dockerfile_curl_retry_all_errors_arg()} --retry-delay 3 "
71757180
f"--connect-timeout 60 --max-time 300 {url} | gpg --dearmor"
71767181
)
71777182

@@ -7338,7 +7343,7 @@ def replace_curl(match: re.Match[str]) -> str:
73387343
return match.group(0)
73397344
return (
73407345
"curl"
7341-
f"{args} --retry 5 --retry-all-errors --retry-delay 2 "
7346+
f"{args} --retry 5 {_dockerfile_curl_retry_all_errors_arg()} --retry-delay 2 "
73427347
f"--connect-timeout 60 --max-time 600 {match.group('url')}"
73437348
)
73447349

0 commit comments

Comments
 (0)