From 12d911f35676d432ff68632a152db1b11e234c15 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Thu, 28 May 2026 10:16:31 +0800 Subject: [PATCH] ci: retry image pulls during deploy --- deploy.sh | 11 ++++++++++- tests/test_deployment_runtime_config.py | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 18142b7f..d4051ae0 100644 --- a/deploy.sh +++ b/deploy.sh @@ -18,7 +18,16 @@ if [ -f "$TAG_FILE" ]; then fi export IMAGE_TAG="$NEW_TAG" -docker compose pull +pull_ok=0 +for pull_attempt in $(seq 1 6); do + docker compose pull && pull_ok=1 && break + echo "Image pull failed or tag not ready, retry ${pull_attempt}/6..." + sleep 10 +done +if [ "$pull_ok" != "1" ]; then + echo "❌ Image pull failed after retries" + exit 1 +fi docker compose up -d # Wait for backend to be ready (retry up to 150s) diff --git a/tests/test_deployment_runtime_config.py b/tests/test_deployment_runtime_config.py index 632eb19c..5068cd2d 100644 --- a/tests/test_deployment_runtime_config.py +++ b/tests/test_deployment_runtime_config.py @@ -60,3 +60,10 @@ def test_city_detail_peak_window_uses_shared_multi_model_resolver(): assert "from src.analysis.trend_engine import _resolve_peak_hours" in source assert "peak_hours = _resolve_peak_hours(" in source + + +def test_deploy_script_retries_image_pull_for_registry_propagation(): + script = (ROOT / "deploy.sh").read_text(encoding="utf-8") + + assert "for pull_attempt in $(seq 1 6)" in script + assert "docker compose pull && pull_ok=1 && break" in script