已合并
support pre commit function flow. #653
liu-wei创建于 3月31日
support pre commit function flow. #653
已合并
liu-wei创建于 3月31日
liu-wei
liu-wei成员
3月31日

描述

support pre commit function flow.
添加 pre-commit 钩子,支持 OAT(Open Audit Tool)合规检查流程。

  • 新增 pre-commit 配置,集成 OAT 合规检查
  • OAT 脚本自动检测并安装 Java 21、Maven
  • 增量扫描 staged 文件的许可证头和二进制文件
  • CRLF 行尾自动修复
  • 自动将 oat_reports/ 和 log/ 加入 .gitignore

关联的Issue

https://gitcode.com/cann/ops-cv/issues/280

测试

pre commit oat check等功能本地执行成功。

文档更新

不涉及文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 liu-wei 的贡献)
liu-weiliu-wei成员
3月31日 创建了 pull request,commit d6d004cc
CANN-robot
CANN-robot成员
3月31日 评论:

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-cann/ops-cv llimwang, loov1 (2/2) llimwang (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robot成员
3月31日 添加了label:cann-cla/yes
CANN-robotCANN-robot成员
3月31日 将zhou-qilong,rxtfeng,loov1,llimwang,gubaocheng设为评审人
CANN-robotCANN-robot成员
3月31日 将zhou-qilong,rxtfeng,loov1,llimwang,gubaocheng设为审查人
liu-wei
liu-wei成员
3月31日 评论:

compile

likedislike
CANN-robot
CANN-robot成员
3月31日 评论:

问题/功能描述

本次PR旨在为项目建立一套代码提交前的自动化检查与质量保障机制,以提升代码规范性和开源合规性。主要解决了两个问题:一是通过配置.gitignore文件,忽略构建产物、测试报告和日志等非源码文件,保持代码仓库的整洁;二是通过引入pre-commit框架,在代码提交前自动执行代码格式化(C/C++)和开源合规性检查,从源头保障代码质量。

修改方案描述

修改方案包含两部分核心内容。首先,更新了.gitignore文件,新增了对oat_reports/log/目录的忽略规则。其次,新增了.pre-commit-config.yaml配置文件,集成了clang-format代码格式化钩子和一个自定义的OAT(开源审计工具)合规性检查脚本钩子。该自定义脚本(scripts/oat_check.sh)实现了环境自愈(自动修复CRLF、安装Java/Maven依赖)、自动获取并构建OAT工具、以增量模式扫描待提交文件,并生成合规性检查报告摘要,从而构建了一个完整、自动化且对开发者友好的预提交检查流程。

likedislike
CANN-robotCANN-robot成员
3月31日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
3月31日 评论:

流水线任务触发成功
任务链接 [48038dc8bc9e4c46850ae54c69a564ee][流水线指导]

任务名称状态日志下载链接
codecheck ❌ FAILED
SCA ✅ SUCCESS >>>>>
anti_virus ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Pre_Compile ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_A5_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_A5_ubuntu24 ✅ SUCCESS >>>>>
Compile_X86_monitor ✅ SUCCESS >>>>> >>>>>
Compile_ARM_monitor ✅ SUCCESS >>>>> >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_codestyle ⚠️ WARNING >>>>>
UT_Test ⚪ ABORTED
Smoke_A900_npupool ⚪ ABORTED
API_Check ⚪ ABORTED >>>>>
ATK_Test_A2 ⚪ ABORTED

[2026-03-31 19:36:21]    CI执行失败

likedislike
CANN-robotCANN-robot成员
3月31日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
3月31日 添加了label:ci-pipeline-failed
liu-wei
liu-wei成员
3月31日 评论:

compile

likedislike
CANN-robotCANN-robot成员
3月31日 删除了label:ci-pipeline-failed
CANN-robotCANN-robot成员
3月31日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
3月31日 评论:

流水线任务触发成功
任务链接 [d72d062e6bf1444eaec352faeda28738][流水线指导]

任务名称状态日志下载链接
codecheck ❌ FAILED >>>>>
SCA ✅ SUCCESS >>>>>
anti_virus ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Pre_Compile ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_A5_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_A5_ubuntu24 ✅ SUCCESS >>>>>
Compile_X86_monitor ✅ SUCCESS >>>>> >>>>>
Compile_ARM_monitor ✅ SUCCESS >>>>> >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_codestyle ⚠️ WARNING >>>>>
UT_Test ⚪ ABORTED
Smoke_A900_npupool ⚪ ABORTED
API_Check ⚪ ABORTED >>>>>
ATK_Test_A2 ⚪ ABORTED

[2026-03-31 19:44:27]    CI执行失败

likedislike
CANN-robotCANN-robot成员
3月31日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
3月31日 添加了label:ci-pipeline-failed
liu-wei
liu-wei成员
3月31日 评论:

代码审查报告

PR 概述

添加 pre-commit 钩子,支持 OAT(Open Audit Tool)合规检查流程。

变更文件

文件 增/删
.gitignore +4 / -1
.pre-commit-config.yaml +18
scripts/oat_check.sh +532

主要功能

  1. 新增 pre-commit 配置 ()

    • 集成 OAT 合规检查脚本
    • 支持增量扫描模式
  2. OAT 检查脚本 ()

    • 自动检测 Java/Maven 环境
    • 自动安装依赖(Java 21、Maven)
    • 增量扫描 staged 文件的许可证头和二进制文件
    • CRLF 行尾自动修复
    • 自动将 和 加入 .gitignore
  3. .gitignore 更新

    • 忽略 OAT 报告输出目录

审查结论

项目 结论
建议 ✅ 建议合入
严重性 Low
代码质量 良好
内存安全 ✅ 无风险
安全性 ✅ 无漏洞

建议补充

  1. PR 描述中「关联的Issue」和「测试」标记为 todo,建议补充具体信息
  2. 建议在 README 中添加 pre-commit 使用说明

此审查由 AI 自动生成

likedislike
liu-wei
liu-wei成员
3月31日 评论:

代码审查报告

PR 概述

添加 pre-commit 钩子,支持 OAT(Open Audit Tool)合规检查流程。

变更文件

  • .gitignore (+4/-1)
  • .pre-commit-config.yaml (+18)
  • scripts/oat_check.sh (+532)

主要功能

  1. 新增 pre-commit 配置,集成 OAT 合规检查
  2. OAT 脚本自动检测并安装 Java 21、Maven
  3. 增量扫描 staged 文件的许可证头和二进制文件
  4. CRLF 行尾自动修复
  5. 自动将 oat_reports/ 和 log/ 加入 .gitignore

审查结论

项目 结论
建议 ✅ 建议合入
严重性 Low
代码质量 良好
内存安全 ✅ 无风险
安全性 ✅ 无漏洞

建议补充

  1. PR 描述中「关联的Issue」和「测试」标记为 todo,建议补充
  2. 建议在 README 中添加 pre-commit 使用说明

此审查由 AI 自动生成

likedislike
liu-wei
liu-wei成员
3月31日 评论:

代码审查报告

PR 概述

添加 pre-commit 钩子,支持 OAT(Open Audit Tool)合规检查流程。

变更文件

  • .gitignore (+4/-1)
  • .pre-commit-config.yaml (+18)
  • scripts/oat_check.sh (+532)

主要功能

  1. 新增 pre-commit 配置,集成 OAT 合规检查
  2. OAT 脚本自动检测并安装 Java 21、Maven
  3. 增量扫描 staged 文件的许可证头和二进制文件
  4. CRLF 行尾自动修复
  5. 自动将 oat_reports/ 和 log/ 加入 .gitignore

审查结论

项目 结论
建议 ✅ 建议合入
严重性 Low
代码质量 良好
内存安全 ✅ 无风险
安全性 ✅ 无漏洞

建议补充

  1. PR 描述中「关联的Issue」和「测试」标记为 todo,建议补充
  2. 建议在 README 中添加 pre-commit 使用说明

此审查由 AI 自动生成

likedislike
liu-weiliu-wei成员
3月31日 修改了pull request 的描述
liu-weiliu-wei成员
3月31日 修改了pull request 的描述
liu-wei
liu-wei成员
3月31日 评论:

compile

likedislike
CANN-robotCANN-robot成员
3月31日 删除了label:ci-pipeline-failed
CANN-robotCANN-robot成员
3月31日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
3月31日 评论:

流水线任务触发成功
任务链接 [410a282c456b448fa62348be9c70b584][流水线指导]

任务名称状态日志下载链接
codecheck ❌ FAILED >>>>>
SCA ✅ SUCCESS >>>>>
anti_virus ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Pre_Compile ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_A5_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_A5_ubuntu24 ✅ SUCCESS >>>>>
Compile_X86_monitor ✅ SUCCESS >>>>> >>>>>
Compile_ARM_monitor ✅ SUCCESS >>>>> >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_codestyle ⚠️ WARNING >>>>>
UT_Test ⚪ ABORTED
Smoke_A900_npupool ⚪ ABORTED
API_Check ⚪ ABORTED >>>>>
ATK_Test_A2 ⚪ ABORTED

[2026-03-31 20:29:43]    CI执行失败

likedislike
CANN-robotCANN-robot成员
3月31日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
3月31日 添加了label:ci-pipeline-failed
liu-weiliu-wei成员
3月31日 update merge request[project id: 7657293, iid: 653, commit_id: a37d21b741cc145d0a7ea908196a7f2f6cfd7538] virtual merging success
liu-weiliu-wei成员
3月31日 强制推送  1 个提交:07a18472-support pre commit function flow.
liu-weiliu-wei成员
3月31日 update merge request[project id: 7657293, iid: 653, commit_id: c146ad83b3a9e28731a4f902ec866a1549d07d8f] virtual merging success
liu-wei
liu-wei成员
3月31日 评论:

compile

likedislike
CANN-robotCANN-robot成员
3月31日 删除了label:ci-pipeline-failed
CANN-robotCANN-robot成员
3月31日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
3月31日 评论:

流水线任务触发成功
任务链接 [1c44db1134cb4856aae8e882422e299c][流水线指导]

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
anti_virus ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Pre_Compile ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_A5_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_A5_ubuntu24 ✅ SUCCESS >>>>>
Compile_X86_monitor ✅ SUCCESS >>>>> >>>>>
Compile_ARM_monitor ✅ SUCCESS >>>>> >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_codestyle ✅ SUCCESS >>>>>
UT_Test ✅ SUCCESS
Smoke_A900_npupool ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
ATK_Test_A2 ✅ SUCCESS

[2026-03-31 20:57:49]    CI执行结束

likedislike
CANN-robotCANN-robot成员
3月31日 添加了label:api-check-pass
CANN-robotCANN-robot成员
3月31日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
3月31日 添加了label:ci-pipeline-passed
liu-weiliu-wei成员
4月1日 修改了pull request 的描述
llimwang成员
4月1日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
4月1日 添加了label:approved
loov成员
4月1日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
4月1日 添加了label:lgtm
CANN-robot
CANN-robot成员
4月1日 评论:

Review Guide

This pull-request passes review.
Committers who wrote a comment of /approve are: llimwang.
Reviewers who wrote a comment of /lgtm are: llimwang, loov1.

likedislike
CANN-robotCANN-robot成员
4月1日 关闭了关联的issue
CANN-robotCANN-robot成员
4月1日 合入了pull request