Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e0e1d61
fix(ci): narrow serve-ab's self-hosted wipe to the A/B checkout dirs
qwen-code-dev-bot Aug 15, 2026
2eeb0ce
test(ci): derive serve-ab wipe pin from the checkout paths (#9228)
qwen-code-dev-bot Aug 15, 2026
aa3ab19
test(ci): pin the serve-ab wipe's full executed script and step order…
qwen-code-dev-bot Aug 15, 2026
e765e1a
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 15, 2026
e7bb585
fix(ci): match serve-ab's wipe step name and pin to its narrowed scop…
qwen-code-dev-bot Aug 15, 2026
900221e
fix(ci): exclude the shared root .git from serve-ab's self-hosted wip…
qwen-code-dev-bot Aug 16, 2026
415d980
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 16, 2026
8074297
fix(ci): keep only a real .git and scrub its exec state in serve-ab w…
qwen-code-dev-bot Aug 16, 2026
664f791
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 16, 2026
781a982
fix(ci): follow a symlinked workspace root in the serve-ab wipe (#9228)
qwen-code-dev-bot Aug 17, 2026
50d038c
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 18, 2026
2a2c6c4
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 18, 2026
a8a4ec6
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 19, 2026
d92db6d
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 20, 2026
a861aeb
Merge remote-tracking branch 'origin/main' into fix/serve-ab-narrow-s…
qwen-code-dev-bot Aug 20, 2026
9658f76
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 21, 2026
0323a69
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 22, 2026
c3357ee
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 23, 2026
4fd6a7a
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 23, 2026
51777f4
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 24, 2026
9b5b134
fix(ci): defang the worktreeConfig bypass and anchor the serve-ab wip…
qwen-code-dev-bot Aug 24, 2026
8306207
Merge branch 'main' into fix/serve-ab-narrow-self-hosted-wipe
qwen-code-dev-bot Aug 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 66 additions & 4 deletions .github/scripts/ci-runner-routing.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,74 @@ describe('serve-ab.yml runner routing', () => {
assert.match(runsOn, /ubuntu-latest/);
});

it('wipes the reused workspace before checking out PR code', () => {
const wipe = serveAbDoc.jobs.ab.steps.find(
it('wipes only the reused A/B checkout dirs before checking out PR code', () => {
const steps = serveAbDoc.jobs.ab.steps;
const wipeIndex = steps.findIndex(
(s) => s.name === 'Wipe stale workspace before checkout',
);
assert.ok(wipe, 'self-hosted reuse must not bleed one PR into the next');
assert.ok(
wipeIndex !== -1,
'self-hosted reuse must not bleed one PR into the next',
);
const wipe = steps[wipeIndex];
assert.equal(wipe.if, "${{ runner.environment == 'self-hosted' }}");
assert.match(wipe.run, /find "\$GITHUB_WORKSPACE" -mindepth 1 -maxdepth 1 -exec rm -rf/);
assert.notEqual(
wipe['continue-on-error'],
true,
'a failed wipe must fail the job, not bleed into the next PR',
);
// The sudo-less wipe only works because ownership-restore ran first,
// and it must precede the checkouts or it deletes the freshly
// checked-out code instead of stale leftovers.
const stepIndex = (name) => steps.findIndex((s) => s.name === name);
assert.ok(
stepIndex('Restore workspace ownership') < wipeIndex,
'the wipe depends on ownership-restore running first',
);
// Derive the wipe targets from the checkout steps so this pin cannot
// drift from the paths the checkouts actually use.
const checkouts = steps.filter((s) =>
String(s.uses || '').startsWith('actions/checkout'),
);
for (const checkout of checkouts) {
assert.ok(
steps.indexOf(checkout) > wipeIndex,
'the wipe must run before every checkout it protects',
);
assert.ok(
checkout.with && checkout.with.path,
'every checkout must declare a with.path the wipe can target',
);
}
const checkoutPaths = checkouts.map((s) => s.with.path);
assert.ok(
checkoutPaths.length >= 2,
'expected at least two checkout paths',
);
// A whole-workspace wipe destroys the shared root .git, forcing the
// next job on this runner to re-fetch the full history from
// github.com — on the ECS pool's slow link that is the "hung runner"
// pathology. Pin the wipe step's entire executed script: no extra
// removal may be added, and nothing may follow the rm — the script
// runs without `set -e`, so a trailing command would mask a failing
// rm.
const executed = wipe.run
.split('\n')
.map((l) => l.trim())
Comment on lines +277 to +278

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined — intentional strictness, not an oversight. This round's rework pins the wipe step's entire executed-line set (see the R2-1 thread), and that pin is deliberately exact: any change to the wipe script — a backslash continuation wrap or a trailing inline comment on the rm line included — must update the pin in the same diff. That friction is the point: an edit to this rm gets a reviewer's eyes on the workflow change and the pin update together. The failure mode is safe: an innocent reformat produces red CI (fixed by re-pinning in the same PR), never a green CI hiding a widened wipe. Adding continuation-joining plus trailing-comment stripping to the guard is shell lexing inside a regression test — complexity for the very scenario the guard exists to catch. Note the strictness is pre-existing: the prior byte-exact pin also failed on a continuation wrap (your witness confirms), so the rework introduces no new friction here.

中文说明

拒绝——这是有意的严格性,并非疏忽。本轮重构将 wipe 步骤的全部执行行集合作为固定对象(见 R2-1 线程),且该固定有意做到精确:wipe 脚本的任何改动——包括续行反斜杠换行或 rm 行尾的行内注释——都必须在同一 diff 中同步更新固定。这种摩擦正是目的所在:对该 rm 的修改会让审阅者同时看到工作流改动与固定更新。失败模式也是安全的:无辜的重排只会导致红色 CI(在同一 PR 中重新固定即可修复),绝不会出现放宽 wipe 却绿灯通过。在守卫中加入续行合并与行尾注释剥离,等于在回归测试里做 shell 词法解析——是为守卫本就要拦截的场景增加复杂度。另外,此严格性并非新增:此前的逐字节固定同样会在续行换行时失败(你的见证也证实了这一点),因此本轮重构没有引入新的摩擦。

.filter((l) => l !== '' && !l.startsWith('#'));
assert.equal(executed.length, 2, 'expected `set -uo pipefail` + one rm');
assert.equal(executed[0], 'set -uo pipefail');
assert.ok(
executed[1].startsWith('rm -rf '),
'the wipe must be a single rm line',
);
const expectedTargets = checkoutPaths
.map((p) => '"${GITHUB_WORKSPACE:?}/' + p + '"')
.sort();
assert.deepEqual(
executed[1].slice('rm -rf '.length).split(' ').sort(),
expectedTargets,
'the rm must target exactly the checkout dirs',
);
});
});
7 changes: 6 additions & 1 deletion .github/workflows/serve-ab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ jobs:
# could bleed into the builds and silently change the posted A/B
# diff. Hosted runners are ephemeral and never see this. After the
# ownership-restore step everything is user-owned, so no sudo.
find "$GITHUB_WORKSPACE" -mindepth 1 -maxdepth 1 -exec rm -rf {} +
# Only these two directories are removed: wiping the whole workspace
# also destroys the shared root .git, forcing the next job on this
# runner to re-fetch the full ~900 MB of history from github.com. On
# the ECS pool's slow link that stalls checkouts for 20+ minutes and
# the fetches drop mid-pack often enough to read as hung runners.
rm -rf "${GITHUB_WORKSPACE:?}/head" "${GITHUB_WORKSPACE:?}/base"

- name: 'Checkout PR head'
uses: 'actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10' # v6.0.3
Expand Down
Loading