已合并
[feature] compile_commands.json软链到build/并统一pre-commit的clang-tidy与gitleaks检查 #229
[feature] compile_commands.json软链到build/并统一pre-commit的clang-tidy与gitleaks检查 #229
已合并
wangyixian创建于 3 天前
wangyixian成员
3 天前

1. 修改描述

  • 修改原因: 统一规范要求将 compile_commands.json 放于 build 目录下;clang-tidy 依赖编译数据库,需要在构建后自动生成软链接供 IDE 使用。 https://gitcode.com/Ascend/msot/issues/54
  • 修改方案: 参考 msopprof 的 ExternalProject_Add_Step 实现,在 llvm_project 构建后软链其 compile_commands.json 到 build/ 目录;pre-commit 的 clang-tidy 改为经 clang-tidy-wrapper.sh 调用,gitleaks 由本地二进制改为直接调用系统命令。
  • 修改内容:
    1. cmake/Modules/LLVM.cmake:新增 symlink_compile_commands 步骤,将 build/llvm-build/compile_commands.json 软链到 build/compile_commands.json,供 clangd 等 IDE 使用。
    2. 新增 pre-commit/clang-tidy-wrapper.sh:检查 compile_commands.json 存在后再执行 clang-tidy。
    3. .pre-commit-config.yaml:clang-tidy entry 改为 wrapper,-p 指向 build 目录;gitleaks entry 改为 gitleaks;codespell 忽略 DEPENDEES。
  • 涉及代码双合(贴上另一个PR链接):

2. 功能验证

  • 功能自验截图(请确保不体现个人信息)
  • 冒烟是否通过 已通过 python build.py local 验证,[2/8] Symlink compile_commands.json to build/ for clangd IDE support 步骤执行成功,build/compile_commands.json 软链正确,产品包归档成功。

3. 代码检视

  • 要求:
    • 合入功能代码大于 200 行,需要sig会议申报代码检视议题,并在PR中标注会议。
    • committer评估是否需要在sig会议进行代码检视。
    • 参与检视的committer人员名单与检视时间。
    • 大于 1000 行代码原则上不允许合入,需进行备案。
      本 PR 改动约 50 行,远小于 200 行,无需 sig 会议申报。
  • 是否经过代码检视
  • 是否具备UT测试用例看护
  • 是否需要在sig会议中进行代码检视
  • 检视committer人员名单与检视时间:

4. 资料修改自检

  • 资料修改: NA

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 wangyixian 的贡献)
atomgit-bot
atomgit-bot
3 天前 评论:

变更摘要

此 PR 主要目的是统一项目构建规范:将 compile_commands.json 软链到 build/ 目录下供 clangd 等 IDE 工具使用,同时统一 pre-commit 中 clang-tidy 与 gitleaks 的调用方式。通过在 LLVM.cmake 中新增构建后步骤自动创建软链接,并引入 clang-tidy-wrapper.sh 脚本在执行 clang-tidy 前校验编译数据库是否存在,提升开发体验和 pre-commit 健壮性。

主要改动

  • 新增 compile_commands.json 软链接构建步骤:在 cmake/Modules/LLVM.cmake 中为 llvm_project 新增 ExternalProject_Add_Step,在构建完成后自动移除旧文件并将内层 build/llvm-build/compile_commands.json 软链接到 build/compile_commands.json,供 clangd 直接使用。
  • 新增 clang-tidy-wrapper.sh 包装脚本:在执行 clang-tidy 之前检查 build/compile_commands.json 是否存在,若不存在则打印明确错误提示(建议运行 python3 build.py 生成)并以 exit 1 终止,避免静默失败。
- **pre-commit clang-tidy 配置调整**:`.pre-commit-config.yaml` 中 clang-tidy 的 `entry` 从直接调用 `clang-tidy` 改为 `pre-commit/clang-tidy-wrapper.sh`,`-p` 参数从 `.clang-tidy-build` 调整为 `build` 目录,以匹配新的编译数据库路径。
  • pre-commit gitleaks 调用方式变更.pre-commit-config.yaml 中 gitleaks 的 entry 从本地二进制 ./gitleaks 改为直接调用系统命令 gitleaks
  • codespell 忽略词扩充.pre-commit-config.yaml 中 codespell 的忽略词列表新增 DEPENDEES,避免拼写检查误报。
likedislike
atomgit-bot
atomgit-bot
3 天前 评论:

代码审查

✅ 未发现问题

likedislike
ascend-robot
ascend-robot成员
3 天前 评论:

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


PR Approval Progress

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

Module Approval Details

module lgtm status approve status
repo-Ascend/msdebug 龚思维, 门飞飞 (2/2) 门飞飞 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

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

likedislike
ascend-robotascend-robot成员
3 天前 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
3 天前 评论:

ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
3 天前 添加了label:docs-ci-pipeline-running
Wwangyixian成员
3 天前 关联了里程碑:MindStudio 26.2.0
VolKano
VolKano
3 天前 评论:

ci_test

likedislike
ascend-robot
ascend-robot成员
3 天前 评论:

✅ 跳过 docs ci 检查,没有需要检查的文档文件

likedislike
ascend-robotascend-robot成员
3 天前 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
3 天前 添加了label:docs-ci-pipeline-success
Wwangyixian成员
3 天前 修改了pull request 的描述
wangyixian成员
3 天前 评论:

compile

likedislike
ascend-robot
ascend-robot成员
3 天前 评论:

ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
3 天前 删除了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
3 天前 添加了label:docs-ci-pipeline-running
AtlasAccountAtlasAccount成员
3 天前 添加了label:ci-pipeline-running
ascend-robot
ascend-robot成员
3 天前 评论:

✅ 跳过 docs ci 检查,没有需要检查的文档文件

likedislike
ascend-robotascend-robot成员
3 天前 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
3 天前 添加了label:docs-ci-pipeline-success
went_code
went_code成员
3 天前 评论:

/approve

likedislike
ascend-robotascend-robot成员
3 天前 添加了label:approved
AtlasAccountAtlasAccount成员
3 天前 删除了label:ci-pipeline-running
AtlasAccountAtlasAccount成员
3 天前 添加了label:ci-pipeline-passed
AtlasAccount
AtlasAccount成员
3 天前 评论:
流水线 PR-pipeline_msdebug#544 [ commitID:06c6356d ] 已完成
>>>代码风格自动修复执行失败,具体请查看日志,不影响流水线执行及PR合入
阶段 任务名 状态 详情
编译构建 Build_msdebug_x86 >>>
Build_msdebug_arm >>>
恶意代码检查 Antipoison_msdebug >>>
编码安全与规范检查 codecheck_pre-commit >>>
pre-commit >>>
md_check md_check >>>
开源片段检查 SCA_msdebug >>>
开发者测试 UT_msdebug >>>
PreSmoke_msdebug >>>
流水线 PR-pipeline_msdebug >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员[A1streomeria]评论有效
  • compile : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
gong-siwei成员
3 天前 评论:

/lgtm

likedislike
ascend-robotascend-robot成员
3 天前 添加了label:lgtm
ascend-robotascend-robot成员
3 天前 合入了pull request