From a09d1788cd8a11ab224f164f0269161447261f8c Mon Sep 17 00:00:00 2001 From: snowy-yang <102860110+snowy-yang@users.noreply.github.com> Date: Thu, 24 Sep 2026 20:48:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20CI=20=E9=94=81=E5=AE=9A=20python:3.13-sl?= =?UTF-8?q?im=20=E5=AE=B9=E5=99=A8=E3=80=81=E8=B5=B0=20archive=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=8B=89=E6=BA=90=E7=A0=81=EF=BC=8C=E6=AF=8F=E6=AD=A5?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E4=B8=8A=E6=8A=A5=20status?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 五轮实跑证据链:工作流多次 7~26s 即死而 probe(纯 curl)每次成功; 换成 gitea 本地 clone 依旧 8s 即死——默认镜像工具链不明是主因,git/ github 只是其中一环。收缩依赖面:container 固定 python:3.13-slim (保证 python3.13+pip,免去 uv 下载 CPython);源码经 Gitea archive 接口拉 tarball(curl 已被 probe 证明可用);pyright 的 node 缺失时 apt 兜底。日志匿名不可读,改为每个关键步骤把成败写进 commit status (远程可读),失败点从此可直接定位。 部署工作流同步换 archive 拉源码;deploy/secrets 探测两轮均报 MISSING,待仓库侧补配 secrets。 --- .gitea/workflows/ci.yml | 58 +++++++++++++++++++++++--------- .gitea/workflows/deploy-docs.yml | 12 ++++--- 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 966de7a..252e5c6 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -10,24 +10,50 @@ jobs: lint: name: ruff + pyright runs-on: ubuntu-latest + # 固定官方 python 镜像:保证 python3.13 + pip 在场(runner 默认镜像 + # 工具链不明,实测任务曾 7s 即死);runner 不支持 container 时回落 + # 宿主机 python,此时 uv 经下方镜像变量自行下载 CPython + container: python:3.13-slim steps: - # 不用 actions/checkout:runner 对 github 的连通性不稳定(probe.yml - # 实测多次工作流死于 checkout 阶段),改从 Gitea 本体克隆 - - name: 检出代码 - run: git clone --depth=1 "${GITHUB_SERVER_URL:-https://gitea.4i.hk}/${GITHUB_REPOSITORY}.git" . - - - name: 安装 uv - run: pip install uv - - - name: 同步依赖(含 dev 组) - run: uv sync + # 不用 actions/checkout、不用 git:runner 对 github 连通性不稳 + # (probe.yml 实测),改走 Gitea archive 接口拉源码 tarball;每步 + # 结果写进 commit status(日志匿名不可读,status 远程可读) + - name: 拉源码、装依赖并执行检测 env: - # CPython 3.13 走 npmmirror 的 python-build-standalone 镜像, - # 避开 github releases 的间歇性不通 + TOKEN: ${{ secrets.GITEA_TOKEN }} UV_PYTHON_INSTALL_MIRROR: https://registry.npmmirror.com/-/binary/python-build-standalone + run: | + set -e + SERVER="${GITHUB_SERVER_URL:-https://gitea.4i.hk}" + note() { + curl -s -m 10 -X POST \ + -H "Authorization: token $TOKEN" \ + -H 'Content-Type: application/json' \ + -d "{\"state\":\"$3\",\"context\":\"ci/$1\",\"description\":\"$2\"}" \ + "$SERVER/api/v1/repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \ + -o /dev/null + } + trap 'note error "步骤意外失败,详见 Actions 日志" failure' ERR - - name: ruff 静态检查 - run: uv run ruff check src tests examples + curl -sL "$SERVER/api/v1/repos/$GITHUB_REPOSITORY/archive/$GITHUB_SHA.tar.gz" -o src.tgz \ + && mkdir src && tar -xzf src.tgz -C src --strip-components=1 && cd src \ + || { note fetch "archive 拉取失败" failure; exit 1; } + note fetch ok success - - name: pyright 类型检查 - run: uv run pyright + pip install uv >/dev/null 2>&1 \ + || { note pip "pip 安装 uv 失败" failure; exit 1; } + note pip ok success + + uv sync >/dev/null 2>&1 \ + || { note sync "uv sync 失败" failure; exit 1; } + note sync ok success + + uv run ruff check src tests examples \ + || { note ruff "ruff check 未通过" failure; exit 1; } + note ruff ok success + + # pyright 需要 node:镜像里没有就装 Debian 的(保底 pyright 自带下载) + command -v node >/dev/null 2>&1 || { apt-get update -qq && apt-get install -y -qq nodejs; } || true + uv run pyright \ + || { note pyright "pyright 未通过" failure; exit 1; } + note pyright ok success diff --git a/.gitea/workflows/deploy-docs.yml b/.gitea/workflows/deploy-docs.yml index 4425550..7da7367 100644 --- a/.gitea/workflows/deploy-docs.yml +++ b/.gitea/workflows/deploy-docs.yml @@ -19,10 +19,14 @@ jobs: name: Cloudflare Pages runs-on: ubuntu-latest steps: - # 不用 actions/checkout(runner 对 github 连通性不稳,见 probe.yml), - # 改从 Gitea 本体克隆 - - name: 检出代码 - run: git clone --depth=1 "${GITHUB_SERVER_URL:-https://gitea.4i.hk}/${GITHUB_REPOSITORY}.git" . + # 不用 actions/checkout、不用 git(runner 对 github 连通性不稳,见 + # probe.yml):改走 Gitea archive 接口拉源码 tarball + - name: 拉源码 + run: | + SERVER="${GITHUB_SERVER_URL:-https://gitea.4i.hk}" + curl -sL "$SERVER/api/v1/repos/$GITHUB_REPOSITORY/archive/$GITHUB_SHA.tar.gz" -o src.tgz \ + && mkdir src && tar -xzf src.tgz -C src --strip-components=1 \ + && mv src/* . && rm -rf src src.tgz # 日志匿名不可读:把 secrets 在场情况写进 commit status 便于远程 # 排查(只报 set/MISSING,不泄露值)