| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[FEAT] [scripts]: 添加 UT 重构框架之 scripts 和 helpers Co-authored-by: AvadaKedavrua<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !253 merge refactor-add-scripts into develop [FEAT] [scripts]: 添加 UT 重构框架之 scripts 和 helpers Created-by: AvadaKedavrua Commit-by: AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 **Please describe the motivation of this PR and the goal you want to achieve through this PR.** **请描述您的拉取请求的动机和您希望通过此拉取请求实现的目标。** ------ ## 📝 Modification / 修改内容 **Please briefly describe what modification is made in this PR.** **请简要描述此拉取请求中进行的修改。** 添加 UT 重构框架之 scripts 和 helpers ------ ## 📐 Associated Test Results / 关联测试结果 **Please provide the related test results, such as test reports, etc.** **请提供相关测试结果,例如测试报告等。** 添加 UT 重构框架之 scripts 和 helpers ------ ## 🌟 Use cases (Optional) / 使用案例(可选) **If this PR introduces a new feature, it is better to list some use cases here and update the documentation.** **如果此拉取请求引入了新功能,最好在此处列出一些用例并更新文档。** ------ ## ✅ Checklist / 检查列表 **Before PR**: - [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [ ] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!253 | 28 天前 | |
【FEAT】【SCRIPTS】update UT refactor design to use YAML policy and JUnit XML reporting Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !265 merge refactor-add-scripts into develop 【FEAT】【SCRIPTS】update UT refactor design to use YAML policy and JUnit XML reporting Created-by: AvadaKedavrua Commit-by: liujiawang Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [ ] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [x] Refactor(代码重构) - [ ] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 **Please describe the motivation of this PR and the goal you want to achieve through this PR.** **请描述您的拉取请求的动机和您希望通过此拉取请求实现的目标。** 本次 PR 对 CI 门禁体系进行了系统性重构:测试结果解析从基于 pytest stdout 文本正则匹配切换为 JUnit XML 解析,同时引入 YAML 策略驱动的门禁配置体系,替代硬编码的源码/测试层映射、豁免列表和审批人管理,并统一了全链路的结构化日志与类型化错误模型。 ------ ## 📝 Modification / 修改内容 **Please briefly describe what modification is made in this PR.** **请简要描述此拉取请求中进行的修改。** 主要改动点 1. YAML 策略驱动的门禁配置 新增 scripts/helpers/ci_gate/gate_policy.py,通过 gate_policy.yaml + approvers.yaml 声明式管理测试发现规则(TestDiscovery,glob 模式)、豁免条目(ExemptionDoc,含 deadline/approver/ticket 等)和审批人注册表 移除 diff.py 中硬编码的 _SOURCE_PREFIX_TO_LAYER 等常量与辅助函数,改为由 YAML 策略驱动 支持 PR diff 感知的增量校验(仅在策略文件变更时触发审批人交叉校验) 2. JUnit XML 替代 stdout 文本解析 pytest_parser.py 废弃 parse_pytest_output(正则匹配 stdout),新增 parse_junit_xml,通过 xml.etree.ElementTree 解析 pytest --junit-xml 输出 支持多 XML 文件聚合合并(_merge_stats)和 pytest node ID 还原(_format_testcase_id) Nightly CI 的 _stream_pytest 不再返回文本输出,各阶段通过 --junit-xml 写入临时 XML 文件 3. 错误模型类型化 GateError(category/path/symbol/detail)替代裸字符串和 Exemption 数据类 Baseline.exemptions 改为 SourceExemption,新增 discovery: TestDiscovery 字段 新增 errors.py 的 format_blocking_errors(),按 new_source/modified_source/deleted_source/deleted_test 分类分组展示 4. 结构化日志体系 新增 scripts/helpers/common/_logging.py(setup_logger、log_env_audit) main.py、coverage_gate.py、feishu_notifier.py、build_test_map.py、report_builder.py 等所有 print(…, file=sys.stderr) 统一替换为 logging 5. 测试映射流程增强 新增 collect_test_map(内存模式,不写文件)、_remap_renamed_sources(重命名迁移映射)、_merge_test_maps(新旧合并)、_run_new_tests_and_build_map(新增测试先采集) 冗余检测算法优化:引入 symbol_to_tests 反向索引 + compared_pairs 去重,仅对共享符号的测试对计算 Jaccard 删除源/测试的边界处理改善(排除同时删除的测试、跳过已删除源、测试路径规范化) 6. 配置层重构 Config 提供内置默认值(line_threshold=60.0 等),_parse_float/_parse_bool/_parse_str 支持 default 参数 新增 msmodeling_cache、_validate_threshold [0,100] 范围校验;test_map_path 改为可选 CI Shell 脚本默认值调整:MSMODELING_TEST_WEIGHTS_PRUNE 默认改为 0,覆盖率阈值下调至 60/40 7. 文件重命名追踪 ChangeSet 新增 renames 字段,git diff 增加 -M 选项和 R 状态解析,纯重命名(score=100)无需新测试 8. 飞书通知增强 build_feishu_payload 支持 expired_exemption_section 过期豁免提示 新增 _parse_feishu_response 解析 webhook JSON 响应 ------ ## 📐 Associated Test Results / 关联测试结果 **Please provide the related test results, such as test reports, etc.** **请提供相关测试结果,例如测试报告等。** ------ ## 🌟 Use cases (Optional) / 使用案例(可选) **If this PR introduces a new feature, it is better to list some use cases here and update the documentation.** **如果此拉取请求引入了新功能,最好在此处列出一些用例并更新文档。** ------ ## ✅ Checklist / 检查列表 **Before PR**: - [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!265 | 26 天前 | |
[FEAT] [scripts]: 添加 UT 重构框架之 scripts 和 helpers Co-authored-by: AvadaKedavrua<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !253 merge refactor-add-scripts into develop [FEAT] [scripts]: 添加 UT 重构框架之 scripts 和 helpers Created-by: AvadaKedavrua Commit-by: AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [ ] Bugfix(Bug 修复) - [ ] Docs(文档更新) - [ ] CI/CD(持续集成/持续部署) - [ ] Refactor(代码重构) - [ ] Perf(性能优化) - [ ] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 **Please describe the motivation of this PR and the goal you want to achieve through this PR.** **请描述您的拉取请求的动机和您希望通过此拉取请求实现的目标。** ------ ## 📝 Modification / 修改内容 **Please briefly describe what modification is made in this PR.** **请简要描述此拉取请求中进行的修改。** 添加 UT 重构框架之 scripts 和 helpers ------ ## 📐 Associated Test Results / 关联测试结果 **Please provide the related test results, such as test reports, etc.** **请提供相关测试结果,例如测试报告等。** 添加 UT 重构框架之 scripts 和 helpers ------ ## 🌟 Use cases (Optional) / 使用案例(可选) **If this PR introduces a new feature, it is better to list some use cases here and update the documentation.** **如果此拉取请求引入了新功能,最好在此处列出一些用例并更新文档。** ------ ## ✅ Checklist / 检查列表 **Before PR**: - [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [ ] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [ ] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!253 | 28 天前 | |
【REFACTOR】CI Gate 联合执行与 Nightly 流水线加固 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !342 merge fix into develop 【REFACTOR】CI Gate 联合执行与 Nightly 流水线加固 Created-by: AvadaKedavrua Commit-by: liujiawang Merged-by: ascend-robot Description: ## 修改原因 CI Gate / Nightly helpers 在 union 重构后存在多处逻辑与体验问题: - 全豁免测试仍跑 Phase 2(#112) - Nightly audit 使用过期 test_map(#113) - coverage fallback 在 union 重构后断裂(#119) - PRODUCT_SOURCE_PREFIXES 与 gate_policy.yaml 双源 roots - 重复 collect/git diff、日志含内部术语、nightly 缺终端摘要 本 PR 统一执行模型并补齐回归测试与文档。 --- ## 修改内容 **CI Gate (scripts/helpers/ci_gate/)** - 预跑硬阻断仅保留删除测试/删除源码;覆盖率映射改为跑后软策略 - compute_execution_plan 联合去重 pytest waves;产品/测试变更时附加 --cov - fetch_diff() 单次 git diff;load_gate_policy 按 yaml mtime 缓存 - roots 单一来源:tests/.ci/gate_policy.yaml - 用户向英文日志与成功摘要 print **Nightly (scripts/helpers/nightly/)** - 过期/冗余审计使用新鲜 test_map(#113) - 终端摘要、英文 phase 标签;移除 drift TODO - allowed_node_ids 复用、弱覆盖符号检测传 mapping **Common / Policy** - coverage_config.py 懒加载 product_roots() - gate_policy.yaml:tests/helpers/** exclude - 文档同步:tests/README.md、docs/design/ut_refactor.md、tests/SKILL.md 关联 issue:#112 #113 #114 #115 #116 #117 #119 #120 #121 #122 #123 #124 --- ## 优化特性对比(Before / After) ### 特性 1:联合去重 pytest 执行(核心优化) **场景**:同一 PR 同时改了产品代码 tensor_cast/foo.py 和测试文件 tests/regression/cli/test_shared.py,且 test_shared.py::test_x 恰好也是 foo.py 在 test_map 里的回归用例。 #### Before(分阶段、可能重复跑) text # 1) 预跑:新源码无 test_map 映射 → 直接硬阻断,pytest 还没跑 BLOCK: tensor_cast/foo.py has no test_map entry for symbol Foo.bar # 2) Phase 0:单独跑一轮带 --cov 的 pytest 做 coverage fallback pytest tests/regression/cli/test_shared.py -m not npu --cov ... # 3) Phase 1:跑变更测试 pytest tests/regression/cli/test_shared.py::test_x -m not npu # 4) Phase 2:再跑映射回归(与 Phase 1 重叠) pytest tests/regression/cli/test_shared.py::test_x \ tests/regression/cli/test_other.py::test_y \ -m "not npu and not nightly and not network" → test_shared.py::test_x 被执行 2~3 次;git diff 可能重复 fetch;coverage 与映射校验割裂 #### After(先跑、后验、去重) text # 1) 预跑硬阻断:仅删测试 / 删源码 Validating hard-blocking policy ... (no block — foo.py 是修改不是删除) # 2) 计划:联合调度,node id 去重(changed-test 优先) Scheduling 2 test node(s): new or changed test file Scheduling 1 test node(s): changed product file mapped regression Sample node(s): tests/regression/cli/test_shared.py::test_x, ... Execution uses 2 pytest wave(s) after deduplication # 3) 单次 union pytest(附带 --cov --cov-context=test) Wave 1 (-m not npu): tests/regression/cli/test_shared.py::test_x # changed-test,只跑一次 Wave 2 (-m not npu and not nightly and not network): tests/regression/cli/test_other.py::test_y # 纯回归,test_x 不再重复 # 4) 跑后软策略:用同一次 .coverage 做 mapping fallback Checking new/modified source coverage mapping against collected data ... CI gate passed: 2 test node(s) (new or changed test file; changed product file mapped regression) → 同一 node 只执行 1 次;coverage fallback 与 pytest 同轮完成;CI 耗时更短、行为更可预期 ### 特性 2:配置变更触发全量,跳过无效 collect **场景**:PR 只改了 pyproject.toml(依赖/测试配置变更)。 #### Before text config change detected → full suite still collect changed test files in Phase 1 ... # 多余 collect pytest tests/ -m not npu #### After text Config path(s): pyproject.toml Selected full test suite: dependency or test configuration changed pytest tests/ -m not npu # changed_test_nodes 为空,跳过 gate_new_tests collect CI gate passed: full test suite (pyproject.toml) ### 特性 3:Nightly 终端摘要(用户可读) #### Before text Phase 2a done. elapsed=1832.4s # 流水线结束,无一行总览;内部 phase 编号 #### After text Nightly pipeline finished. test_map: written (line 74.1%, branch 61.8%) nightly-marked: 142 passed in 1832s benchmark: 38 passed in 412s network: 12 passed in 89s weak coverage symbols: 3 report: /path/to/nightly_report.json --- ## 自验证 ### Helpers 回归测试 目的:确认 CI Gate / Nightly / Common helpers 全量回归通过 步骤: 1. 进入仓库根目录 2. 执行: bash uv run python -m pytest tests/regression/scripts/helpers/ -q 结果: 341 passed, 5 warnings in 1.02s ### gate_policy 缓存失效 目的:确认 yaml mtime 变化后 load_gate_policy 缓存失效 步骤: 1. 运行单测: bash uv run python -m pytest tests/regression/scripts/helpers/ci_gate/test_gate_policy.py::test_load_gate_policy_cached_until_yaml_mtime_changes -v 结果:PASSED(修复同秒写入 mtime 未变导致的 flaky) ### pre-commit 目的:提交前 hook 全绿 步骤: 1. git commit 触发 pre-commit(ruff、pylint、bandit、typos 等) 结果:全部 Passed See merge request: Ascend/msmodeling!342 | 13 天前 | |
【REFACTOR】CI Gate 联合执行与 Nightly 流水线加固 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !342 merge fix into develop 【REFACTOR】CI Gate 联合执行与 Nightly 流水线加固 Created-by: AvadaKedavrua Commit-by: liujiawang Merged-by: ascend-robot Description: ## 修改原因 CI Gate / Nightly helpers 在 union 重构后存在多处逻辑与体验问题: - 全豁免测试仍跑 Phase 2(#112) - Nightly audit 使用过期 test_map(#113) - coverage fallback 在 union 重构后断裂(#119) - PRODUCT_SOURCE_PREFIXES 与 gate_policy.yaml 双源 roots - 重复 collect/git diff、日志含内部术语、nightly 缺终端摘要 本 PR 统一执行模型并补齐回归测试与文档。 --- ## 修改内容 **CI Gate (scripts/helpers/ci_gate/)** - 预跑硬阻断仅保留删除测试/删除源码;覆盖率映射改为跑后软策略 - compute_execution_plan 联合去重 pytest waves;产品/测试变更时附加 --cov - fetch_diff() 单次 git diff;load_gate_policy 按 yaml mtime 缓存 - roots 单一来源:tests/.ci/gate_policy.yaml - 用户向英文日志与成功摘要 print **Nightly (scripts/helpers/nightly/)** - 过期/冗余审计使用新鲜 test_map(#113) - 终端摘要、英文 phase 标签;移除 drift TODO - allowed_node_ids 复用、弱覆盖符号检测传 mapping **Common / Policy** - coverage_config.py 懒加载 product_roots() - gate_policy.yaml:tests/helpers/** exclude - 文档同步:tests/README.md、docs/design/ut_refactor.md、tests/SKILL.md 关联 issue:#112 #113 #114 #115 #116 #117 #119 #120 #121 #122 #123 #124 --- ## 优化特性对比(Before / After) ### 特性 1:联合去重 pytest 执行(核心优化) **场景**:同一 PR 同时改了产品代码 tensor_cast/foo.py 和测试文件 tests/regression/cli/test_shared.py,且 test_shared.py::test_x 恰好也是 foo.py 在 test_map 里的回归用例。 #### Before(分阶段、可能重复跑) text # 1) 预跑:新源码无 test_map 映射 → 直接硬阻断,pytest 还没跑 BLOCK: tensor_cast/foo.py has no test_map entry for symbol Foo.bar # 2) Phase 0:单独跑一轮带 --cov 的 pytest 做 coverage fallback pytest tests/regression/cli/test_shared.py -m not npu --cov ... # 3) Phase 1:跑变更测试 pytest tests/regression/cli/test_shared.py::test_x -m not npu # 4) Phase 2:再跑映射回归(与 Phase 1 重叠) pytest tests/regression/cli/test_shared.py::test_x \ tests/regression/cli/test_other.py::test_y \ -m "not npu and not nightly and not network" → test_shared.py::test_x 被执行 2~3 次;git diff 可能重复 fetch;coverage 与映射校验割裂 #### After(先跑、后验、去重) text # 1) 预跑硬阻断:仅删测试 / 删源码 Validating hard-blocking policy ... (no block — foo.py 是修改不是删除) # 2) 计划:联合调度,node id 去重(changed-test 优先) Scheduling 2 test node(s): new or changed test file Scheduling 1 test node(s): changed product file mapped regression Sample node(s): tests/regression/cli/test_shared.py::test_x, ... Execution uses 2 pytest wave(s) after deduplication # 3) 单次 union pytest(附带 --cov --cov-context=test) Wave 1 (-m not npu): tests/regression/cli/test_shared.py::test_x # changed-test,只跑一次 Wave 2 (-m not npu and not nightly and not network): tests/regression/cli/test_other.py::test_y # 纯回归,test_x 不再重复 # 4) 跑后软策略:用同一次 .coverage 做 mapping fallback Checking new/modified source coverage mapping against collected data ... CI gate passed: 2 test node(s) (new or changed test file; changed product file mapped regression) → 同一 node 只执行 1 次;coverage fallback 与 pytest 同轮完成;CI 耗时更短、行为更可预期 ### 特性 2:配置变更触发全量,跳过无效 collect **场景**:PR 只改了 pyproject.toml(依赖/测试配置变更)。 #### Before text config change detected → full suite still collect changed test files in Phase 1 ... # 多余 collect pytest tests/ -m not npu #### After text Config path(s): pyproject.toml Selected full test suite: dependency or test configuration changed pytest tests/ -m not npu # changed_test_nodes 为空,跳过 gate_new_tests collect CI gate passed: full test suite (pyproject.toml) ### 特性 3:Nightly 终端摘要(用户可读) #### Before text Phase 2a done. elapsed=1832.4s # 流水线结束,无一行总览;内部 phase 编号 #### After text Nightly pipeline finished. test_map: written (line 74.1%, branch 61.8%) nightly-marked: 142 passed in 1832s benchmark: 38 passed in 412s network: 12 passed in 89s weak coverage symbols: 3 report: /path/to/nightly_report.json --- ## 自验证 ### Helpers 回归测试 目的:确认 CI Gate / Nightly / Common helpers 全量回归通过 步骤: 1. 进入仓库根目录 2. 执行: bash uv run python -m pytest tests/regression/scripts/helpers/ -q 结果: 341 passed, 5 warnings in 1.02s ### gate_policy 缓存失效 目的:确认 yaml mtime 变化后 load_gate_policy 缓存失效 步骤: 1. 运行单测: bash uv run python -m pytest tests/regression/scripts/helpers/ci_gate/test_gate_policy.py::test_load_gate_policy_cached_until_yaml_mtime_changes -v 结果:PASSED(修复同秒写入 mtime 未变导致的 flaky) ### pre-commit 目的:提交前 hook 全绿 步骤: 1. git commit 触发 pre-commit(ruff、pylint、bandit、typos 等) 结果:全部 Passed See merge request: Ascend/msmodeling!342 | 13 天前 | |
【FIX】CI Gate 增量门禁加固:test_map 漏检修复、pytest 策略与 node 级豁免 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !334 merge fix into develop 【FIX】CI Gate 增量门禁加固:test_map 漏检修复、pytest 策略与 node 级豁免 Created-by: AvadaKedavrua Commit-by: liujiawang Merged-by: ascend-robot Description: ## 背景 修复 CI 增量门禁多处漏检/误拦(含 #107):Phase 0 test_map 合并覆盖同 symbol、未映射 symbol 误拦、pytest 继承 addopts 行为不可控、exemptions.tests 整文件误豁免等。 Closes #107 --- ## 改动摘要 ### 策略与 coverage - **_merge_test_maps**:同 symbol test id **union**,不再 replace(修复 test_main_extra 等用例被跳过) - **coverage 兜底**:symbol 双 map 均无 → 查 Phase 0 .coverage(含 import 空 context)→ 放行 - **omit SSOT**:读 pyproject.toml [tool.coverage.run].omit;gate_policy.yaml 新增 roots,exemptions.tests 接入 Phase 0/2 ### Pytest 执行(pytest_runner.py) - 门禁 subprocess 统一 **-o addopts=** + **显式 -m** - **collect-first** → min(cpu, collected) + --dist worksteal - Phase 0: not npu;Phase 1/2 增量: not npu and not nightly and not network;config 全量: tests/ + not npu - 全量触发:conftest.py、requirements.txt、uv.lock 等;**不含** gate_policy.yaml ### exemptions.tests(node 级) - 登记必须为 pytest node(tests/...py::func 或 ...::Class::method),禁止 [、禁止 class-only、禁止整文件 pathspec 回退 - **Phase 0**:按改动文件 collect node → 过滤豁免 → 显式 node 列表跑 pytest+cov;全豁免打 log 跳过(避免 exit 5) - **Phase 2**:incremental_tests 过滤豁免 node - Phase 0 失败输出可复制 exemptions.tests YAML 模板 ### 可观测性 - Phase 0/1/2 及策略拦截日志:说明各阶段目的、失败含义、跳过原因 - run_*.sh:-vv;nested subprocess+cov+xdist 回归测试改 stub --- ## 自验证 bash uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_pytest_runner.py -q 141 passed See merge request: Ascend/msmodeling!334 | 14 天前 | |
【FIX】CI Gate 增量门禁加固:test_map 漏检修复、pytest 策略与 node 级豁免 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !334 merge fix into develop 【FIX】CI Gate 增量门禁加固:test_map 漏检修复、pytest 策略与 node 级豁免 Created-by: AvadaKedavrua Commit-by: liujiawang Merged-by: ascend-robot Description: ## 背景 修复 CI 增量门禁多处漏检/误拦(含 #107):Phase 0 test_map 合并覆盖同 symbol、未映射 symbol 误拦、pytest 继承 addopts 行为不可控、exemptions.tests 整文件误豁免等。 Closes #107 --- ## 改动摘要 ### 策略与 coverage - **_merge_test_maps**:同 symbol test id **union**,不再 replace(修复 test_main_extra 等用例被跳过) - **coverage 兜底**:symbol 双 map 均无 → 查 Phase 0 .coverage(含 import 空 context)→ 放行 - **omit SSOT**:读 pyproject.toml [tool.coverage.run].omit;gate_policy.yaml 新增 roots,exemptions.tests 接入 Phase 0/2 ### Pytest 执行(pytest_runner.py) - 门禁 subprocess 统一 **-o addopts=** + **显式 -m** - **collect-first** → min(cpu, collected) + --dist worksteal - Phase 0: not npu;Phase 1/2 增量: not npu and not nightly and not network;config 全量: tests/ + not npu - 全量触发:conftest.py、requirements.txt、uv.lock 等;**不含** gate_policy.yaml ### exemptions.tests(node 级) - 登记必须为 pytest node(tests/...py::func 或 ...::Class::method),禁止 [、禁止 class-only、禁止整文件 pathspec 回退 - **Phase 0**:按改动文件 collect node → 过滤豁免 → 显式 node 列表跑 pytest+cov;全豁免打 log 跳过(避免 exit 5) - **Phase 2**:incremental_tests 过滤豁免 node - Phase 0 失败输出可复制 exemptions.tests YAML 模板 ### 可观测性 - Phase 0/1/2 及策略拦截日志:说明各阶段目的、失败含义、跳过原因 - run_*.sh:-vv;nested subprocess+cov+xdist 回归测试改 stub --- ## 自验证 bash uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_pytest_runner.py -q 141 passed See merge request: Ascend/msmodeling!334 | 14 天前 | |
【REFACTOR】CI Gate 联合执行与 Nightly 流水线加固 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !342 merge fix into develop 【REFACTOR】CI Gate 联合执行与 Nightly 流水线加固 Created-by: AvadaKedavrua Commit-by: liujiawang Merged-by: ascend-robot Description: ## 修改原因 CI Gate / Nightly helpers 在 union 重构后存在多处逻辑与体验问题: - 全豁免测试仍跑 Phase 2(#112) - Nightly audit 使用过期 test_map(#113) - coverage fallback 在 union 重构后断裂(#119) - PRODUCT_SOURCE_PREFIXES 与 gate_policy.yaml 双源 roots - 重复 collect/git diff、日志含内部术语、nightly 缺终端摘要 本 PR 统一执行模型并补齐回归测试与文档。 --- ## 修改内容 **CI Gate (scripts/helpers/ci_gate/)** - 预跑硬阻断仅保留删除测试/删除源码;覆盖率映射改为跑后软策略 - compute_execution_plan 联合去重 pytest waves;产品/测试变更时附加 --cov - fetch_diff() 单次 git diff;load_gate_policy 按 yaml mtime 缓存 - roots 单一来源:tests/.ci/gate_policy.yaml - 用户向英文日志与成功摘要 print **Nightly (scripts/helpers/nightly/)** - 过期/冗余审计使用新鲜 test_map(#113) - 终端摘要、英文 phase 标签;移除 drift TODO - allowed_node_ids 复用、弱覆盖符号检测传 mapping **Common / Policy** - coverage_config.py 懒加载 product_roots() - gate_policy.yaml:tests/helpers/** exclude - 文档同步:tests/README.md、docs/design/ut_refactor.md、tests/SKILL.md 关联 issue:#112 #113 #114 #115 #116 #117 #119 #120 #121 #122 #123 #124 --- ## 优化特性对比(Before / After) ### 特性 1:联合去重 pytest 执行(核心优化) **场景**:同一 PR 同时改了产品代码 tensor_cast/foo.py 和测试文件 tests/regression/cli/test_shared.py,且 test_shared.py::test_x 恰好也是 foo.py 在 test_map 里的回归用例。 #### Before(分阶段、可能重复跑) text # 1) 预跑:新源码无 test_map 映射 → 直接硬阻断,pytest 还没跑 BLOCK: tensor_cast/foo.py has no test_map entry for symbol Foo.bar # 2) Phase 0:单独跑一轮带 --cov 的 pytest 做 coverage fallback pytest tests/regression/cli/test_shared.py -m not npu --cov ... # 3) Phase 1:跑变更测试 pytest tests/regression/cli/test_shared.py::test_x -m not npu # 4) Phase 2:再跑映射回归(与 Phase 1 重叠) pytest tests/regression/cli/test_shared.py::test_x \ tests/regression/cli/test_other.py::test_y \ -m "not npu and not nightly and not network" → test_shared.py::test_x 被执行 2~3 次;git diff 可能重复 fetch;coverage 与映射校验割裂 #### After(先跑、后验、去重) text # 1) 预跑硬阻断:仅删测试 / 删源码 Validating hard-blocking policy ... (no block — foo.py 是修改不是删除) # 2) 计划:联合调度,node id 去重(changed-test 优先) Scheduling 2 test node(s): new or changed test file Scheduling 1 test node(s): changed product file mapped regression Sample node(s): tests/regression/cli/test_shared.py::test_x, ... Execution uses 2 pytest wave(s) after deduplication # 3) 单次 union pytest(附带 --cov --cov-context=test) Wave 1 (-m not npu): tests/regression/cli/test_shared.py::test_x # changed-test,只跑一次 Wave 2 (-m not npu and not nightly and not network): tests/regression/cli/test_other.py::test_y # 纯回归,test_x 不再重复 # 4) 跑后软策略:用同一次 .coverage 做 mapping fallback Checking new/modified source coverage mapping against collected data ... CI gate passed: 2 test node(s) (new or changed test file; changed product file mapped regression) → 同一 node 只执行 1 次;coverage fallback 与 pytest 同轮完成;CI 耗时更短、行为更可预期 ### 特性 2:配置变更触发全量,跳过无效 collect **场景**:PR 只改了 pyproject.toml(依赖/测试配置变更)。 #### Before text config change detected → full suite still collect changed test files in Phase 1 ... # 多余 collect pytest tests/ -m not npu #### After text Config path(s): pyproject.toml Selected full test suite: dependency or test configuration changed pytest tests/ -m not npu # changed_test_nodes 为空,跳过 gate_new_tests collect CI gate passed: full test suite (pyproject.toml) ### 特性 3:Nightly 终端摘要(用户可读) #### Before text Phase 2a done. elapsed=1832.4s # 流水线结束,无一行总览;内部 phase 编号 #### After text Nightly pipeline finished. test_map: written (line 74.1%, branch 61.8%) nightly-marked: 142 passed in 1832s benchmark: 38 passed in 412s network: 12 passed in 89s weak coverage symbols: 3 report: /path/to/nightly_report.json --- ## 自验证 ### Helpers 回归测试 目的:确认 CI Gate / Nightly / Common helpers 全量回归通过 步骤: 1. 进入仓库根目录 2. 执行: bash uv run python -m pytest tests/regression/scripts/helpers/ -q 结果: 341 passed, 5 warnings in 1.02s ### gate_policy 缓存失效 目的:确认 yaml mtime 变化后 load_gate_policy 缓存失效 步骤: 1. 运行单测: bash uv run python -m pytest tests/regression/scripts/helpers/ci_gate/test_gate_policy.py::test_load_gate_policy_cached_until_yaml_mtime_changes -v 结果:PASSED(修复同秒写入 mtime 未变导致的 flaky) ### pre-commit 目的:提交前 hook 全绿 步骤: 1. git commit 触发 pre-commit(ruff、pylint、bandit、typos 等) 结果:全部 Passed See merge request: Ascend/msmodeling!342 | 13 天前 | |
【REFACTOR】CI Gate 联合执行与 Nightly 流水线加固 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !342 merge fix into develop 【REFACTOR】CI Gate 联合执行与 Nightly 流水线加固 Created-by: AvadaKedavrua Commit-by: liujiawang Merged-by: ascend-robot Description: ## 修改原因 CI Gate / Nightly helpers 在 union 重构后存在多处逻辑与体验问题: - 全豁免测试仍跑 Phase 2(#112) - Nightly audit 使用过期 test_map(#113) - coverage fallback 在 union 重构后断裂(#119) - PRODUCT_SOURCE_PREFIXES 与 gate_policy.yaml 双源 roots - 重复 collect/git diff、日志含内部术语、nightly 缺终端摘要 本 PR 统一执行模型并补齐回归测试与文档。 --- ## 修改内容 **CI Gate (scripts/helpers/ci_gate/)** - 预跑硬阻断仅保留删除测试/删除源码;覆盖率映射改为跑后软策略 - compute_execution_plan 联合去重 pytest waves;产品/测试变更时附加 --cov - fetch_diff() 单次 git diff;load_gate_policy 按 yaml mtime 缓存 - roots 单一来源:tests/.ci/gate_policy.yaml - 用户向英文日志与成功摘要 print **Nightly (scripts/helpers/nightly/)** - 过期/冗余审计使用新鲜 test_map(#113) - 终端摘要、英文 phase 标签;移除 drift TODO - allowed_node_ids 复用、弱覆盖符号检测传 mapping **Common / Policy** - coverage_config.py 懒加载 product_roots() - gate_policy.yaml:tests/helpers/** exclude - 文档同步:tests/README.md、docs/design/ut_refactor.md、tests/SKILL.md 关联 issue:#112 #113 #114 #115 #116 #117 #119 #120 #121 #122 #123 #124 --- ## 优化特性对比(Before / After) ### 特性 1:联合去重 pytest 执行(核心优化) **场景**:同一 PR 同时改了产品代码 tensor_cast/foo.py 和测试文件 tests/regression/cli/test_shared.py,且 test_shared.py::test_x 恰好也是 foo.py 在 test_map 里的回归用例。 #### Before(分阶段、可能重复跑) text # 1) 预跑:新源码无 test_map 映射 → 直接硬阻断,pytest 还没跑 BLOCK: tensor_cast/foo.py has no test_map entry for symbol Foo.bar # 2) Phase 0:单独跑一轮带 --cov 的 pytest 做 coverage fallback pytest tests/regression/cli/test_shared.py -m not npu --cov ... # 3) Phase 1:跑变更测试 pytest tests/regression/cli/test_shared.py::test_x -m not npu # 4) Phase 2:再跑映射回归(与 Phase 1 重叠) pytest tests/regression/cli/test_shared.py::test_x \ tests/regression/cli/test_other.py::test_y \ -m "not npu and not nightly and not network" → test_shared.py::test_x 被执行 2~3 次;git diff 可能重复 fetch;coverage 与映射校验割裂 #### After(先跑、后验、去重) text # 1) 预跑硬阻断:仅删测试 / 删源码 Validating hard-blocking policy ... (no block — foo.py 是修改不是删除) # 2) 计划:联合调度,node id 去重(changed-test 优先) Scheduling 2 test node(s): new or changed test file Scheduling 1 test node(s): changed product file mapped regression Sample node(s): tests/regression/cli/test_shared.py::test_x, ... Execution uses 2 pytest wave(s) after deduplication # 3) 单次 union pytest(附带 --cov --cov-context=test) Wave 1 (-m not npu): tests/regression/cli/test_shared.py::test_x # changed-test,只跑一次 Wave 2 (-m not npu and not nightly and not network): tests/regression/cli/test_other.py::test_y # 纯回归,test_x 不再重复 # 4) 跑后软策略:用同一次 .coverage 做 mapping fallback Checking new/modified source coverage mapping against collected data ... CI gate passed: 2 test node(s) (new or changed test file; changed product file mapped regression) → 同一 node 只执行 1 次;coverage fallback 与 pytest 同轮完成;CI 耗时更短、行为更可预期 ### 特性 2:配置变更触发全量,跳过无效 collect **场景**:PR 只改了 pyproject.toml(依赖/测试配置变更)。 #### Before text config change detected → full suite still collect changed test files in Phase 1 ... # 多余 collect pytest tests/ -m not npu #### After text Config path(s): pyproject.toml Selected full test suite: dependency or test configuration changed pytest tests/ -m not npu # changed_test_nodes 为空,跳过 gate_new_tests collect CI gate passed: full test suite (pyproject.toml) ### 特性 3:Nightly 终端摘要(用户可读) #### Before text Phase 2a done. elapsed=1832.4s # 流水线结束,无一行总览;内部 phase 编号 #### After text Nightly pipeline finished. test_map: written (line 74.1%, branch 61.8%) nightly-marked: 142 passed in 1832s benchmark: 38 passed in 412s network: 12 passed in 89s weak coverage symbols: 3 report: /path/to/nightly_report.json --- ## 自验证 ### Helpers 回归测试 目的:确认 CI Gate / Nightly / Common helpers 全量回归通过 步骤: 1. 进入仓库根目录 2. 执行: bash uv run python -m pytest tests/regression/scripts/helpers/ -q 结果: 341 passed, 5 warnings in 1.02s ### gate_policy 缓存失效 目的:确认 yaml mtime 变化后 load_gate_policy 缓存失效 步骤: 1. 运行单测: bash uv run python -m pytest tests/regression/scripts/helpers/ci_gate/test_gate_policy.py::test_load_gate_policy_cached_until_yaml_mtime_changes -v 结果:PASSED(修复同秒写入 mtime 未变导致的 flaky) ### pre-commit 目的:提交前 hook 全绿 步骤: 1. git commit 触发 pre-commit(ruff、pylint、bandit、typos 等) 结果:全部 Passed See merge request: Ascend/msmodeling!342 | 13 天前 | |
【FIX】CI Gate 增量门禁加固:test_map 漏检修复、pytest 策略与 node 级豁免 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !334 merge fix into develop 【FIX】CI Gate 增量门禁加固:test_map 漏检修复、pytest 策略与 node 级豁免 Created-by: AvadaKedavrua Commit-by: liujiawang Merged-by: ascend-robot Description: ## 背景 修复 CI 增量门禁多处漏检/误拦(含 #107):Phase 0 test_map 合并覆盖同 symbol、未映射 symbol 误拦、pytest 继承 addopts 行为不可控、exemptions.tests 整文件误豁免等。 Closes #107 --- ## 改动摘要 ### 策略与 coverage - **_merge_test_maps**:同 symbol test id **union**,不再 replace(修复 test_main_extra 等用例被跳过) - **coverage 兜底**:symbol 双 map 均无 → 查 Phase 0 .coverage(含 import 空 context)→ 放行 - **omit SSOT**:读 pyproject.toml [tool.coverage.run].omit;gate_policy.yaml 新增 roots,exemptions.tests 接入 Phase 0/2 ### Pytest 执行(pytest_runner.py) - 门禁 subprocess 统一 **-o addopts=** + **显式 -m** - **collect-first** → min(cpu, collected) + --dist worksteal - Phase 0: not npu;Phase 1/2 增量: not npu and not nightly and not network;config 全量: tests/ + not npu - 全量触发:conftest.py、requirements.txt、uv.lock 等;**不含** gate_policy.yaml ### exemptions.tests(node 级) - 登记必须为 pytest node(tests/...py::func 或 ...::Class::method),禁止 [、禁止 class-only、禁止整文件 pathspec 回退 - **Phase 0**:按改动文件 collect node → 过滤豁免 → 显式 node 列表跑 pytest+cov;全豁免打 log 跳过(避免 exit 5) - **Phase 2**:incremental_tests 过滤豁免 node - Phase 0 失败输出可复制 exemptions.tests YAML 模板 ### 可观测性 - Phase 0/1/2 及策略拦截日志:说明各阶段目的、失败含义、跳过原因 - run_*.sh:-vv;nested subprocess+cov+xdist 回归测试改 stub --- ## 自验证 bash uv run pytest tests/regression/scripts/helpers/ci_gate/ \ tests/regression/scripts/helpers/common/test_pytest_runner.py -q 141 passed See merge request: Ascend/msmodeling!334 | 14 天前 | |
【REFACTOR】CI Gate 联合执行与 Nightly 流水线加固 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !342 merge fix into develop 【REFACTOR】CI Gate 联合执行与 Nightly 流水线加固 Created-by: AvadaKedavrua Commit-by: liujiawang Merged-by: ascend-robot Description: ## 修改原因 CI Gate / Nightly helpers 在 union 重构后存在多处逻辑与体验问题: - 全豁免测试仍跑 Phase 2(#112) - Nightly audit 使用过期 test_map(#113) - coverage fallback 在 union 重构后断裂(#119) - PRODUCT_SOURCE_PREFIXES 与 gate_policy.yaml 双源 roots - 重复 collect/git diff、日志含内部术语、nightly 缺终端摘要 本 PR 统一执行模型并补齐回归测试与文档。 --- ## 修改内容 **CI Gate (scripts/helpers/ci_gate/)** - 预跑硬阻断仅保留删除测试/删除源码;覆盖率映射改为跑后软策略 - compute_execution_plan 联合去重 pytest waves;产品/测试变更时附加 --cov - fetch_diff() 单次 git diff;load_gate_policy 按 yaml mtime 缓存 - roots 单一来源:tests/.ci/gate_policy.yaml - 用户向英文日志与成功摘要 print **Nightly (scripts/helpers/nightly/)** - 过期/冗余审计使用新鲜 test_map(#113) - 终端摘要、英文 phase 标签;移除 drift TODO - allowed_node_ids 复用、弱覆盖符号检测传 mapping **Common / Policy** - coverage_config.py 懒加载 product_roots() - gate_policy.yaml:tests/helpers/** exclude - 文档同步:tests/README.md、docs/design/ut_refactor.md、tests/SKILL.md 关联 issue:#112 #113 #114 #115 #116 #117 #119 #120 #121 #122 #123 #124 --- ## 优化特性对比(Before / After) ### 特性 1:联合去重 pytest 执行(核心优化) **场景**:同一 PR 同时改了产品代码 tensor_cast/foo.py 和测试文件 tests/regression/cli/test_shared.py,且 test_shared.py::test_x 恰好也是 foo.py 在 test_map 里的回归用例。 #### Before(分阶段、可能重复跑) text # 1) 预跑:新源码无 test_map 映射 → 直接硬阻断,pytest 还没跑 BLOCK: tensor_cast/foo.py has no test_map entry for symbol Foo.bar # 2) Phase 0:单独跑一轮带 --cov 的 pytest 做 coverage fallback pytest tests/regression/cli/test_shared.py -m not npu --cov ... # 3) Phase 1:跑变更测试 pytest tests/regression/cli/test_shared.py::test_x -m not npu # 4) Phase 2:再跑映射回归(与 Phase 1 重叠) pytest tests/regression/cli/test_shared.py::test_x \ tests/regression/cli/test_other.py::test_y \ -m "not npu and not nightly and not network" → test_shared.py::test_x 被执行 2~3 次;git diff 可能重复 fetch;coverage 与映射校验割裂 #### After(先跑、后验、去重) text # 1) 预跑硬阻断:仅删测试 / 删源码 Validating hard-blocking policy ... (no block — foo.py 是修改不是删除) # 2) 计划:联合调度,node id 去重(changed-test 优先) Scheduling 2 test node(s): new or changed test file Scheduling 1 test node(s): changed product file mapped regression Sample node(s): tests/regression/cli/test_shared.py::test_x, ... Execution uses 2 pytest wave(s) after deduplication # 3) 单次 union pytest(附带 --cov --cov-context=test) Wave 1 (-m not npu): tests/regression/cli/test_shared.py::test_x # changed-test,只跑一次 Wave 2 (-m not npu and not nightly and not network): tests/regression/cli/test_other.py::test_y # 纯回归,test_x 不再重复 # 4) 跑后软策略:用同一次 .coverage 做 mapping fallback Checking new/modified source coverage mapping against collected data ... CI gate passed: 2 test node(s) (new or changed test file; changed product file mapped regression) → 同一 node 只执行 1 次;coverage fallback 与 pytest 同轮完成;CI 耗时更短、行为更可预期 ### 特性 2:配置变更触发全量,跳过无效 collect **场景**:PR 只改了 pyproject.toml(依赖/测试配置变更)。 #### Before text config change detected → full suite still collect changed test files in Phase 1 ... # 多余 collect pytest tests/ -m not npu #### After text Config path(s): pyproject.toml Selected full test suite: dependency or test configuration changed pytest tests/ -m not npu # changed_test_nodes 为空,跳过 gate_new_tests collect CI gate passed: full test suite (pyproject.toml) ### 特性 3:Nightly 终端摘要(用户可读) #### Before text Phase 2a done. elapsed=1832.4s # 流水线结束,无一行总览;内部 phase 编号 #### After text Nightly pipeline finished. test_map: written (line 74.1%, branch 61.8%) nightly-marked: 142 passed in 1832s benchmark: 38 passed in 412s network: 12 passed in 89s weak coverage symbols: 3 report: /path/to/nightly_report.json --- ## 自验证 ### Helpers 回归测试 目的:确认 CI Gate / Nightly / Common helpers 全量回归通过 步骤: 1. 进入仓库根目录 2. 执行: bash uv run python -m pytest tests/regression/scripts/helpers/ -q 结果: 341 passed, 5 warnings in 1.02s ### gate_policy 缓存失效 目的:确认 yaml mtime 变化后 load_gate_policy 缓存失效 步骤: 1. 运行单测: bash uv run python -m pytest tests/regression/scripts/helpers/ci_gate/test_gate_policy.py::test_load_gate_policy_cached_until_yaml_mtime_changes -v 结果:PASSED(修复同秒写入 mtime 未变导致的 flaky) ### pre-commit 目的:提交前 hook 全绿 步骤: 1. git commit 触发 pre-commit(ruff、pylint、bandit、typos 等) 结果:全部 Passed See merge request: Ascend/msmodeling!342 | 13 天前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 28 天前 | ||
| 26 天前 | ||
| 28 天前 | ||
| 13 天前 | ||
| 13 天前 | ||
| 14 天前 | ||
| 14 天前 | ||
| 13 天前 | ||
| 13 天前 | ||
| 14 天前 | ||
| 13 天前 |