From 56f0ee089b2e992ee5b4c1a16ff4f6f2f6128810 Mon Sep 17 00:00:00 2001 From: linmeng <819991304@qq.com> Date: Tue, 28 Jul 2026 17:25:44 +0800 Subject: [PATCH] fix: bound Gitea checkout latency --- .gitea/workflows/backend-quality-gate.yml | 3 ++- docs/BUG_HISTORY.md | 2 +- frontend/tests/staging-backend-workflows.test.ts | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/backend-quality-gate.yml b/.gitea/workflows/backend-quality-gate.yml index 78760302..a873f082 100644 --- a/.gitea/workflows/backend-quality-gate.yml +++ b/.gitea/workflows/backend-quality-gate.yml @@ -29,7 +29,8 @@ jobs: git init . git remote remove origin 2>/dev/null || true git remote add origin https://git.copse.top/root/Jyotisha.git - git fetch --no-tags origin "$GITEA_SHA" + git -c http.connectTimeout=15 -c http.lowSpeedLimit=1024 -c http.lowSpeedTime=30 \ + fetch --depth=1 --no-tags origin "$GITEA_SHA" git checkout --detach --force "$GITEA_SHA" - name: Build and push images diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 6d1cbad3..95dd9274 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -1577,7 +1577,7 @@ - 用户现象:staging 自动部署在构建 API 镜像时失败,阿里云 `library/python:3.12-slim` 返回 `pull access denied` / `insufficient_scope`;同路径的 Node 镜像也不可拉取。 - 触发条件:`staging` push 后,Runner 使用 `registry.cn-hangzhou.aliyuncs.com/library/python:3.12-slim` 或对应 Node 地址解析基础镜像。 - 根因:这两个阿里云 `library/*` 地址并非当前凭据可访问的公共镜像仓库;同时 xiaoxin 直连 Docker Hub 超时,导致不能简单换回官方短名称。 -- 修复:工作流保持单 job 构建发布部署链路;API 基础镜像改为已在 xiaoxin 完整拉取验证的 DaoCloud Python 3.12 slim,Web 基础镜像改为已完整拉取验证的华为云 DDN Node 22 alpine;API 构建使用实测最快的阿里云 PyPI 并设置 60 秒 pip 超时;远端 `ubuntu` 的 Docker 操作继续使用免交互 sudo。 +- 修复:工作流保持单 job 构建发布部署链路;checkout 使用当前 SHA 的 depth-1 浅拉取并设置连接/低速超时;API 基础镜像改为已在 xiaoxin 完整拉取验证的 DaoCloud Python 3.12 slim,Web 基础镜像改为已完整拉取验证的华为云 DDN Node 22 alpine;API 构建使用实测最快的阿里云 APT/PyPI 并设置有限重试与超时;远端 `ubuntu` 的 Docker 操作继续使用免交互 sudo。 - 验证:修复前两个阿里云基础镜像地址均返回拒绝,Docker Hub 超时;替代 Python/Node 基础镜像均在真实 Runner 主机完成整镜像 pull。首次修复运行实际阻塞在 Debian 官方 APT,后续 shell 命令尚未进入 pip;同机探测阿里云 Debian 索引约 0.11 秒/1.29 MB/s,清华约 0.30 秒/461 KB/s,官方约 1.22 秒/115 KB/s;阿里云 PyPI 也为候选中最快。后续构建、ACR push、服务器 Compose 和健康检查继续按运行日志闭环。 - 防复发:staging Dockerfile 的基础镜像必须在 xiaoxin 完整 `docker pull` 验证;APT 与 Python 包源均基于 Runner 实测选择并设置有限重试/超时,避免网络异常无限占用工作流。 - 相关记录:BUG-082、BUG-083、BUG-084 diff --git a/frontend/tests/staging-backend-workflows.test.ts b/frontend/tests/staging-backend-workflows.test.ts index a5a53b0b..4acfa027 100644 --- a/frontend/tests/staging-backend-workflows.test.ts +++ b/frontend/tests/staging-backend-workflows.test.ts @@ -467,6 +467,8 @@ test("Gitea staging push builds ACR images and deploys them on the test server", assert.match(workflow, /push:\n\s+branches: \[staging\]/); assert.doesNotMatch(workflow, /pull_request:|workflow_dispatch:|needs: validate/); assert.match(workflow, /crpi-d1feco6itet73spp\.cn-hongkong\.personal\.cr\.aliyuncs\.com\/copse\/jyotisha/); + assert.match(workflow, /fetch --depth=1 --no-tags origin "\$GITEA_SHA"/); + assert.match(workflow, /http\.lowSpeedTime=30/); assert.match(workflow, /docker build .*railway-api\.Dockerfile/); assert.match(workflow, /docker build .*railway-web\.Dockerfile/); assert.match(workflow, /docker push "\$IMAGE_REPOSITORY:api-\$GITEA_SHA"/);