Merged
feat(script): Enhance pre_commit_check.sh for local LLT full verification and raise CI case timeout #6053
chengding888Add on Sep 8
feat(script): Enhance pre_commit_check.sh for local LLT full verification and raise CI case timeout #6053
Merged
chengding888Add on Sep 8
chengding888
chengding888Collaborators
Sep 8

PR 应该避免没有描述信息,描述信息的最重要的作用是描述修改意图,应该清晰明了。例如:标题中包含了 fix 标签,如果没有描述信息,就需要Review人员猜测PR具体修复了哪些内容,或者怀疑修改的必要性。如果PR和特定的Issue相关,可以单独包含一行 Related Issue: 放到描述信息最后。

下面是一个典型的PR描述信息:

The origin issue template brings too many noise, it's not suitable for git message. eg: comments
are not removed, labels are redundant as the PR tile already contains the tag.

The guide gives a clear suggestion on how to write the PR body.

Related Issue: #1234,#5678

更多描述信息见:Commit Message 规范

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for chengding888's contribution.)
chengding888chengding888Collaborators
Sep 8 Created pull request, commit 1521d153
atomgit-bot
atomgit-bot
Sep 8 Comments:

变更摘要

该 PR 旨在增强本地 tools/scripts/pre_commit_check.sh 的 --full 全量 LLT 验证能力,并同步提升 CI 侧用例执行超时时间。CI 脚本 .gitcode/scripts/ut.sh 中多个 UT 任务的 --case_execute_timeout 从 90 秒提升至 120 秒;本地脚本则改进了 --full 模式下不依赖文件变更强制跑全量模块、ASan 阶段跳过 perf 门禁计时用例、仿真 UT 前临时清除 ASCEND_WORK_PATH 环境变量,并将 clang/ASan 阶段失败从直接退出改为告警提示,避免阻塞其余阶段的验证。

主要改动

  • 提升 CI 用例超时时间: .gitcode/scripts/ut.sh 中 Py3_ninja、Cpp_make_clang、make_clang1/2/3、make_gnu_1/2/3 等任务的 --case_execute_timeout 由 90 统一调整为 120。
  • --full 模式强制全量验证: pre_commit_check.sh 的 main() 中,--full 模式下直接设置 HAS_CPP=1、HAS_PY=1 并指定全量 UT_MODULES/PY_MODULES,不再依赖变更文件分析;同时"仅文档/配置变更跳过 UT"的提前退出逻辑增加 FULL != 1 条件。
  • ASan 阶段跳过 perf 门禁计时用例: run_clang() 中新增 GTEST_FILTER="${CLANG_GTEST_FILTER:-*-*PerfGuard*:*RunTimeLimit*}" 环境变量,ASan 阶段只做内存安全检查,计时验证交由 gnu/Release 阶段覆盖。
  • 仿真 UT 环境变量处理: run_sim() 在执行前临时 unset ASCEND_WORK_PATH(避免框架将其重定向到 $ASCEND_WORK_PATH/pypto 导致断言失败),结束后恢复原值并保留返回码。
  • clang/ASan 失败降级为告警: run_clang 失败时不再立即退出,而是记录 CLANG_FAILED=1 并输出告警日志,其余阶段继续执行;最终汇总时若 CLANG_FAILED=1 会附加人工确认提示。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 8 Comments:

代码审查

审查结论

已逐一审查全部 2 个变更文件:

**1. .gitcode/scripts/ut.sh**(无问题) 仅将 8 处 --case_execute_timeout 由 90 提升为 120,参数替换统一、无逻辑变更,check_ret` 调用链不受影响。

2. `tools/scripts/pre_commit_check.sh(2 个问题)

  • run_sim 的 ASCEND_WORK_PATH 临时 unset/恢复、--full 跳过条件与模块强制覆盖、CLANG_FAILED 状态机本身实现正确;set -u 下 ${ASCEND_WORK_PATH:-}、local rc=$? 均安全。
  • 但存在下述两个缺陷。

发现问题汇总

优先级 数量 说明
P0 0 —
P1 0 —
P2 1 clang/ASan 阶段失败后脚本仍打印"全部检查通过,可以提交 PR"并 exit 0,与失败告警自相矛盾,且使本地预检(含 pre-push 钩子场景)无法拦截真实 ASan 错误,与本工具"提前拦截 CI 门禁错误"的定位相悖
P3 1 run_clang 中 export GTEST_FILTER 未在阶段结束后恢复,会泄漏到后续 run_py/run_sim 及任何 gtest 子进程,存在静默跳过 perf 门禁用例的验证盲区

总体风险判断

