fix(ci): 彻底修复migration diff step卡住问题 — 用后台进程+轮询替代timeout命令
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Unit Tests (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
CI/CD Pipeline / Build Staging API Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Web Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Worker Image (push) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (push) Has been cancelled
CI/CD Pipeline / Production Browser E2E (push) Failing after 1510h31m21s
CI/CD Pipeline / Deploy Production (push) Failing after 1510h31m22s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 1510h31m22s
CI/CD Pipeline / Build Production Web Image (push) Failing after 1510h31m22s
CI/CD Pipeline / Build Production API Image (push) Failing after 1510h31m23s

- Gitea Actions v0.2.6不支持step级continue-on-error和timeout-minutes
- timeout命令在host runner环境下行为不可靠(可能不生效)
- 改用后台进程+30秒轮询超时,确保无论fetch成功/失败/卡住都在30秒内返回
- set +e + exit 0确保step永远不会失败,真正做到准备工作不阻断主流程
This commit is contained in:
CI Bot
2026-07-15 16:21:27 +08:00
parent 8ffc22f348
commit cebb33c2e2
+1 -3
View File
@@ -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"