Prhub

#2761 fix(ci): exempt .claude skill tooling from the test-discovery rule

原始 PR 作者 yueming-yuan 合并时间 2026-08-26 10:39 文件变更 1 提交数 2 评论 0 代码增减 +4 / -1

执行摘要

豁免 .claude 技能测试,修复 CI 全红

main 分支因 #1890 变红:mechanical-refactor-verify 技能更新在其 .claude/skills/.../scripts/tests/ 下新增了内部测试套件,而 test_no_test_file_lives_outside_the_tests_tree 规则会标记这些文件,导致每次 PR 合并时失败。这些套件由技能自身的工作流执行,而非此规则所守护的 CI runner,因此 .claude/ 应与 tests/ 一起加入路径豁免。

该 PR 是必要的 CI 修复,建议合并;其设计决策(将 .claude/ 与 tests/ 同等豁免)值得在类似场景中借鉴。

讨论亮点

无 review 评论,只有 bot 提示和两位 reviewer 的 LGTM 批准。

实现拆解

  1. 修改 tests/ci/test/test_ci_discovery_coverage.py 中的 _test_files_outside_the_tests_tree 函数,将路径前缀判断从 path.startswith("tests/") 改为 path.startswith(("tests/", ".claude/")),以同时豁免 .claude/ 下的测试文件。
  2. 添加注释说明 .claude/ 下技能工具测试由技能自身工作流运行。
文件 模块 状态 重要度
tests/ci/test/test_ci_discovery_coverage.py CI 发现 modified 4.1

关键符号

_test_files_outside_the_tests_tree

关键源码片段

tests/ci/test/test_ci_discovery_coverage.py test-coverage

修改测试发现豁免规则,添加 .claude/ 路径豁免以修复 CI 失败。

def _test_files_outside_the_tests_tree() -> list[str]:
    """Tracked test files this repository carries, asked of git rather than the filesystem.    A directory walk from the checkout root is wrong here: CI clones sglang and
    Megatron-LM *into* the workspace, so the walk would inherit thousands of test
    files belonging to other repositories (and, locally, whatever a venv or a
    worktree happens to hold).
    """
    listing = subprocess.run(
        ["git", "ls-files", "-z", "--", "*test_*.py"],
        cwd=REPO_ROOT,
        capture_output=True,
        text=True,
        check=True,
    ).stdout
    return sorted(
        path
        for path in listing.split("\0")
        if path
        # .claude/ holds agent-skill tooling whose test suites are run by the
        # skill's own workflow, not by the CI runners this rule guards.
        and not path.startswith(("tests/", ".claude/")) and PurePosixPath(path).name.startswith("test_")
    )

评论区精华

豁免 .claude/ 路径的必要性 设计

PR body 解释 .claude/ 下的测试由技能自身工作流运行,不应被 CI 规则标记。

结论:reviewer 批准,无异议。 · 已解决

风险与影响

此变更仅放宽了测试发现规则的豁免范围,不涉及核心逻辑,风险极低。

对用户无直接影响;对 CI 流程有正面影响,修复了因 .claude/ 下测试文件导致的持续失败;对团队而言,规则豁免范围扩大。

规则豁免范围扩大

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论