Skip to content

Commit 4c57363

Browse files
committed
fix(ci): aarch64 self-host gate 克隆的是 main,永远看不到被评审的 PR
「Self-host — build mcpp + xlings from source」这一步固定克隆上游 main。于是 这道关卡从来没有验证过 PR 本身:一个会破坏「从源码自举」的改动能顺利通过它, 只在合入之后才炸。 这次是以最刺眼的方式暴露的 —— 上一个 commit 修的正是本仓库的 bootstrap pin, 而那个修复**无法被验证**:修复在分支上,克隆的却是 main,于是 job 继续报 `version '2026.8.4.1' not found`。 PR 上改为自举**被评审的那份代码**;非 PR 场景没有 head ref,main 本来就是对的。 用 fetch-by-sha 而不是 `clone --depth 1`(后者不接受 sha)。
1 parent 9e8fb50 commit 4c57363

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/ci-aarch64-fresh-install.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,25 @@ jobs:
9999
run: |
100100
# mcpp/xlings manifests pin a glibc default toolchain; on aarch64 the
101101
# musl-static target is the published path, so build with --target.
102-
git clone --depth 1 https://github.com/mcpp-community/mcpp /tmp/mcpp-src
102+
#
103+
# On a pull_request, self-host the code UNDER REVIEW rather than
104+
# upstream main. Cloning main meant this gate never saw the PR at
105+
# all: a change that breaks the from-source build passed here and
106+
# only failed after merge, and — the way this surfaced — a fix to
107+
# the repo's own bootstrap pin was untestable, because the fix was
108+
# on the branch while the clone was of main. Outside a PR there is
109+
# no head ref and main is exactly right.
110+
ref='${{ github.event.pull_request.head.sha }}'
111+
repo='${{ github.event.pull_request.head.repo.clone_url }}'
112+
[ -n "$ref" ] || ref='${{ github.sha }}'
113+
[ -n "$repo" ] || repo='https://github.com/mcpp-community/mcpp'
114+
# fetch-by-sha rather than `clone --depth 1`, which cannot take one.
115+
git init -q /tmp/mcpp-src
103116
cd /tmp/mcpp-src
117+
git remote add origin "$repo"
118+
git fetch -q --depth 1 origin "$ref"
119+
git checkout -q FETCH_HEAD
120+
echo "self-hosting $repo @ $ref"
104121
mcpp self config --mirror GLOBAL 2>/dev/null || true
105122
mcpp build --target aarch64-linux-musl
106123
m=$(find target/aarch64-linux-musl -type f -path '*/bin/mcpp' | head -1)

0 commit comments

Comments
 (0)