Skip to content

ci(midscene): Midscene 改为合入 master 后跑,失败 @ 本轮 PR 作者;测试 Bot 按 CLI 名匹配 - #2527

Merged
deepcoldy merged 6 commits into
masterfrom
ci/midscene-post-merge
Oct 30, 2026
Merged

deepcoldy merged 6 commits into
masterfrom
ci/midscene-post-merge

Conversation

@deepcoldy

@deepcoldy deepcoldy commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

改了什么

  • Midscene E2E 改为合入 master 后跑:去掉 pull_request 触发,改为 push: master + 手动 dispatch。Dashboard Midscene 与 Feishu live 都不再挡 PR。
    • master 运行之间不互相取消(cancel-in-progress: false):正在跑的跑完;排队中 GitHub 只保留最新一个,一次运行可能覆盖多次合入。
    • 每次 master 运行的报告发到 botmux-midscene/master-run-<run id>/,publish-gh-pages.sh 新增 PAGES_KEEP_PREFIX / PAGES_KEEP,只保留最新 5 份(单份 ~150 MB)。
    • 手动 dispatch 的行为不变(report_site_key 默认 manual),合入前想看 live 结果就在分支上 dispatch。
  • 失败通知(新 job notify-failure,仅 push 运行):Dashboard / 飞书席位等待 / Feishu live / 报告任一失败时,scripts/midscene-notify-failure.mjs 找出「上一次跑出结果的 master 运行」到本次之间合入的所有 PR,在每个 PR 下评论 @作者 @仓库 owner,附失败用例表(含 not-run)、报告链接和运行链接;同批多 PR 时注明「失败不一定由本 PR 引起」;没有 PR 的直推提交改为 commit 评论。支持 NOTIFY_DRY_RUN=1 只打印不发。
  • 更新 test/e2e-browser/README.md 的 GitHub Actions 一节。
  • 飞书测试 Bot 改按 CLI 名匹配(为测试租户里的应用去掉 [Botmux] 前缀做准备):botDisplayNames() 同时接受 Claude 与旧名 [Botmux]Claude,大小写精确匹配(租户里另有 codex、Nash_Claude 等无关应用);Messenger 加载判定、私聊入口、@ 成员列表都改用它。
    • @ 校验原来靠文本里的 [Botmux] 区分「已选中的提及」和「刚输入的查询」,去掉前缀后两者文本相同。改为读编辑器里 contenteditable=false 的提及块(MENTION_CHIPS):在真实飞书页面上验证过,输入 @Clau 时为空,选中后为 ["@[Botmux]Claude"]。

为什么

