Skip to content

[FEATURE] CI 契约测试与 workflow 文本逐字耦合,合法重构与门禁回归无法区分 #279

Closed

Description

@codeasier

功能描述

tests/test_ci_tiers.py 把 .github/workflows/test.yml 当作字符串来断言:step 名称、run: 完整文本、if: 表达式、步骤顺序都要求逐字一致,例如

assert fast["run"] == 'pytest -m "not slow and not nightly"'
assert f"--include='*/{file}' --fail-under={floor}" in guard["run"]

这类断言能防“有人悄悄放宽门禁”,但无法区分“门禁语义变了”和“YAML 文本形态变了”。升级 actions/checkout 版本、引入 pip cache、把两步合并、调整引号或换行——都不改变门禁,却会让测试变红。

使用场景

维护 CI 时(升级 actions、加缓存、拆分或合并 step、调整 if 表达式)需要判断“这次改动有没有动门禁”。当前每次都要人工核对失败原因,误报会逐渐训练出“红了就改测试”的习惯。

期望的实现方式

No response

示例

tests/test_ci_tiers.py:22
    assert fast["run"] == 'pytest -m "not slow and not nightly"'
tests/test_ci_tiers.py:45
    assert f"--include='*/{file}' --fail-under={floor}" in guard["run"]

参考资源

No response

验收标准

No response

Activity

  1. codeasier commented on Nov 1, 2026

    @codeasier
    OwnerAuthor

    Implemented by PR #283: CI contract tests inspect bounded structured workflow semantics rather than exact step labels/text, with positive legal-refactor mutations and negative gate-weakening mutations; previous acceptance/coverage/provenance checks remain protected.

    Merged main: 39f3762e9e54344433dc44e23da69e03c1c64984. Independent review and pre-merge checks passed. Post-merge Test and Platform compatibility are completed successfully, including required Chromium and all macOS/Windows jobs. The event-inapplicable nightly dataset lane is skipped, not claimed as a pass.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions