From 2916fc59028832db0299e9573c9b296699c8221e Mon Sep 17 00:00:00 2001 From: snowy-yang <102860110+snowy-yang@users.noreply.github.com> Date: Thu, 24 Sep 2026 20:30:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20CI=20=E6=91=86=E8=84=B1=20github=20?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=EF=BC=88uv=20=E8=B5=B0=20pip+tuna=E3=80=81CP?= =?UTF-8?q?ython=20=E8=B5=B0=20npmmirror=EF=BC=89=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=BD=91=E7=BB=9C=E6=8E=A2=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 第二轮实跑:检测工作流 12s 即败于 setup-uv(它从 github.com 拉 uv 二进制),部署工作流却能存活 1 分钟以上——同用 checkout 而死法不 同,判断 checkout 可用、github 拉取是检测链路的堵点。为此: - ci.yml 弃用 setup-uv:pip(tuna 索引)装 uv;uv sync 的 CPython 下载指向 npmmirror 的 python-build-standalone 镜像,包索引走 tuna; - 新增 probe.yml:把 runner 对 github/pypi/tuna/npm/npmmirror/CF API 的连通性写进 commit status(匿名可读),补齐无法读日志时的观测。 --- .gitea/workflows/ci.yml | 14 +++++++++----- .gitea/workflows/probe.yml | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 .gitea/workflows/probe.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 3c275ed..6bbefb9 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -14,14 +14,18 @@ jobs: - name: 检出代码 uses: actions/checkout@v4 - - name: 安装 uv 与 Python 3.13 - uses: astral-sh/setup-uv@v5 - with: - python-version: "3.13" - # 不开 enable-cache:Gitea 的 Actions 缓存服务不完善,常导致任务末尾失败 + # 不用 setup-uv:它要从 github.com 拉 uv 二进制与 CPython——runner + # 主机对 github 的连通性不可靠(见 probe.yml 探测)。改走 pip/tuna + # 装 uv,CPython 走 npmmirror 的 python-build-standalone 镜像, + # 包索引走 tuna。 + - name: 安装 uv + run: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple uv - name: 同步依赖(含 dev 组) run: uv sync + env: + UV_DEFAULT_INDEX: https://pypi.tuna.tsinghua.edu.cn/simple + UV_PYTHON_INSTALL_MIRROR: https://registry.npmmirror.com/-/binary/python-build-standalone - name: ruff 静态检查 run: uv run ruff check src tests examples diff --git a/.gitea/workflows/probe.yml b/.gitea/workflows/probe.yml new file mode 100644 index 0000000..f20a761 --- /dev/null +++ b/.gitea/workflows/probe.yml @@ -0,0 +1,36 @@ +name: 网络探测 + +# 探测 runner 主机对各关键站点的出网连通性,结果写入 commit status +# (公开仓库匿名可读:GET /repos/{owner}/{repo}/commits/{sha}/status)。 +# 改动本文件推送即触发。 + +on: + push: + paths: ['.gitea/workflows/probe.yml'] + +jobs: + probe: + name: runner 出网探测 + runs-on: ubuntu-latest + steps: + - name: 探测连通性并写入 commit status + env: + TOKEN: ${{ secrets.GITEA_TOKEN }} + run: | + SERVER="${GITHUB_SERVER_URL:-https://gitea.4i.hk}" + post() { + curl -s -m 10 -X POST \ + -H "Authorization: token $TOKEN" \ + -H 'Content-Type: application/json' \ + -d "{\"state\":\"success\",\"context\":\"probe/$1\",\"description\":\"$2\"}" \ + "$SERVER/api/v1/repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \ + -o /dev/null -w "probe/$1 = $2 (HTTP %{http_code})\n" + } + code() { curl -s -m 8 -o /dev/null -w '%{http_code}' -L "$1"; } + post github "$(code https://github.com)" success + post uv-release "$(code https://github.com/astral-sh/uv/releases/latest)" success + post pypi "$(code https://pypi.org/simple/)" success + post tuna "$(code https://pypi.tuna.tsinghua.edu.cn/simple/)" success + post npm "$(code https://registry.npmjs.org)" success + post npmmirror "$(code https://registry.npmmirror.com)" success + post cf-api "$(code https://api.cloudflare.com/client/v4)" success