ci(gates): 覆盖率总闸与全量 cppcheck 移到远端 CI 强制(提交期实跑 48 根)
用户裁定 2026-10-28:慢钩子不再压在每个 git commit 上,由远端 CI 强制;本地等价入口 = scripts/ci_local.py 的 manual 段。 实测三根耗时:cppcheck 20.5 s、test-cppcheck 38.1 s、 test-coverage 105.2 s,合计 ~165 s ≈ 一次带代码提交耗时的 三分之二(test-coverage 的 files: 覆盖 App/,改一行就跑光 40 套)。 - .pre-commit-config.yaml:cppcheck / test-cppcheck / test-coverage 加 stages: [manual] + 理由注释;替换掉 test-coverage 上方「没写 stages → 所有阶段都跑、输出出现两次」 的旧坑注释(固定 manual 后不再有这一坑)。 - .gitea/workflows/ci.yml:static-gates job 在静态门禁步之后 新增「手动阶段门禁(覆盖率总闸 + 全量 cppcheck)」步, if: always(),逐根 --hook-stage manual(pre_commit run 不支持 多 id),日志 ci-artifacts/manual-stage.log + 归档 + STEP_SUMMARY, rc≠0 即失败;run 块纯 ASCII。 - scripts/ci_local.py:新增 MANUAL_STAGE_HOOKS 与 run_manual_stage() (静态段之后默认跑),删 run_coverage() 死代码,--coverage 降级为兼容别名。 - AGENTS.md + 12 篇 docs/scripts/README:三数同源口径改为 声明 51 / 提交期 --all-files 实跑 47 / +gitlint = 48, 其余 3 根在 manual 阶段;历史测量数字只加「当时」不回改。 验证:pre-commit run --all-files = 47 Passed / 0 Failed rc=0; manual 三根 Passed(test-coverage line 89.8% func 93.2% 41/41 套); ci_local.py --static-only 全绿;check_doc_links --all --sections-strict rc=0、mojibake / bom-drift / id-check-new rc=0; ci.yml yaml.safe_load 通过。未改任何 .c/.h,故未跑 @build。
This commit is contained in:
+16
-5
@@ -76,6 +76,11 @@ repos:
|
||||
hooks:
|
||||
- id: cppcheck
|
||||
name: cppcheck
|
||||
# ⚠ stages: [manual](2026-10-28 用户裁定):全库扫描实测 ~20 s,不压在提交期;
|
||||
# 由**远端 CI** 强制(.gitea/workflows/ci.yml 的「手动阶段门禁(覆盖率总闸 + 全量 cppcheck)」步),
|
||||
# 本地的等价入口 = scripts/ci_local.py(manual 段)或
|
||||
# python -m pre_commit run --all-files --hook-stage manual cppcheck
|
||||
stages: [manual]
|
||||
entry: cppcheck
|
||||
# 注意:YAML 流序列中逗号是元素分隔符,含逗号/空格的参数必须加引号
|
||||
args: ['--enable=warning,performance,portability,style', '--error-exitcode=1',
|
||||
@@ -115,6 +120,9 @@ repos:
|
||||
# 依据:docs/审查记录/测试与架构改进建议.md §3.4;实机测试实施指南.md §8.1
|
||||
- id: test-cppcheck
|
||||
name: cppcheck (test/, warning only)
|
||||
# ⚠ stages: [manual](2026-10-28,同 cppcheck):实测 ~38 s;由远端 CI 与
|
||||
# scripts/ci_local.py 的 manual 段跑,提交期不跑。
|
||||
stages: [manual]
|
||||
entry: cppcheck
|
||||
args: ['--enable=warning', '--error-exitcode=1',
|
||||
'--inline-suppr', '--std=c99', '--quiet',
|
||||
@@ -737,13 +745,16 @@ repos:
|
||||
# 口径 / 分母 / 基线 / 盲区详解都在 docs/测试说明/主机单测覆盖率口径.md,本处只留接线事实。
|
||||
# 触发面**含门禁自身**(.pre-commit-config.yaml):不带自身就等于谁改坏这根闸的 files:
|
||||
# 模式,它就再也不跑且无人察觉(同 lv-conf-sync / bsp-err 的既有做法)。
|
||||
# ⚠ 读输出的坑(2026-10-24 连踩两次才定位):本钩子没写 stages: → 默认属于**所有阶段**,
|
||||
# 于是同一次提交的输出里它出现两次:pre-commit 阶段那一遍才可能实跑;commit-msg 阶段
|
||||
# 那一遍的"文件"是提交信息文件,几乎必然 (no files to check)Skipped。**只看输出结尾会
|
||||
# 把"实跑通过"读成"根本没跑"**——判它跑没跑要认**第一次**出现的那一行。
|
||||
# 实跑证据:只改本文件的提交(e327636 / c4ca292)里 test-coverage 与 bsp-err 都是 Passed。
|
||||
# ⚠ stages: [manual](2026-10-28 用户裁定):本钩子跑光全部 40 套单测(实测 ~105 s,
|
||||
# 占一次带代码提交耗时的三分之二)→ 不压在提交期,由**远端 CI** 强制
|
||||
# (.gitea/workflows/ci.yml 的「手动阶段门禁(覆盖率总闸 + 全量 cppcheck)」步),本地等价入口 =
|
||||
# scripts/ci_local.py(manual 段);手工复跑:
|
||||
# python -m pre_commit run --all-files --hook-stage manual test-coverage
|
||||
# 另:此前它没写 stages: → 默认属于所有阶段,同一次提交输出里出现两次(commit-msg
|
||||
# 阶段那遍几乎必然 Skipped,只看结尾会把实跑读成"没跑")。固定 manual 阶段后不再有这一坑。
|
||||
- id: test-coverage
|
||||
name: 主机单测覆盖率(增量拦截:已覆盖行只增不减)
|
||||
stages: [manual]
|
||||
entry: python scripts/check_test_coverage.py
|
||||
language: system
|
||||
files: ^(App/|Drivers/BSP/|test/host/|scripts/check_test_coverage\.py|scripts/test_coverage_baseline\.json|\.pre-commit-config\.yaml$)
|
||||
|
||||
Reference in New Issue
Block a user