# PR #2761 完整报告

- 仓库：`radixark/miles`
- 标题：fix(ci): exempt .claude skill tooling from the test-discovery rule
- 合并时间：2026-08-26 10:39
- 原文链接：http://prhub.com.cn/radixark/miles/pull/2761

---

# 执行摘要

- 一句话：豁免 .claude 技能测试，修复 CI 全红
- 推荐动作：该 PR 是必要的 CI 修复，建议合并；其设计决策（将 .claude/ 与 tests/ 同等豁免）值得在类似场景中借鉴。

# 功能与动机

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

# 实现拆解

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 发现；类别 test；类型 test-coverage）: 修改测试发现豁免规则，添加 .claude/ 路径豁免以修复 CI 失败。

关键符号：_test_files_outside_the_tests_tree

## 关键源码片段

### `tests/ci/test/test_ci_discovery_coverage.py`

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

```python
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_")
    )

```

# 评论区精华

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

- 豁免 .claude/ 路径的必要性 (design): reviewer 批准，无异议。

# 风险与影响

- 风险：此变更仅放宽了测试发现规则的豁免范围，不涉及核心逻辑，风险极低。
- 影响：对用户无直接影响；对 CI 流程有正面影响，修复了因 .claude/ 下测试文件导致的持续失败；对团队而言，规则豁免范围扩大。
- 风险标记：规则豁免范围扩大

# 关联脉络

- PR #1890 Update the mechanical-refactor-verify skill to the latest sglang version: 该 PR 引入了 .claude/skills/ 下的测试套件，导致本 PR 修复的 CI 失败。