From cebb33c2e22c0490783be769fc3f083137b122d9 Mon Sep 17 00:00:00 2001 From: CI Bot Date: Wed, 15 Jul 2026 16:21:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E5=BD=BB=E5=BA=95=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?migration=20diff=20step=E5=8D=A1=E4=BD=8F=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?=E2=80=94=20=E7=94=A8=E5=90=8E=E5=8F=B0=E8=BF=9B=E7=A8=8B+?= =?UTF-8?q?=E8=BD=AE=E8=AF=A2=E6=9B=BF=E4=BB=A3timeout=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Gitea Actions v0.2.6不支持step级continue-on-error和timeout-minutes - timeout命令在host runner环境下行为不可靠(可能不生效) - 改用后台进程+30秒轮询超时,确保无论fetch成功/失败/卡住都在30秒内返回 - set +e + exit 0确保step永远不会失败,真正做到准备工作不阻断主流程 --- .gitea/workflows/ci-cd.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitea/workflows/ci-cd.yml b/.gitea/workflows/ci-cd.yml index df0e92f4b..520296165 100755 --- a/.gitea/workflows/ci-cd.yml +++ b/.gitea/workflows/ci-cd.yml @@ -143,13 +143,11 @@ jobs: ' - name: Prepare git for migration diff - continue-on-error: true - timeout-minutes: 2 shell: sh env: GITHUB_TOKEN: ${{ github.token }} GITHUB_SERVER_URL: ${{ github.server_url }} - run: "set -eu\nif command -v git >/dev/null 2>&1; then\n if [ ! -d .git ]; then\n git init -q\n git config user.email \"ci@localhost\"\n git config user.name \"CI\"\n git add .\n git commit -q -m \"current\"\n REPO_URL=\"https://x-access-token:${GITHUB_TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git\"\n git remote add origin \"$REPO_URL\"\n fi\n timeout 30 git fetch origin develop --depth=1 -q 2>/dev/null || echo \"WARN: cannot fetch develop, will check all migrations\"\nelse\n echo \"WARN: git not available, will check all migrations\"\nfi\n" + run: "set +e\nif command -v git >/dev/null 2>&1; then\n if [ ! -d .git ]; then\n git init -q\n git config user.email \"ci@localhost\"\n git config user.name \"CI\"\n git add .\n git commit -q -m \"current\"\n REPO_URL=\"https://x-access-token:${GITHUB_TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git\"\n git remote add origin \"$REPO_URL\" 2>/dev/null\n fi\n # 后台fetch + 30秒超时保护,防止git fetch卡住拖慢CI\n git fetch origin develop --depth=1 -q >/dev/null 2>&1 &\n FETCH_PID=$!\n for i in $(seq 1 30); do\n if ! kill -0 $FETCH_PID 2>/dev/null; then\n break\n fi\n sleep 1\n done\n if kill -0 $FETCH_PID 2>/dev/null; then\n kill $FETCH_PID 2>/dev/null\n echo \"WARN: git fetch timeout after 30s, will check all migrations\"\n else\n wait $FETCH_PID 2>/dev/null\n if [ $? -eq 0 ]; then\n echo \"INFO: fetched origin/develop successfully\"\n else\n echo \"WARN: git fetch failed, will check all migrations\"\n fi\n fi\nelse\n echo \"WARN: git not available, will check all migrations\"\nfi\nexit 0\n" - name: Check migration safety shell: sh run: "set -eu\nif git rev-parse origin/develop >/dev/null 2>&1; then\n python3 scripts/check_migration_safety.py --allow-medium-risk --diff-against origin/develop\nelse\n python3 scripts/check_migration_safety.py --allow-medium-risk\nfi\n"