已合并
[feature] compile_commands.json软链到build/并统一pre-commit的clang-tidy与gitleaks检查 #229
wangyixian创建于 3 天前
[feature] compile_commands.json软链到build/并统一pre-commit的clang-tidy与gitleaks检查 #229
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 wangyixian 的贡献)atomgit-bot
3 天前 评论:
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,避免拼写检查误报。


atomgit-bot
3 天前 评论:
3 天前 评论:
ascend-robot
3 天前 评论:
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
/approveor/lgtm- Commenting
/approveimplies 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. 👍


3 天前 添加了label:ascend-cla/yes
ascend-robot
3 天前 评论:
3 天前 评论:
ascend docs pipeline is running...


3 天前 添加了label:docs-ci-pipeline-running
3 天前 关联了里程碑:MindStudio 26.2.0
VolKano
3 天前 评论:
3 天前 评论:
ci_test


ascend-robot
3 天前 评论:
3 天前 评论:
✅ 跳过 docs ci 检查,没有需要检查的文档文件


3 天前 删除了label:docs-ci-pipeline-running
3 天前 添加了label:docs-ci-pipeline-success
3 天前 修改了pull request 的描述
wangyixian
3 天前 评论:
3 天前 评论:
compile


ascend-robot
3 天前 评论:
3 天前 评论:
ascend docs pipeline is running...


3 天前 删除了label:docs-ci-pipeline-success
3 天前 添加了label:docs-ci-pipeline-running
3 天前 添加了label:ci-pipeline-running
ascend-robot
3 天前 评论:
3 天前 评论:
✅ 跳过 docs ci 检查,没有需要检查的文档文件


3 天前 删除了label:docs-ci-pipeline-running
3 天前 添加了label:docs-ci-pipeline-success
went_code
3 天前 评论:
3 天前 评论:
/approve


3 天前 添加了label:approved
3 天前 删除了label:ci-pipeline-running
3 天前 添加了label:ci-pipeline-passed
AtlasAccount
3 天前 评论:
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 | ✅ | >>> |
- compile : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


gong-siwei
3 天前 评论:
3 天前 评论:
/lgtm


3 天前 添加了label:lgtm
3 天前 合入了pull request
1. 修改描述
compile_commands.json放于 build 目录下;clang-tidy 依赖编译数据库,需要在构建后自动生成软链接供 IDE 使用。 https://gitcode.com/Ascend/msot/issues/54cmake/Modules/LLVM.cmake:新增symlink_compile_commands步骤,将build/llvm-build/compile_commands.json软链到build/compile_commands.json,供 clangd 等 IDE 使用。pre-commit/clang-tidy-wrapper.sh:检查 compile_commands.json 存在后再执行 clang-tidy。.pre-commit-config.yaml:clang-tidy entry 改为 wrapper,-p指向 build 目录;gitleaks entry 改为gitleaks;codespell 忽略 DEPENDEES。2. 功能验证
python build.py local验证,[2/8] Symlink compile_commands.json to build/ for clangd IDE support步骤执行成功,build/compile_commands.json软链正确,产品包归档成功。3. 代码检视
本 PR 改动约 50 行,远小于 200 行,无需 sig 会议申报。
4. 资料修改自检