feat: 流水线更新,兼容多次commit
All checks were successful
缓存序列化结构检查 / cache-schema-check (push) Has been skipped
All checks were successful
缓存序列化结构检查 / cache-schema-check (push) Has been skipped
This commit is contained in:
59
docs/实施方案.md
59
docs/实施方案.md
@@ -239,13 +239,18 @@ java -jar cache-schema-checker-1.0.0.jar \
|
||||
|
||||
### 6.2 对比基准(old-sha)获取策略
|
||||
|
||||
与 `demo.yaml` 保持一致,优先级:
|
||||
流水线使用 **push 区间累计对比**(方案:`before` → `after`):
|
||||
|
||||
1. 流水线显式传入 `--old-sha`(通常为 `HEAD~1`)
|
||||
2. 若 `HEAD~1` 不存在(首次提交)→ 跳过检测,`exit 0`
|
||||
3. 浅克隆 `--depth 2` 确保 `HEAD~1` 可用
|
||||
1. `--new-sha` = `gitea.sha`(push 后 tip)
|
||||
2. `--old-sha` = `gitea.event.before`(push 前 tip)
|
||||
3. `before` 为空或全 `0`(新分支首次 push)→ 跳过检测,`exit 0`
|
||||
4. `workflow_dispatch` 无 before 时回退 `HEAD~1`
|
||||
5. 浅克隆当前 tip(`--depth 1`),再按需 `git fetch --depth 1 <before>` / `deepen`,**无需全量历史**
|
||||
|
||||
> 不支持一次 push 多个 commit 时逐个分析;第一版仅对比 `HEAD~1..HEAD`。后续可扩展为 `before..after` 范围分析。
|
||||
> 一次 push 含多个 commit 时,只做 **一次** 检测,对比区间为整次 push 的累计 diff(`before..after`),不会漏掉中间 commit 留下的结构变更。
|
||||
> 不做「每个 commit 各告警一条」;中间引入又被末 commit 改回的净无变更,累计结果可能为「无变更」(符合阻断「最终结构」的目标)。
|
||||
|
||||
详见 `docs/CI集成说明.md`。
|
||||
|
||||
### 6.3 处理步骤
|
||||
|
||||
@@ -465,42 +470,14 @@ notify:
|
||||
详见 `docs/CI集成说明.md`。核心流程:
|
||||
|
||||
```yaml
|
||||
# jnpf-java-cloud/.gitea/workflows/cache-schema-check.yaml
|
||||
name: 缓存序列化结构检查
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
cache-schema-check:
|
||||
if: ${{ gitea.ref != 'refs/heads/pre' && gitea.ref != 'refs/heads/dev' && gitea.ref != 'refs/heads/master-2.0' }}
|
||||
runs-on: jdk11
|
||||
steps:
|
||||
- name: 检出代码
|
||||
run: |
|
||||
git clone --depth 2 --single-branch --branch "${{ gitea.ref_name }}" \
|
||||
"https://${{ gitea.token }}@git.niujiekeji.com/${{ gitea.repository }}.git" .
|
||||
git checkout -B "${{ gitea.ref_name }}" "${{ gitea.sha }}"
|
||||
|
||||
- name: 下载检测工具
|
||||
run: |
|
||||
# 从 Nexus 下载 cache-schema-checker jar
|
||||
...
|
||||
|
||||
- name: 执行检测
|
||||
env:
|
||||
WECOM_ROBOT_WEBHOOK: ${{ secrets.WECOM_ROBOT_WEBHOOK }}
|
||||
run: |
|
||||
OLD_SHA=$(git rev-parse HEAD~1 2>/dev/null || echo "")
|
||||
[ -z "$OLD_SHA" ] && exit 0
|
||||
java -jar /tmp/cache-schema-checker-1.0.0.jar \
|
||||
--config .gitea/config/cache-schema-check-config.yaml \
|
||||
--repo-root . \
|
||||
--old-sha "$OLD_SHA" \
|
||||
--new-sha "$(git rev-parse HEAD)" \
|
||||
--branch "${{ gitea.ref_name }}" \
|
||||
--modifier "${{ gitea.actor }}" \
|
||||
--modify-time "$(git log -1 --format=%cd --date=format:'%Y-%m-%d %H:%M:%S')"
|
||||
# jnpf-java-cloud/.gitea/workflows/cache-schema-check.yaml(要点)
|
||||
# 检出:浅克隆 tip(depth 1)
|
||||
# 检测:--old-sha = gitea.event.before,--new-sha = gitea.sha
|
||||
# 按需 fetch before 提交对象,覆盖一次 push 的多 commit 累计 diff
|
||||
```
|
||||
|
||||
完整模板见 `docs/CI集成说明.md` / `.gitea/workflows/cache-schema-check.yaml`。
|
||||
|
||||
---
|
||||
|
||||
## 10. 分阶段交付计划
|
||||
@@ -579,8 +556,8 @@ jobs:
|
||||
| 类型推断失败 | 漏报 | 标记 `LOW_CONFIDENCE`,配置 `manual_mappings` |
|
||||
| Lombok 复杂注解 | 字段遗漏 | 基于源码字段 + 注解;后续 delombok |
|
||||
| 同一 key 多分支写不同类型 | 误报 | 报告注明置信度;人工 suppression |
|
||||
| 浅克隆 parent 不可用 | 跳过检测 | `--depth 2`;文档明确要求 |
|
||||
| 一次 push 多 commit | 仅检最后一个 | 文档说明;后续扩展 range |
|
||||
| 浅克隆拿不到 before | 漏检 / exit 2 | 按 SHA `fetch --depth 1` + deepen 兜底;见 CI 说明 |
|
||||
| 一次 push 多 commit | 旧方案仅看末 commit 会漏检 | 已改为 `before..after` 累计对比 |
|
||||
| 依赖 jar 中的类型 | 字段展开不完整 | 配置 `manual_mappings` 补充 |
|
||||
| JsonUtil 实现不可见 | 序列化规则猜测 | 默认按字段名序列化;与 Fastjson 对齐 |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user