本次改动主体(CI 超时提升、--full 全量逻辑、仿真环境变量隔离)正确且低风险;主要风险集中在 clang 失败被降级为"仅告警 + exit 0"这一处,可能使 --full 模式漏报 ASan 内存错误并误导开发者提交 PR,建议合入前修正最终成功提示与退出码。

类型 数量
🔴 阻塞 0
🟡 建议 1

💬 仅评论

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 8 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 8 Comments:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
.gitcode/** ✅ Larry_liuyi, wangzheng97 (2/2) ✅ Larry_liuyi (1/1)
tools/scripts ✅ 尹杰, wangzheng97 (2/2) ✅ 尹杰 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
CANN-robot
CANN-robotCollaborators
Sep 8 Comments:

CLA Signature Pass

chengding888, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robotCollaborators
Sep 8 Set mywaaagh_admin,songchangxia,xinweiliu,tanghaoran7,cam_bxh,shentukangjun,dai-zhentao,lululu40888,shi-dingkun,gguuaanngg,codehjp423,Larry_liuyi,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Sep 8 Set mywaaagh_admin,songchangxia,tanghaoran7,shentukangjun,Larry_liuyi,jason_yuan_ye,yinjie27_,tsungl4,gaoxingwang,linjiashu as approver
chengding888chengding888Collaborators
Sep 8 Associated issue: [Requirement|需求建议]: 新增上库前本地预检工具(一级冒烟)提前拦截 CI 门禁错误
chengding888
chengding888Collaborators
Sep 8 Comments:

compile

likedislike
chengding888chengding888Collaborators
Sep 8 Pre merge succeeded (commit_id: fd9c921a927bcc3034aabbb27c7a4fa5df51c8fd)
CANN-robot
CANN-robotCollaborators
Sep 8 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 8 Added label: ci-pipeline-running
atomgit-bot
atomgit-botSep 8Start code review1
tools/scripts/pre_commit_check.sh
@@ -388,0 +400,4 @@
400+ if [[ "${rc}" != "0" ]]; then
401+ CLANG_FAILED=1
402+ log_warn "clang UT 失败: 可能存在真正的 ASan 内存错误(perf 门禁用例已跳过), 请查看上方日志人工确认。"
403+ fi
atomgit-bot
atomgit-botSep 8Comments:

🟡 Medium Priority

变更行 400-403:run_clang 失败时不再 exit 1,改为置 CLANG_FAILED=1 并仅打 log_warn。但脚本末尾 418 行仍无条件打印 "全部检查通过 (耗时 Xs), 可以提交 PR。",422 行无条件 exit 0,与 420 行新增的失败告警自相矛盾。

受影响行为/契约:本工具(Issue #3186、PR 标题)的定位是"上库前本地预检、提前拦截 CI 门禁错误",并在 --full 模式下对齐 CI 的 Cpp_make_clang 范围;而 CI 侧 ut.sh 的 Cpp_make_clang/make_clang* 分支在 UT 失败时均 check_ret 退出非零。此次改动把 clang 阶段从硬失败降级为"仅告警 + exit 0"。

失败模式:--full 模式下若 clang/ASan 阶段存在真实的 ASan 内存错误,脚本会输出"全部检查通过,可以提交 PR"并以退出码 0 结束。开发者按提示提交 PR 后,CI 的 clang/ASan 门禁必然失败并浪费一次 CI 循环——这正是该工具要提前拦截的场景;若脚本被挂为 pre-push 钩子(Issue #3186 方案 3),exit 0 也会直接放行。即便降级是刻意为之,最终成功提示与退出码也必须与失败状态一致,否则输出会误导使用者。

修复方向:CLANG_FAILED=1 时跳过/改写 418 行的成功消息,并在最终判定处 exit 1(或至少不再打印"可以提交 PR"),让失败可见、可被钩子拦截。

建议:在最终汇总处根据 CLANG_FAILED 判定:为 1 时打印失败汇总并 exit 1(与 gnu/py/sim 阶段的失败处理一致),或将 418 行的"全部检查通过/可以提交 PR"改为条件输出,避免成功消息与失败告警同时出现、退出码掩盖失败。

likedislike
Incorrect?
chengding888chengding888Collaborators
Sep 8 Resolved final issue
CANN-robotCANN-robotCollaborators
Sep 8 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 8 Added label: ci-pipeline-passed
Jie Yin
Jie YinCollaborators
Sep 8 Comments:

/approve

likedislike
刘怡
刘怡Collaborators
Sep 8 Comments:

/approve
/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Sep 8 Added label: approved
wangzheng97
wangzheng97Collaborators
Sep 8 Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Sep 8 Added label: lgtm
wangzheng97
wangzheng97Collaborators
Sep 8 Comments:

/check-pr

likedislike
CANN-robotCANN-robotCollaborators
Sep 8 Merged pull request