已合并
[core] ci: pre-commit 全量格式化:clang-format/ruff,仅格式无逻辑变更 #930
[core] ci: pre-commit 全量格式化:clang-format/ruff,仅格式无逻辑变更 #930
已合并
shilinlee创建于 7月8日
shilinlee
shilinlee成员
7月8日

合入来源

问题/功能描述

仓库代码风格不统一(C++ 指针对齐、大括号位置、行宽;Python 引号、行宽、换行),且缺乏强制校验。需引入 pre-commit 全量格式化与 CI PR 检查,统一全仓风格基线。

修改方案描述

  1. 配置 pre-commit 钩子(.pre-commit-config.yaml、.clang-format、pre-commit/pyproject.toml):trim trailing whitespace、fix end of files、check yaml/json、detect private key、ruff format(py310,行长 120)、codespell、clang-format v18.1.8(Google 基础,IndentWidth=4,ColumnLimit=120,Allman 大括号)。
  2. 改造 script/ci-pre-commit-pr.sh,支持全量检查/格式化与按 PR 变更增量过滤两种模式。
  3. 验证:pre-commit run --all-files 全部通过;95 个 Python 文件 AST 比对无语义差异;C++ 抽查(common_def.h、pytransfer.cpp 等)均为纯格式化。

是否涉及UT/ST

开发自检

likedislike
Pull Request已成功合入, 合并人@zhangjinshi
(感谢 shilinlee 的贡献)
shilinleeshilinlee成员
7月8日 强制推送  102 个提交:b9b57ddb-100 commits from branch develop,8c17fb5e-commit,97859d01-[format] pre-commit 全量格式化:clang-format/ruff,仅格式无逻辑变更
shilinleeshilinlee成员
7月8日 修改标题为 “[core] ci: pre-commit 全量格式化:clang-format/ruff,仅格式无逻辑变更”,原标题为“[core] ci: 临时跳过 ruff/pylint/bandit 三个 pre-commit hook”
shilinleeshilinlee成员
7月8日 修改了pull request 的描述
shilinleeshilinlee成员
7月8日 修改了pull request 的描述
shilinleeshilinlee成员
7月8日 关联了issue:[Usage]: 门禁开启pre-commit,格式化代码
shilinleeshilinlee成员
7月8日 强制推送  4 个提交:26c9ec4f-2 commits from branch develop,3b49e114-commit,56c6efd5-[format] pre-commit 全量格式化:clang-format/ruff,仅格式无逻辑变更
ascend-robotascend-robot成员
7月8日 添加了label:ci-pipeline-running
ascend-robotascend-robot成员
7月8日 添加了label:ascend-cla/yes
ascend-robotascend-robot成员
7月8日 添加了label:stat/needs-squash
ascend-robot
ascend-robot成员
7月8日 评论:

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

⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 3 person(s) per module)、approve (requires ≥ 1 person(s) per module)

Module Approval Details

module lgtm status approve status
repo-Ascend/memfabric_hybrid ❌ (0/3)(You can also ask: xu-jingru, gaopu2024, p_chenhui, wuxiaotong, swagglian_gitcode) ❌ (0/1)(You can also ask: yangjingyao, weihaoran1, yuncliu, liu1103xwxw, shepherd-cheung)

💡 Tip:

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

CLA Signature Pass

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

likedislike
ascend-robotascend-robot成员
7月8日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
7月8日 添加了label:ci-pipeline-failed
shilinlee
shilinlee成员
7月9日 评论:

retry UT_memfabric-hybrid

likedislike
ascend-robotascend-robot成员
7月9日 删除了label:ci-pipeline-failed
ascend-robotascend-robot成员
7月9日 添加了label:ci-pipeline-running
shilinlee
shilinlee成员
7月9日 评论:

retry CodeCheck_mf

likedislike
shilinlee
shilinlee成员
7月9日 评论:

retry SCA_mf

likedislike
shilinleeshilinlee成员
7月9日 修改了pull request 的描述
ascend-robotascend-robot成员
7月9日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
7月9日 添加了label:ci-pipeline-failed
ascend-robot
ascend-robot成员
7月9日 评论:
流水线 PR-pipeline_memfabric_hybrid#4145 (重试第1次) [ commitID:56c6efd5 ] 运行失败
阶段 任务名 状态 详情
编译构建 Build_memfabric-hybrid ✅ >>>
Build_memfabric-hybrid-bazel ✅ >>>
恶意代码检查 Antipoison_mf ✅ >>>
编码安全与规范检查 pre-commit ✅ >>>
CodeCheck_mf ✅ >>>
开源片段检查 SCA_mf ✅ >>>
开发者测试 UT_memfabric-hybrid ❌ >>>
流水线 PR-pipeline_memfabric_hybrid ❌ >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员评论有效
  • compile : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
shilinlee
shilinlee成员
7月9日 评论:

retry UT_memfabric-hybrid

likedislike
ascend-robotascend-robot成员
7月9日 删除了label:ci-pipeline-failed
ascend-robotascend-robot成员
7月9日 添加了label:ci-pipeline-running
ascend-robotascend-robot成员
7月9日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
7月9日 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
7月9日 评论:
流水线 PR-pipeline_memfabric_hybrid#4145 (重试第3次) [ commitID:56c6efd5 ] 已完成
阶段 任务名 状态 详情
编译构建 Build_memfabric-hybrid ✅ >>>
Build_memfabric-hybrid-bazel ✅ >>>
恶意代码检查 Antipoison_mf ✅ >>>
编码安全与规范检查 pre-commit ✅ >>>
CodeCheck_mf ✅ >>>
开源片段检查 SCA_mf ✅ >>>
开发者测试 UT_memfabric-hybrid ✅ >>>
流水线 PR-pipeline_memfabric_hybrid ✅ >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员评论有效
  • compile : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
Yyangqi成员
7月9日 将yangqi12138设为评审人
Yyangqi成员
7月9日 通过了评审
Zzhangjinshi成员
7月9日 通过审查
Zzhangjinshi成员
7月9日 关闭了关联的issue
Zzhangjinshi成员
7月9日 合入了pull request