Skip to content

Commit 201dd67

Browse files
committed
ci: CN 镜像检查从「可达」升级为「可达且内容一致」
可达不等于对。内容过期的镜像资产照样返回 200,而这不是假设 —— 只要 fork 在同一个上游 版本上重切 tag 就会发生:gitcode 不能覆盖同名资产(release 的 DELETE 还返回 405),于是 旧 tarball 留在那里、GLOBAL 已经往前走了,CN 用户静默拿到上一版。在 mcpplibs/libglvnd v1.7.0 上连着遇到两次。 tests/list_cn_urls.lua 本来就在输出 `url<TAB>sha256`,这次是用上第二列而不是丢掉它。 body 本来也要下载(gitcode 的 release 页面可以 200 而资产已经没了),所以顺手做个哈希不 增加成本。 空流单独判:curl 失败时管道给出的是空输入,它的 sha256 是个固定常量,当成不可达处理而 不是当成「内容不符」——后者的报错会把人指向错误的方向。 本地验证过这条检查确实会抓到当前 libglvnd 的 CN 不一致。
1 parent 7153be3 commit 201dd67

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

‎.github/workflows/validate.yml‎

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,16 @@ jobs:
316316
- uses: actions/checkout@v4
317317
- name: Install lua
318318
run: sudo apt-get install -y --no-install-recommends lua5.4
319-
- name: Check CN mirror assets are reachable
319+
# REACHABLE IS NOT ENOUGH, and the gap is not hypothetical: a mirror
320+
# asset whose CONTENT is stale answers 200 all day. It happens whenever a
321+
# fork tag is re-cut at the same upstream version — gitcode cannot
322+
# overwrite a same-named asset (and DELETE on a release returns 405), so
323+
# the old tarball stays up while GLOBAL moves on, and CN users silently
324+
# get the previous build. Measured twice on mcpplibs/libglvnd v1.7.0.
325+
#
326+
# tests/list_cn_urls.lua already emits `url<TAB>sha256`; this now uses
327+
# the second column instead of throwing it away.
328+
- name: Check CN mirror assets are reachable AND match the descriptor
320329
env:
321330
PKGS: ${{ needs.select.outputs.pkgs }}
322331
run: |
@@ -338,16 +347,27 @@ jobs:
338347
echo "checking $total CN mirror url(s)"
339348
while IFS=$'\t' read -r url sha; do
340349
[ -z "$url" ] && continue
341-
# follow redirects; gitcode release assets resolve to object storage
342-
code=$(curl -fsSL -o /dev/null -w '%{http_code}' --retry 2 --max-time 60 "$url" || echo "000")
343-
if [ "$code" != "200" ]; then
344-
echo "::error::CN mirror unreachable ($code): $url"
350+
# follow redirects; gitcode release assets resolve to object storage.
351+
# The body is downloaded either way — a gitcode release page can 200
352+
# while the asset behind it is gone — so hashing it costs nothing
353+
# extra and answers the second question too.
354+
got=$(curl -fsSL --retry 2 --max-time 120 "$url" 2>/dev/null | sha256sum | cut -d' ' -f1)
355+
if [ -z "$got" ] || [ "$got" = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ]; then
356+
# empty stream hashes to that constant; treat it as unreachable
357+
echo "::error::CN mirror unreachable or empty: $url"
358+
fail=1
359+
elif [ -n "$sha" ] && [ "$got" != "$sha" ]; then
360+
echo "::error::CN mirror CONTENT differs from the descriptor: $url"
361+
echo " descriptor: $sha"
362+
echo " mirror: $got"
363+
echo " gitcode cannot overwrite a same-named asset; delete the"
364+
echo " release asset and re-publish it with gtc."
345365
fail=1
346366
else
347367
echo "ok: $url"
348368
fi
349369
done < /tmp/cn.tsv
350-
[ $fail -eq 0 ] && echo "All CN mirror urls reachable."
370+
[ $fail -eq 0 ] && echo "All CN mirror urls reachable and matching."
351371
exit $fail
352372
353373
# ── The whole test surface, as a mcpp workspace ───────────────────────

0 commit comments

Comments
 (0)