Prhub

#25320 ci: dispatch pr-test-extra.yml from pr-test.yml on the scheduled cron

原始 PR 作者 alisonshao 合并时间 2026-05-15 16:01 文件变更 5 提交数 16 评论 4 代码增减 +165 / -2

执行摘要

定时调度触发额外测试层,引入 PR awareness 注释

现有每天3次的定时调度仅覆盖基础测试层(pr-test.yml),而extra-tier测试(包括#24725中移到run-ci-extra标签门控下的约50个测试,以及#25203和#25236中添加的B200/H200 8 GPU条件测试)仅通过PR标签或手动workflow_dispatch触发,缺少定时回归兜底。

值得精读该PR的工作流设计,尤其是_pr-awareness-comment.yml中通过HTML注释槽位替换和concurrency group序列化的实践,以及call-pr-test-extra的调度策略。对于维护多层级CI的仓库有参考价值。

讨论亮点

无Review评论;Issue中作者提供了两个Actions运行链接用于验证,合并者使用/tag-and-rerun-ci重新触发CI。未发现实质性设计争论。

实现拆解

  1. 新增_pr-awareness-comment.yml可重用工作流:通过workflow_call接收workflow_kind参数,在PR body中插入/更新两个槽位(pr-test和pr-test-extra),显示对应CI的运行状态。使用actions/github-scriptpulls.get/update API,通过concurrency group序列化并发写操作。
  2. 修改pr-test.yml:添加run_all_tests输入参数;新增call-pr-test-extra作业,仅在schedule事件或test_parallel_dispatch=true时触发,调用pr-test-extra.yml;新增call-pr-awareness作业,在check-changes后立即更新意识块。
  3. 修改pr-test-extra.yml:添加call-pr-awareness作业,确保即使PR没有run-ci-extra标签(作业被跳过)也能更新意识块,让作者看到此次运行是空操作。
  4. 调整健康检查跳过条件:在SKIP_STAGE_HEALTH_CHECK中增加test_parallel_dispatchrun_all_tests条件,避免批量/全量运行时因单个阶段失败而提前终止。
  5. 为Stage Job添加名称:在_pr-test-stage.yml_pr-test-check-changes.yml中添加name字段,使GHA UI中的矩阵任务显示为“extra-a-test-1-gpu-small (0)”而非裸“(0)”,提升可读性。
文件 模块 状态 重要度
.github/workflows/_pr-awareness-comment.yml CI 工作流 added 7.51
.github/workflows/pr-test.yml CI 工作流 modified 5.08
.github/workflows/pr-test-extra.yml CI 工作流 modified 4.5
.github/workflows/_pr-test-check-changes.yml CI 工作流 modified 2.81
.github/workflows/_pr-test-stage.yml CI 工作流 modified 2.81

关键符号

existingBlock extractSlot newPrTest newPrExtra

关键源码片段

.github/workflows/_pr-awareness-comment.yml infrastructure

新增的核心工作流,负责在 PR body 中维护 CI 意识块,实现两个工作流的运行状态展示。

# .github/workflows/_pr-awareness-comment.yml
# 可重用工作流:在 PR body 中维护 CI 意识块
name: PR Awareness Commenton:
  workflow_call:
    inputs:
      workflow_kind:
        description: "Which workflow is calling: 'pr-test' or 'pr-test-extra'"
        required: true
        type: stringpermissions:
  pull-requests: writejobs:
  update-pr-body:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    # 用 concurrency group 防止 pr-test 和 pr-test-extra 同时更新时发生冲突
    concurrency:
      group: pr-awareness-${{ github.event.pull_request.number }}
      cancel-in-progress: false
    steps:
      - name: Update awareness block in PR body
        uses: actions/github-script@v7
        env:
          KIND: ${{ inputs.workflow_kind }}
        with:
          script: |
            const kind = process.env.KIND;
            const { data: pr } = await github.rest.pulls.get({ ... });
            const body = pr.body || '';
            // 提取现有意识块,保留另一个工作流的槽位
            const existingBlock = (body.match(/<!-- pr-awareness:start -->[\\s\\S]*?<!-- pr-awareness:end -->/) || [''])[0];
            const prevPrTest = extractSlot(existingBlock, '<!-- slot:pr-test:start -->', '<!-- slot:pr-test:end -->');
            const prevPrExtra = extractSlot(existingBlock, '<!-- slot:pr-test-extra:start -->', '<!-- slot:pr-test-extra:end -->');
            // 仅更新调用者自己的槽位,另一个保持原样
            // … 具体替换逻辑略

评论区精华

没有提炼出高价值讨论线程

当前评论区没有形成足够清晰的争议点或结论,后续有更多讨论时会体现在这里。

风险与影响

  1. PR body并发写入pr-testpr-test-extra都可能更新同一PR的意识块,虽通过concurrency group序列化,但若两个工作流同时触发(可能性低),后执行者可能覆盖前者的槽位。已通过逐槽位替换而非整体覆盖缓解。
  2. Extra状态未接入required checkcall-pr-test-extra的结果未加入pr-test-finishneeds:,因此定时调度下extra测试失败不会影响父运行状态(PR中仍可见),但不会阻止合入。若需严格门禁需后续跟进。
  3. 条件覆盖不全call-pr-test-extra的触发条件为github.event_name == 'schedule' || inputs.test_parallel_dispatch == true,但未包含workflow_dispatch;通过test_parallel_dispatch可模拟全量运行,但文档中未明确说明。

对用户:无直接功能影响。对系统:定时调度会增加extra测试层的执行频率(每天3次→实际新增约50个测试及B200/H200任务),但CI资源消耗有限。对团队:extra测试获得定时回归覆盖,减少main上引入回归的风险;PR创建者能通过意识块快速了解CI状态,降低沟通成本。影响程度中等,属于CI稳定性提升。

PR body 并发写入风险 Extra 状态未接入 required check 定时调度跳过 stage health check

关联 Issue

未识别关联 Issue

当前没有检测到明确关联的 Issue 链接,后续同步到相关引用后会出现在这里。

完整报告

参与讨论