已合并
更新.pre-commit-config.yaml,统一repo和rev #251
Whn0604创建于 26 天前
更新.pre-commit-config.yaml,统一repo和rev #251
已合并
Whn0604创建于 26 天前
4 个文件变更+72-26
@@ -36,3 +36,7 @@ tmp/
36**/.claude/scheduled_tasks.lock36**/.claude/scheduled_tasks.lock
37 37 
38coverage.xml38coverage.xml
39+ 
40+oat_reports/
41+ 
42+log/
@@ -1,17 +1,57 @@
1-repos: 1+# See https://pre-commit.com for hook docs.
2- # C++ 代码格式化检查 2+# NOTE: 本文件 license header 由 OAT.xml 的 defaultPolicyFilter/copyrightPolicyFilter 豁免,
3- - repo: https://github.com/pre-commit/mirrors-clang-format 3+# CI 的 precommit.py 会用 PyYAML 重序列化本文件、丢弃所有注释(含 license header)。
4- rev: v16.0.0 4+default_language_version:
5- hooks: 5+ python: python3
6- - id: clang-format
7- types_or: [c++, c]
8 6 
9- # Python 代码检查 7+repos:
10- - repo: https://gitcode.com/gh_mirrors/ru/ruff-pre-commit 8+ # 基础文本/安全检查
11- rev: v0.14.14 9+ - repo: https://gitcode.com/gh_mirrors/pr/pre-commit-hooks
12- hooks: 10+ rev: v4.6.0
13- - id: ruff-check 11+ hooks:
14- args: ["--output-format", "github", "--fix"] 12+ - id: trailing-whitespace
15- types: [python] 13+ exclude_types: [markdown]
16- - id: ruff-format 14+ - id: end-of-file-fixer
17- types: [python] 15+ - id: check-yaml
16+ # safe-loaders may choke on multi-document YAML anchors in some CI files
17+ args: [--allow-multiple-documents]
18+ - id: check-json
19+ - id: check-added-large-files
20+ args: [--maxkb=1024]
21+ - id: check-merge-conflict
22+ - id: detect-private-key
23+ 
24+ # C/C++ 格式化(遵循仓库根目录 .clang-format,style=file)
25+ - repo: https://gitcode.com/pre-commit-clang/mirrors-clang-format
26+ rev: v18.1.8
27+ hooks:
28+ - id: clang-format
29+ types_or: [c++, c]
30+ 
31+ # Python 检查与格式化
32+ - repo: https://gitcode.com/gh_mirrors/ru/ruff-pre-commit
33+ rev: v0.14.14
34+ hooks:
35+ - id: ruff-check
36+ args: [--output-format=github, --fix]
37+ types: [python]
38+ - id: ruff-format
39+ types: [python]
40+ 
41+ # 拼写检查(CANN 专用词典白名单见 .codespellrc)
42+ - repo: https://gitcode.com/gh_mirrors/co/codespell
43+ rev: v2.4.1
44+ hooks:
45+ - id: codespell
46+ additional_dependencies:
47+ - tomli
48+ 
49+ # 开源合规检查(华为 OAT)
50+ - repo: local
51+ hooks:
52+ - id: oat-check
53+ name: oat-check (open-source compliance)
54+ entry: ./scripts/oat_check.sh
55+ language: system
56+ pass_filenames: false
57+ stages: [pre-commit]
MOAT.xml+11-9
@@ -12,14 +12,16 @@
12 <filefilterlist>12 <filefilterlist>
13 <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">13 <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
14 <filteritem type="filename" name="classify_rule.yaml" desc="recognize code owner"/>14 <filteritem type="filename" name="classify_rule.yaml" desc="recognize code owner"/>
15- <filteritem type="filename" name="OWNERS" desc="Describe commite owner"/> 15+ <filteritem type="filename" name="OWNERS" desc="Describe commite owner"/>
16- <filteritem type="filename" name="OAT.xml" desc="Describe commite owner"/> 16+ <filteritem type="filename" name="OAT.xml" desc="Describe commite owner"/>
17 <filteritem type="filename" name=".gitmodules" desc="git submodule "/>17 <filteritem type="filename" name=".gitmodules" desc="git submodule "/>
18+ <filteritem type="filename" name=".pre-commit-config.yaml" desc="pre-commit tool config, regenerated by CI (comments stripped)"/>
18 </filefilter>19 </filefilter>
19 <filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">20 <filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
20 <filteritem type="filename" name="classify_rule.yaml" desc="recognize code owner"/>21 <filteritem type="filename" name="classify_rule.yaml" desc="recognize code owner"/>
21 <filteritem type="filename" name="OWNERS" desc="Describe commite owner"/>22 <filteritem type="filename" name="OWNERS" desc="Describe commite owner"/>
22 <filteritem type="filename" name=".gitmodules" desc="git submodule "/>23 <filteritem type="filename" name=".gitmodules" desc="git submodule "/>
24+ <filteritem type="filename" name=".pre-commit-config.yaml" desc="pre-commit tool config, regenerated by CI (comments stripped)"/>
23 </filefilter>25 </filefilter>
24 <filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies">26 <filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies">
25 </filefilter>27 </filefilter>
@@ -37,21 +39,21 @@
37 Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);39 Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
38 you may not use this file except in compliance with the License.40 you may not use this file except in compliance with the License.
39 You may obtain a copy of the License at41 You may obtain a copy of the License at
40- 42+ 
41 http://www.apache.org/licenses/LICENSE-2.043 http://www.apache.org/licenses/LICENSE-2.0
42- 44+ 
43 Unless required by applicable law or agreed to in writing, software45 Unless required by applicable law or agreed to in writing, software
44 distributed under the License is distributed on an &quot;AS IS&quot; BASIS,46 distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
45 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.47 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46 See the License for the specific language governing permissions and48 See the License for the specific language governing permissions and
47 limitations under the License.49 limitations under the License.
48 </licensetext>50 </licensetext>
49- 51+ 
50 <!-- SPDX标识符匹配 -->52 <!-- SPDX标识符匹配 -->
51 <licensetext name="SPDX-Apache-2.0" desc="SPDX license identifier">53 <licensetext name="SPDX-Apache-2.0" desc="SPDX license identifier">
52 SPDX-License-Identifier: Apache-2.054 SPDX-License-Identifier: Apache-2.0
53 </licensetext>55 </licensetext>
54- 56+ 
55 <!-- 简化的Apache头 -->57 <!-- 简化的Apache头 -->
56 <licensetext name="Apache-2.0-Simple" desc="Simple Apache 2.0 header">58 <licensetext name="Apache-2.0-Simple" desc="Simple Apache 2.0 header">
57 Licensed to the Apache Software Foundation (ASF) under one59 Licensed to the Apache Software Foundation (ASF) under one
@@ -61,9 +63,9 @@
61 to you under the Apache License, Version 2.0 (the63 to you under the Apache License, Version 2.0 (the
62 &quot;License&quot;); you may not use this file except in compliance64 &quot;License&quot;); you may not use this file except in compliance
63 with the License. You may obtain a copy of the License at65 with the License. You may obtain a copy of the License at
64- 66+ 
65 http://www.apache.org/licenses/LICENSE-2.067 http://www.apache.org/licenses/LICENSE-2.0
66- 68+ 
67 Unless required by applicable law or agreed to in writing,69 Unless required by applicable law or agreed to in writing,
68 software distributed under the License is distributed on an70 software distributed under the License is distributed on an
69 &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY71 &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -74,4 +76,4 @@
74 </licensematcher>76 </licensematcher>
75 </licensematcherlist>77 </licensematcherlist>
76 </oatconfig>78 </oatconfig>
77-</configuration>79+</configuration>
@@ -5,7 +5,7 @@
5# Licensed under the Apache License, Version 2.0 (the "License");5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at7# You may obtain a copy of the License at
8-# 8+#
9# http://www.apache.org/licenses/LICENSE-2.09# http://www.apache.org/licenses/LICENSE-2.0
10#10#
11# Unless required by applicable law or agreed to in writing, software11# Unless required by applicable law or agreed to in writing, software