probe: runner 环境盘点(python3/pip/uv/git/npx 在场 + clone/装 uv 实测)

This commit is contained in:
snowy-yang committed 2026-09-24 20:42:58 +08:00
1 parent 98ed680c73
commit b3edd79674
1 file changed
+34 -13
+34 -13
View File
@@ -1,21 +1,20 @@
name: 网络探测 name: 网络探测
# 探测 runner 主机对各关键站点的出网连通性,结果写入 commit status # runner 环境盘点:出网连通性 + 基础工具链 + clone/装 uv 迷你实测,
# (公开仓库匿名可读:GET /repos/{owner}/{repo}/commits/{sha}/status)。 # 结果写入 commit status(公开仓库匿名可读)。
# 改动本文件推送即触发。 # 改动本文件推送即触发。
on: on:
push: push:
paths: ['.gitea/workflows/probe.yml'] paths: ['.gitea/workflows/probe.yml']
workflow_dispatch:
jobs: jobs:
probe: probe:
name: runner 出网探测 name: runner 环境探测
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: 探测连通性并写入 commit status - name: 工具链与连通性探测
env:
TOKEN: ${{ secrets.GITEA_TOKEN }}
run: | run: |
SERVER="${GITHUB_SERVER_URL:-https://gitea.4i.hk}" SERVER="${GITHUB_SERVER_URL:-https://gitea.4i.hk}"
post() { post() {
@@ -26,11 +25,33 @@ jobs:
"$SERVER/api/v1/repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \ "$SERVER/api/v1/repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \
-o /dev/null -w "probe/$1 = $2 (HTTP %{http_code})\n" -o /dev/null -w "probe/$1 = $2 (HTTP %{http_code})\n"
} }
inv() { command -v "$1" >/dev/null 2>&1 && echo yes || echo no; }
code() { curl -s -m 8 -o /dev/null -w '%{http_code}' -L "$1"; } 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 python3 "$(python3 -V 2>/dev/null || echo absent)"
post pypi "$(code https://pypi.org/simple/)" success post pip "$(inv pip)"
post tuna "$(code https://pypi.tuna.tsinghua.edu.cn/simple/)" success post pip3 "$(inv pip3)"
post npm "$(code https://registry.npmjs.org)" success post uv "$(inv uv)"
post npmmirror "$(code https://registry.npmmirror.com)" success post git "$(inv git)"
post cf-api "$(code https://api.cloudflare.com/client/v4)" success post npx "$(inv npx)"
post pypi "$(code https://pypi.org/simple/)"
post npmmirror "$(code https://registry.npmmirror.com)"
rm -rf /tmp/src
if git clone --depth=1 "$SERVER/$GITHUB_REPOSITORY.git" /tmp/src >/dev/null 2>&1; then
post clone ok
else
post clone fail
fi
if cd /tmp/src 2>/dev/null \
&& { pip install uv >/dev/null 2>&1 \
|| pip3 install uv >/dev/null 2>&1 \
|| python3 -m pip install uv >/dev/null 2>&1; }; then
post pip-install-uv ok
else
post pip-install-uv fail
fi
UV_BIN="$(command -v uv || echo "$HOME/.local/bin/uv")"
post uv-version "$("$UV_BIN" --version 2>/dev/null || echo none)"