| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[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 | 29 天前 | |
【FIX】修复 nightly Feishu 误报与 web_ui conftest 全局污染 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !306 merge issue-fix into develop 【FIX】修复 nightly Feishu 误报与 web_ui conftest 全局污染 Created-by: AvadaKedavrua Commit-by: AvadaKedavrua;liujiawang Merged-by: ascend-robot Description: ## 修改原因 1. **#97 nightly Feishu 误报**:pytest 各 phase exit=1(collection/import 失败)但 JUnit 为空时,Feishu 仍显示 All passed / Passed: 0 | Failed: 0。 2. **#96 web_ui conftest 污染**:tests/regression/web_ui/conftest.py 在 import 时 sys.modules["tensor_cast"] = MagicMock(),xdist 全量收集时污染全局模块,触发 tensor_cast.__spec__ is not set。 3. **transformers 5.8.0**:deepseek_v4 重复注册导致 collection 失败。 --- ## 修改内容 ### Nightly 报告(#97) - FeishuReportInput / PhaseBreakdownEntry 结构化报告输入 - build_phase_breakdown()、resolve_first_error()、extract_pytest_log_snippet() 解析 phase log - Feishu payload 按 overall_exit + errors 判定状态,展示 per-phase breakdown 与 infra failure - 新增/更新 tests/regression/scripts/helpers/nightly/ 回归用例 ### Conftest 与 CI Gate(#96) - 移除 web_ui/conftest.py 模块级 sys.modules mock - is_config_path() 匹配 tests/**/conftest.py,conftest 变更触发全量回归 - 新增 tests/smoke/test_conftest_hygiene.py 守卫 ### 测试规范补强 - 新增 tests/helpers/junit_xml.py 共享 JUnit XML 构造 - 新增四 phase 全 infra failure 集成测 test_emit_report_four_phase_all_infra_failure ### 其他 - transformers 上限 <5.8.0 - pytest xdist 默认 --dist=worksteal(scripts/lib/common.sh 与各 run_*.sh) - 更新 tests/README.md / tests/SKILL.md / docs/design/ut_refactor.md --- ## 自验证 ### Nightly 工具链 UT collect-only 目的:确认新增/重构用例可被 pytest 正常收集,无 import 错误。 步骤: 1. 同步 CI 依赖: bash uv sync --frozen --group ci 2. 仅收集 nightly 回归用例: bash uv run pytest tests/regression/scripts/helpers/nightly/ --collect-only -q 结果: 85 tests collected in 0.04s ### Lint / 类型检查 目的:确认改动文件符合项目 ruff / mypy 要求。 步骤:对以下路径执行 MCP lint 与 type_check(explicit_package_bases=true): - scripts/helpers/nightly/*.py - tests/helpers/junit_xml.py - tests/regression/scripts/helpers/nightly/test_*.py 结果: ruff: clean mypy: clean (follow-imports=skip, explicit-package-bases) ### Conftest 卫生(#96 回归场景) 目的:验证 web_ui conftest 不再污染 tensor_cast.__spec__。 步骤: bash uv run pytest tests/smoke/test_conftest_hygiene.py -q 结果:该用例在 dfb66f0 提交中已添加;全量回归由用户在远端环境验证通过(见会话记录)。 See merge request: Ascend/msmodeling!306 | 19 天前 | |
【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 | 14 天前 | |
【FIX】修复 nightly Feishu 误报与 web_ui conftest 全局污染 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !306 merge issue-fix into develop 【FIX】修复 nightly Feishu 误报与 web_ui conftest 全局污染 Created-by: AvadaKedavrua Commit-by: AvadaKedavrua;liujiawang Merged-by: ascend-robot Description: ## 修改原因 1. **#97 nightly Feishu 误报**:pytest 各 phase exit=1(collection/import 失败)但 JUnit 为空时,Feishu 仍显示 All passed / Passed: 0 | Failed: 0。 2. **#96 web_ui conftest 污染**:tests/regression/web_ui/conftest.py 在 import 时 sys.modules["tensor_cast"] = MagicMock(),xdist 全量收集时污染全局模块,触发 tensor_cast.__spec__ is not set。 3. **transformers 5.8.0**:deepseek_v4 重复注册导致 collection 失败。 --- ## 修改内容 ### Nightly 报告(#97) - FeishuReportInput / PhaseBreakdownEntry 结构化报告输入 - build_phase_breakdown()、resolve_first_error()、extract_pytest_log_snippet() 解析 phase log - Feishu payload 按 overall_exit + errors 判定状态,展示 per-phase breakdown 与 infra failure - 新增/更新 tests/regression/scripts/helpers/nightly/ 回归用例 ### Conftest 与 CI Gate(#96) - 移除 web_ui/conftest.py 模块级 sys.modules mock - is_config_path() 匹配 tests/**/conftest.py,conftest 变更触发全量回归 - 新增 tests/smoke/test_conftest_hygiene.py 守卫 ### 测试规范补强 - 新增 tests/helpers/junit_xml.py 共享 JUnit XML 构造 - 新增四 phase 全 infra failure 集成测 test_emit_report_four_phase_all_infra_failure ### 其他 - transformers 上限 <5.8.0 - pytest xdist 默认 --dist=worksteal(scripts/lib/common.sh 与各 run_*.sh) - 更新 tests/README.md / tests/SKILL.md / docs/design/ut_refactor.md --- ## 自验证 ### Nightly 工具链 UT collect-only 目的:确认新增/重构用例可被 pytest 正常收集,无 import 错误。 步骤: 1. 同步 CI 依赖: bash uv sync --frozen --group ci 2. 仅收集 nightly 回归用例: bash uv run pytest tests/regression/scripts/helpers/nightly/ --collect-only -q 结果: 85 tests collected in 0.04s ### Lint / 类型检查 目的:确认改动文件符合项目 ruff / mypy 要求。 步骤:对以下路径执行 MCP lint 与 type_check(explicit_package_bases=true): - scripts/helpers/nightly/*.py - tests/helpers/junit_xml.py - tests/regression/scripts/helpers/nightly/test_*.py 结果: ruff: clean mypy: clean (follow-imports=skip, explicit-package-bases) ### Conftest 卫生(#96 回归场景) 目的:验证 web_ui conftest 不再污染 tensor_cast.__spec__。 步骤: bash uv run pytest tests/smoke/test_conftest_hygiene.py -q 结果:该用例在 dfb66f0 提交中已添加;全量回归由用户在远端环境验证通过(见会话记录)。 See merge request: Ascend/msmodeling!306 | 19 天前 | |
【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 | 14 天前 | |
【FIX】修复 nightly Feishu 误报与 web_ui conftest 全局污染 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !306 merge issue-fix into develop 【FIX】修复 nightly Feishu 误报与 web_ui conftest 全局污染 Created-by: AvadaKedavrua Commit-by: AvadaKedavrua;liujiawang Merged-by: ascend-robot Description: ## 修改原因 1. **#97 nightly Feishu 误报**:pytest 各 phase exit=1(collection/import 失败)但 JUnit 为空时,Feishu 仍显示 All passed / Passed: 0 | Failed: 0。 2. **#96 web_ui conftest 污染**:tests/regression/web_ui/conftest.py 在 import 时 sys.modules["tensor_cast"] = MagicMock(),xdist 全量收集时污染全局模块,触发 tensor_cast.__spec__ is not set。 3. **transformers 5.8.0**:deepseek_v4 重复注册导致 collection 失败。 --- ## 修改内容 ### Nightly 报告(#97) - FeishuReportInput / PhaseBreakdownEntry 结构化报告输入 - build_phase_breakdown()、resolve_first_error()、extract_pytest_log_snippet() 解析 phase log - Feishu payload 按 overall_exit + errors 判定状态,展示 per-phase breakdown 与 infra failure - 新增/更新 tests/regression/scripts/helpers/nightly/ 回归用例 ### Conftest 与 CI Gate(#96) - 移除 web_ui/conftest.py 模块级 sys.modules mock - is_config_path() 匹配 tests/**/conftest.py,conftest 变更触发全量回归 - 新增 tests/smoke/test_conftest_hygiene.py 守卫 ### 测试规范补强 - 新增 tests/helpers/junit_xml.py 共享 JUnit XML 构造 - 新增四 phase 全 infra failure 集成测 test_emit_report_four_phase_all_infra_failure ### 其他 - transformers 上限 <5.8.0 - pytest xdist 默认 --dist=worksteal(scripts/lib/common.sh 与各 run_*.sh) - 更新 tests/README.md / tests/SKILL.md / docs/design/ut_refactor.md --- ## 自验证 ### Nightly 工具链 UT collect-only 目的:确认新增/重构用例可被 pytest 正常收集,无 import 错误。 步骤: 1. 同步 CI 依赖: bash uv sync --frozen --group ci 2. 仅收集 nightly 回归用例: bash uv run pytest tests/regression/scripts/helpers/nightly/ --collect-only -q 结果: 85 tests collected in 0.04s ### Lint / 类型检查 目的:确认改动文件符合项目 ruff / mypy 要求。 步骤:对以下路径执行 MCP lint 与 type_check(explicit_package_bases=true): - scripts/helpers/nightly/*.py - tests/helpers/junit_xml.py - tests/regression/scripts/helpers/nightly/test_*.py 结果: ruff: clean mypy: clean (follow-imports=skip, explicit-package-bases) ### Conftest 卫生(#96 回归场景) 目的:验证 web_ui conftest 不再污染 tensor_cast.__spec__。 步骤: bash uv run pytest tests/smoke/test_conftest_hygiene.py -q 结果:该用例在 dfb66f0 提交中已添加;全量回归由用户在远端环境验证通过(见会话记录)。 See merge request: Ascend/msmodeling!306 | 19 天前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 29 天前 | ||
| 19 天前 | ||
| 14 天前 | ||
| 19 天前 | ||
| 14 天前 | ||
| 19 天前 |