飞书 live 只有一个席位,PR 上的运行排队动辄数小时(曾有已合入 PR 的运行占席位 ~3.5h,#2259),拖慢所有 PR。改成合入后跑,失败直接通知到作者。

影响面

只动 CI 与测试脚本,不动 src/。ci.yml 的必需 check(build / test)不变。合码规范里「PR 上 Feishu live 要归因」的条目需要相应调整为「master 运行失败时看通知归因」。

验证

  • bunx vitest run test/midscene-e2e-workflow.test.ts test/midscene-notify-failure.test.ts test/publish-gh-pages.test.ts test/feishu-live-queue.test.ts test/test-hygiene.test.ts test/midscene-lanes.test.ts → 6 files / 59 tests 通过
    • workflow 用例按真实触发器、并发组和 job 条件逐事件求值:PR 不触发;master 合入不取消在跑的 master 运行;手动运行不进 master 组;任一套件失败都会走到 notify-failure,手动运行失败不评论。
    • 发布用例:master-run-9/10/100 发三次、保留 2 → 留 10 和 100(按数值排序),其它目录不动。
  • bun run build、bun run test:midscene:typecheck 通过;test/midscene-mention-check.test.ts 覆盖新旧名、大小写不同的同名应用、未选中的查询。
  • 对真实仓库 dry-run 通知脚本(伪造 run id、master HEAD、失败 manifest):正确解析到 HEAD 提交对应的 test(codex-app): 空闲重连用例等本轮 final 之后的空闲状态再杀引擎,不再与 runner 空闲结算赛跑 #2523 并生成评论正文,未实际发出。
  • 合入后的第一次 master 运行才能验证 push 触发与 notify job 的真实权限;合入后我会盯这一次。

🤖 Generated with Claude Code


已知限制(评审补充):失败通知为 best-effort

  • 归因区间的锚点是「上一次跑出 success/failure 的 master run」,不是「失败通知已全部发出」。若某次失败 run 的 notify-failure job 在评论发完前就终止(POST 遇 GitHub 二级限流 403/429、5xx 或网络中断),且无人手动 re-run 这个失败 job,则该批中尚未收到评论的 PR 不会被之后的 run 覆盖——后续 run 的区间已前移。

  • 缓解:每条评论带 <!-- midscene-notify run=<run id> --> 幂等标记,手动 re-run 该失败 job 会逐路跳过已发、只补发缺失的 PR,不重复 @;恢复方式即 re-run 红色 notify job。

  • 非阻断小项:去重只查评论列表第一页(per_page=100,默认最旧在前),单会话评论超 100 条时同 run 重跑理论上会重复;当前全仓单 PR 评论最高 43 条、暂不可达,后续以 direction=desc 收口。

  • 首跑观察到的并发覆盖边界:concurrency: push-master + cancel-in-progress: false 下,排队中的 master 运行只保留最新一个,被顶掉的运行是「零 job cancelled」,从不出结果。因此若较早的运行一直处于 in_progress(其「等待飞书 live 席位」排队阶段也算 in_progress),期间落地的提交所对应的更晚 push 运行会被零 job 顶掉、可能永远不被任何 Midscene master 运行直接测试——要等之后某次运行的归因区间回溯覆盖它们;该运行若因席位超时失败,归因区间仍只锚到上一次跑出结果的运行,通知会评论区间内(可能仅较早)的 PR,而真实环境已含更晚未测提交。属 best-effort + 区间锚点的已知后果,非缺陷。

@deepcoldy deepcoldy changed the title ci(midscene): Midscene 改为合入 master 后跑,失败时 @ 本轮 PR 作者附报告 ci(midscene): Midscene 改为合入 master 后跑,失败 @ 本轮 PR 作者;测试 Bot 按 CLI 名匹配 Oct 29, 2026
@deepcoldy

Copy link
Copy Markdown
Owner Author

你好,自动评审(Claude)初步看了一遍,整体逻辑是成立的:合入后触发、master 运行互不取消、按「上次跑出结果的运行→本次」区间归因 PR、报告只留最新 5 份、测试 Bot 兼容新旧名称这些我都核过;还用真实仓库做了 NOTIFY_DRY_RUN(只打印不发送),单 PR 和多 PR 两条路径都正确(区间 4169cdc…0345cc5 正确归因到 #2513 / #2526,互发「失败不一定由本 PR 引起」)。本地 7 个相关测试文件 106 例、test:midscene:typecheck、bun run build 均通过。

有 1 个合入前建议修掉的问题——当前 head 的 CodeQL code-scanning 是红的(1 个 high):

scripts/midscene-notify-failure.mjs:72 的 escapeCell 转义不完整(CodeQL: Incomplete string escaping/encoding)

.replace(/\|/g, '\\|') 只转义了竖线,没有先转义反斜杠。当单元格原文里反斜杠紧贴竖线(例如 a\|b)时,结果会变成 a\\|b:前两个反斜杠构成一个被转义的反斜杠,竖线反而变成未转义,Markdown 表格会在这一列被拆开。输入来自用例名 / 失败信息(仓库内 YAML 与 Midscene 报告),GitHub 评论本身会做净化,所以没有可利用的注入或执行风险,但这是个真实缺陷,并且让当前 head 挂着 high 告警。建议先转义反斜杠、再转义竖线:

const escapeCell = (value) => String(value ?? '')
  .replace(/\\/g, '\\\\')
  .replace(/\|/g, '\\|')
  .replace(/\s+/g, ' ')
  .trim();

并在 test/midscene-notify-failure.test.ts 补一条 a\|b 的回归用例(处理后竖线仍被转义、不会拆列)。

两个非阻断的小建议(可选,顺手就改):

  1. notify-failure 重跑没有去重:手动 re-run 这个 job 会在同一批 PR 下重复发 @ 评论(脚本会顺序发,中途网络失败后重跑会把前面的再发一遍)。可考虑发送前查一条已有的机器人评论、或加个固定标记来幂等。
  2. 通知条件没有包含 deploy-report:当各测试套件都绿、只有报告发布失败时不会发评论通知。如果这是有意为之(没有失败用例就不打扰作者)可以忽略,只是确认一下口径。

这是自动评审的初步意见,最终以维护者审阅为准。

@deepcoldy

Copy link
Copy Markdown
Owner Author

已按建议修复,head 已更新:

  • escapeCell:先转义反斜杠再转义竖线。补了 a\|b 回归用例,断言这一行未转义的竖线仍是 5 个,也就是 4 列不拆。做过变异检查:去掉反斜杠转义后,这条用例会变红。
  • 重跑去重(建议 1):每条评论末尾带隐藏标记 <!-- midscene-notify run=<run id> -->。发评论前先读该 PR(或 commit)已有的评论,同一 run id 已经评论过就跳过,job 重跑或中途失败后重跑都不会重复 @。用例覆盖了「同 run 跳过、不同 run 照发」。对真实仓库 dry-run,标记能正常输出。
  • deploy-report(建议 2):这是有意的。这里只在有测试失败时打扰作者;只是发布失败时,用例结果仍然写在 Summary 和 artifact 里,不需要作者处理。

bunx vitest run test/midscene-notify-failure.test.ts test/midscene-e2e-workflow.test.ts 17/17 通过。

@deepcoldy
deepcoldy merged commit 04083df into master Oct 30, 2026
14 checks passed
deepcoldy pushed a commit that referenced this pull request Oct 30, 2026
#2527/#2562 squash 合入 master 后产生 6 处文本冲突(squash 无祖先关系所致):
workflow/README/helpers/server.ts/midscene-suite.test.ts 取本 PR 侧(严格超集),
midscene-node-reference.md 取 master 生成式版本后重新生成;净 diff 仍为 15 个
PR 文件、src/ 零改动。
@deepcoldy

Copy link
Copy Markdown
Owner Author

合入后首个 master push 运行的归因预告(自动化评审/维护备注,最终以维护者为准)

合入后触发的运行现状(便于看首跑结果时对照):

deepcoldy pushed a commit that referenced this pull request Oct 30, 2026
pi 在 8a6ea4f 复审可合后,master 又进 #2570/#2537/#2558/#2514/#2562/#2527。
与本 PR 同文件仅 worker.ts(#2558 白名单补齐 Gemini/Pi/OpenCode 目录,改 import@326
与 spawnCli@22379+;本 PR 改 import@11 与 provisionIsolatedBotHome@2388,不同函数、
相距 2 万行),merge-tree 零冲突。按 G7 文件交集规则同步以在最新主干跑 CI。
@github-actions

Copy link
Copy Markdown

@deepcoldy 合入 master 后的 Midscene E2E 失败:等待飞书 live 席位超时,飞书用例未运行。

这次运行覆盖 04083df。

用例 跑道 状态 失败信息
Claude basic bot flow feishu-core-claude not-run
Codex basic bot flow feishu-core-codex not-run
Codex prompt submission feishu-core-codex not-run
Follow-up in the same topic keeps context feishu-core-conversation not-run
Thread /status and /close commands feishu-core-conversation not-run
Claude DM chat mode replies inline and keeps one session feishu-core-dm-modes-claude not-run
Claude DM thread mode gives each message its own topic and session feishu-core-dm-modes-claude not-run
Claude DM group mode moves the conversation into a new session group feishu-core-dm-modes-claude not-run
Codex DM chat mode replies inline and keeps one session feishu-core-dm-modes-codex not-run
Codex DM thread mode gives each message its own topic and session feishu-core-dm-modes-codex not-run
Codex DM group mode moves the conversation into a new session group feishu-core-dm-modes-codex not-run
Claude group reply mode chat-topic (default) answers inline, topics get their own session feishu-core-group-modes not-run
Claude group reply mode chat answers inline and folds topics into the group session feishu-core-group-modes not-run
Claude group reply mode topic answers in topics that share one session feishu-core-group-modes not-run
Claude group reply mode new-topic starts a session per topic feishu-core-group-modes not-run
Codex group reply mode chat-topic (default) answers inline, topics get their own session feishu-core-group-modes not-run
Codex group reply mode chat answers inline and folds topics into the group session feishu-core-group-modes not-run
Codex group reply mode topic answers in topics that share one session feishu-core-group-modes not-run
Codex group reply mode new-topic starts a session per topic feishu-core-group-modes not-run
Claude group @ mode always ignores messages without an @ feishu-core-group-modes not-run

另有 8 个用例未列出,见报告。

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

🚀 Released in v3.56.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants