This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
# ============================================================
|
# ============================================================
|
||||||
# 缓存序列化结构变更检测 — 业务仓库配置
|
# 序列化结构变更检测 — 业务仓库配置
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# 说明:
|
# 说明:
|
||||||
# - 本配置文件为业务覆盖配置,会与 jar 内 default-config.yaml 深度合并
|
# - 本配置文件为业务覆盖配置,会与 jar 内 default-config.yaml 深度合并
|
||||||
# - 未声明的项沿用工具内置默认值(忽略规则、检测模式等)
|
# - 未声明的项沿用工具内置默认值(忽略规则、检测模式等)
|
||||||
# - 当前实现以 Redis 写入检测为主,后续可扩展其他缓存
|
# - 当前以 Redis 缓存写入检测为主;MQ(RocketMQ/Kafka)方案见 docs/MQ序列化结构检测方案.md
|
||||||
|
|
||||||
# 总开关 true-执行检测 false-跳过检测(流水线直接通过,不发通知)
|
# 总开关 true-执行检测 false-跳过检测(流水线直接通过,不发通知)
|
||||||
enabled: true
|
enabled: true
|
||||||
@@ -17,7 +17,7 @@ notify:
|
|||||||
enabled: true
|
enabled: true
|
||||||
webhook_url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=fa14f0b3-e01a-40f6-96bd-e18beb94e85e
|
webhook_url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=fa14f0b3-e01a-40f6-96bd-e18beb94e85e
|
||||||
notify_on_clean: false
|
notify_on_clean: false
|
||||||
title_prefix: "【缓存结构变更】"
|
title_prefix: "【序列化结构变更】"
|
||||||
|
|
||||||
# 观察期:先只扫描 jnpf-tenant 模块,稳定后改为 include_modules: []
|
# 观察期:先只扫描 jnpf-tenant 模块,稳定后改为 include_modules: []
|
||||||
include_modules:
|
include_modules:
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
name: 缓存序列化结构检查
|
name: 序列化结构检查
|
||||||
run-name: ${{ gitea.actor }}的缓存结构检查
|
run-name: ${{ gitea.actor }}的序列化结构检查
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# cache-schema-checker 私库坐标:com.codechecker:cache-schema-checker:1.0.0
|
# serialization-schema-checker 私库坐标:com.codechecker:serialization-schema-checker:1.0.0
|
||||||
CACHE_SCHEMA_CHECKER_VERSION: "1.0.0"
|
SERIALIZATION_SCHEMA_CHECKER_VERSION: "1.0.0"
|
||||||
CACHE_SCHEMA_CHECKER_REPO_URL: "http://192.168.3.25:18081/nexus/repository/maven-releases"
|
SERIALIZATION_SCHEMA_CHECKER_REPO_URL: "http://192.168.3.25:18081/nexus/repository/maven-releases"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
cache-schema-check:
|
serialization-schema-check:
|
||||||
if: ${{ gitea.ref != 'refs/heads/pre' && gitea.ref != 'refs/heads/dev' && gitea.ref != 'refs/heads/master-2.0' }}
|
if: ${{ gitea.ref != 'refs/heads/pre' && gitea.ref != 'refs/heads/dev' && gitea.ref != 'refs/heads/master-2.0' }}
|
||||||
runs-on: jdk11
|
runs-on: jdk11
|
||||||
steps:
|
steps:
|
||||||
@@ -27,30 +27,30 @@ jobs:
|
|||||||
git clone --depth 1 --single-branch --branch "${BRANCH}" "${REPO_URL}" .
|
git clone --depth 1 --single-branch --branch "${BRANCH}" "${REPO_URL}" .
|
||||||
git checkout -B "${BRANCH}" "${NEW_SHA}"
|
git checkout -B "${BRANCH}" "${NEW_SHA}"
|
||||||
|
|
||||||
echo "${NEW_SHA}" > /tmp/cache-schema-new-sha.txt
|
echo "${NEW_SHA}" > /tmp/serialization-schema-new-sha.txt
|
||||||
|
|
||||||
- name: 检查配置文件
|
- name: 检查配置文件
|
||||||
run: |
|
run: |
|
||||||
if [ ! -f .gitea/config/cache-schema-check-config.yaml ]; then
|
if [ ! -f .gitea/config/serialization-schema-check-config.yaml ]; then
|
||||||
echo "错误: 缺少 .gitea/config/cache-schema-check-config.yaml"
|
echo "错误: 缺少 .gitea/config/serialization-schema-check-config.yaml"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# 顶层总开关 enabled: false 时跳过后续步骤(与 notify.enabled 区分,仅匹配行首)
|
# 顶层总开关 enabled: false 时跳过后续步骤(与 notify.enabled 区分,仅匹配行首)
|
||||||
if grep -Eq '^enabled:[[:space:]]*false([[:space:]]|#|$)' .gitea/config/cache-schema-check-config.yaml; then
|
if grep -Eq '^enabled:[[:space:]]*false([[:space:]]|#|$)' .gitea/config/serialization-schema-check-config.yaml; then
|
||||||
echo "总开关 enabled=false,跳过缓存结构检查"
|
echo "总开关 enabled=false,跳过序列化结构检查"
|
||||||
touch /tmp/cache-schema-check.skip
|
touch /tmp/serialization-schema-check.skip
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 从 Nexus 私库下载 cache-schema-checker
|
- name: 从 Nexus 私库下载 serialization-schema-checker
|
||||||
run: |
|
run: |
|
||||||
if [ -f /tmp/cache-schema-check.skip ]; then
|
if [ -f /tmp/serialization-schema-check.skip ]; then
|
||||||
echo "总开关已关闭,跳过下载"
|
echo "总开关已关闭,跳过下载"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
GROUP_PATH="com/codechecker/cache-schema-checker"
|
GROUP_PATH="com/codechecker/serialization-schema-checker"
|
||||||
JAR_NAME="cache-schema-checker-${CACHE_SCHEMA_CHECKER_VERSION}.jar"
|
JAR_NAME="serialization-schema-checker-${SERIALIZATION_SCHEMA_CHECKER_VERSION}.jar"
|
||||||
JAR_URL="${CACHE_SCHEMA_CHECKER_REPO_URL}/${GROUP_PATH}/${CACHE_SCHEMA_CHECKER_VERSION}/${JAR_NAME}"
|
JAR_URL="${SERIALIZATION_SCHEMA_CHECKER_REPO_URL}/${GROUP_PATH}/${SERIALIZATION_SCHEMA_CHECKER_VERSION}/${JAR_NAME}"
|
||||||
JAR_PATH="/tmp/${JAR_NAME}"
|
JAR_PATH="/tmp/${JAR_NAME}"
|
||||||
|
|
||||||
echo "下载: ${JAR_URL}"
|
echo "下载: ${JAR_URL}"
|
||||||
@@ -72,25 +72,25 @@ jobs:
|
|||||||
|
|
||||||
- name: 验证 JDK
|
- name: 验证 JDK
|
||||||
run: |
|
run: |
|
||||||
if [ -f /tmp/cache-schema-check.skip ]; then
|
if [ -f /tmp/serialization-schema-check.skip ]; then
|
||||||
echo "总开关已关闭,跳过"
|
echo "总开关已关闭,跳过"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo "Java: $(java -version 2>&1 | head -1)"
|
echo "Java: $(java -version 2>&1 | head -1)"
|
||||||
|
|
||||||
- name: 执行缓存序列化结构检测
|
- name: 执行序列化结构检测
|
||||||
env:
|
env:
|
||||||
# push 前 tip;新分支首次 push 时为全 0。workflow_dispatch 可能为空,下方会回退。
|
# push 前 tip;新分支首次 push 时为全 0。workflow_dispatch 可能为空,下方会回退。
|
||||||
PUSH_BEFORE: ${{ gitea.event.before }}
|
PUSH_BEFORE: ${{ gitea.event.before }}
|
||||||
# push 事件携带的 commits 列表(JSON);用于准确统计 commit 数(不受浅克隆影响)
|
# push 事件携带的 commits 列表(JSON);用于准确统计 commit 数(不受浅克隆影响)
|
||||||
PUSH_COMMITS_JSON: ${{ toJson(gitea.event.commits) }}
|
PUSH_COMMITS_JSON: ${{ toJson(gitea.event.commits) }}
|
||||||
run: |
|
run: |
|
||||||
if [ -f /tmp/cache-schema-check.skip ]; then
|
if [ -f /tmp/serialization-schema-check.skip ]; then
|
||||||
echo "总开关已关闭,跳过检测"
|
echo "总开关已关闭,跳过检测"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NEW_SHA=$(cat /tmp/cache-schema-new-sha.txt)
|
NEW_SHA=$(cat /tmp/serialization-schema-new-sha.txt)
|
||||||
OLD_SHA="${PUSH_BEFORE}"
|
OLD_SHA="${PUSH_BEFORE}"
|
||||||
|
|
||||||
# 新分支首次 push(before 全 0)→ 跳过
|
# 新分支首次 push(before 全 0)→ 跳过
|
||||||
@@ -199,8 +199,8 @@ jobs:
|
|||||||
|
|
||||||
COMMIT_TIME=$(git log -1 --format=%cd --date=format:'%Y-%m-%d %H:%M:%S' "${NEW_SHA}")
|
COMMIT_TIME=$(git log -1 --format=%cd --date=format:'%Y-%m-%d %H:%M:%S' "${NEW_SHA}")
|
||||||
|
|
||||||
java -jar "/tmp/cache-schema-checker-${CACHE_SCHEMA_CHECKER_VERSION}.jar" \
|
java -jar "/tmp/serialization-schema-checker-${SERIALIZATION_SCHEMA_CHECKER_VERSION}.jar" \
|
||||||
--config .gitea/config/cache-schema-check-config.yaml \
|
--config .gitea/config/serialization-schema-check-config.yaml \
|
||||||
--repo-root . \
|
--repo-root . \
|
||||||
--old-sha "$OLD_SHA" \
|
--old-sha "$OLD_SHA" \
|
||||||
--new-sha "$NEW_SHA" \
|
--new-sha "$NEW_SHA" \
|
||||||
6
.idea/compiler.xml
generated
6
.idea/compiler.xml
generated
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<annotationProcessing>
|
<annotationProcessing>
|
||||||
@@ -6,11 +6,11 @@
|
|||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
<module name="cache-schema-checker" />
|
<module name="serialization-schema-checker" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
<bytecodeTargetLevel>
|
<bytecodeTargetLevel>
|
||||||
<module name="cache-schema-checker" target="11" />
|
<module name="serialization-schema-checker" target="11" />
|
||||||
</bytecodeTargetLevel>
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 缓存序列化结构检测 — CI 集成说明
|
# 序列化结构检测 — CI 集成说明
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ Gitea Actions 触发
|
|||||||
↓
|
↓
|
||||||
浅克隆业务仓库 tip(depth=1)+ 按需取 push 前 tip(before)
|
浅克隆业务仓库 tip(depth=1)+ 按需取 push 前 tip(before)
|
||||||
↓
|
↓
|
||||||
从 Nexus 下载 cache-schema-checker.jar
|
从 Nexus 下载 serialization-schema-checker.jar
|
||||||
↓
|
↓
|
||||||
java -jar 执行(对比 before → after,累计 diff)
|
java -jar 执行(对比 before → after,累计 diff)
|
||||||
↓
|
↓
|
||||||
@@ -46,7 +46,7 @@ mode=block 且含任意结构变更 → exit 1(流水线失败)
|
|||||||
|----|------|
|
|----|------|
|
||||||
| Gitea Runner | 标签 `jdk11`,已安装 Java 11 |
|
| Gitea Runner | 标签 `jdk11`,已安装 Java 11 |
|
||||||
| Nexus 私库 | 可访问 `http://192.168.3.25:18081/nexus/repository/maven-releases` |
|
| Nexus 私库 | 可访问 `http://192.168.3.25:18081/nexus/repository/maven-releases` |
|
||||||
| 工具 JAR | `com.codechecker:cache-schema-checker:1.0.0` 已发布 |
|
| 工具 JAR | `com.codechecker:serialization-schema-checker:1.0.0` 已发布 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -58,18 +58,18 @@ mode=block 且含任意结构变更 → exit 1(流水线失败)
|
|||||||
jnpf-java-cloud/
|
jnpf-java-cloud/
|
||||||
├── .gitea/
|
├── .gitea/
|
||||||
│ ├── workflows/
|
│ ├── workflows/
|
||||||
│ │ └── cache-schema-check.yaml # 流水线
|
│ │ └── serialization-schema-check.yaml # 流水线
|
||||||
│ └── config/
|
│ └── config/
|
||||||
│ └── cache-schema-check-config.yaml # 检测配置
|
│ └── serialization-schema-check-config.yaml # 检测配置
|
||||||
```
|
```
|
||||||
|
|
||||||
请以本仓库 `.gitea/workflows/cache-schema-check.yaml` 为模板同步到业务仓。
|
请以本仓库 `.gitea/workflows/serialization-schema-check.yaml` 为模板同步到业务仓。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 4. 流水线模板(要点)
|
## 4. 流水线模板(要点)
|
||||||
|
|
||||||
完整可运行版本见:`.gitea/workflows/cache-schema-check.yaml`。
|
完整可运行版本见:`.gitea/workflows/serialization-schema-check.yaml`。
|
||||||
|
|
||||||
核心逻辑摘要:
|
核心逻辑摘要:
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ git fetch --depth 1 origin "$OLD_SHA" # 优先
|
|||||||
# 或 git fetch --deepen N # 兜底
|
# 或 git fetch --deepen N # 兜底
|
||||||
|
|
||||||
# 4) 执行
|
# 4) 执行
|
||||||
java -jar cache-schema-checker-1.0.0.jar \
|
java -jar serialization-schema-checker-1.0.0.jar \
|
||||||
--old-sha "$OLD_SHA" \
|
--old-sha "$OLD_SHA" \
|
||||||
--new-sha "$NEW_SHA" \
|
--new-sha "$NEW_SHA" \
|
||||||
...
|
...
|
||||||
@@ -98,7 +98,7 @@ java -jar cache-schema-checker-1.0.0.jar \
|
|||||||
|--------|------|------|
|
|--------|------|------|
|
||||||
| `demo.yaml` (AI代码质量分析) | AI Code Review | 并行,互不影响 |
|
| `demo.yaml` (AI代码质量分析) | AI Code Review | 并行,互不影响 |
|
||||||
| `code-check` (CodeChecker) | 通用变更检测 | **同模式**,可并列执行 |
|
| `code-check` (CodeChecker) | 通用变更检测 | **同模式**,可并列执行 |
|
||||||
| `cache-schema-check` | 缓存结构检测 | 新增 |
|
| `serialization-schema-check` | 缓存结构检测 | 新增 |
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -116,9 +116,9 @@ mvn clean deploy -DskipTests
|
|||||||
发布产物:
|
发布产物:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
com/codechecker/cache-schema-checker/1.0.0/
|
com/codechecker/serialization-schema-checker/1.0.0/
|
||||||
├── cache-schema-checker-1.0.0.jar # 可执行 fat-jar
|
├── serialization-schema-checker-1.0.0.jar # 可执行 fat-jar
|
||||||
└── cache-schema-checker-1.0.0.pom
|
└── serialization-schema-checker-1.0.0.pom
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -157,8 +157,8 @@ com/codechecker/cache-schema-checker/1.0.0/
|
|||||||
OLD_SHA=$(git rev-parse origin/$(git branch --show-current)~3) # 示例:假设 ahead 3
|
OLD_SHA=$(git rev-parse origin/$(git branch --show-current)~3) # 示例:假设 ahead 3
|
||||||
NEW_SHA=$(git rev-parse HEAD)
|
NEW_SHA=$(git rev-parse HEAD)
|
||||||
|
|
||||||
java -jar /path/to/cache-schema-checker-1.0.0.jar \
|
java -jar /path/to/serialization-schema-checker-1.0.0.jar \
|
||||||
--config .gitea/config/cache-schema-check-config.yaml \
|
--config .gitea/config/serialization-schema-check-config.yaml \
|
||||||
--repo-root . \
|
--repo-root . \
|
||||||
--old-sha "$OLD_SHA" \
|
--old-sha "$OLD_SHA" \
|
||||||
--new-sha "$NEW_SHA" \
|
--new-sha "$NEW_SHA" \
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
> 版本:v0.2
|
> 版本:v0.2
|
||||||
> 日期:2026-07-15
|
> 日期:2026-07-15
|
||||||
> 状态:**方案已落地(含 Kafka),开发未启动**
|
> 状态:**方案已落地(含 Kafka),开发未启动**
|
||||||
> 关联:复用 `cache-schema-checker` 的 Schema 提取、Diff、企微通知与 CI 框架
|
> 关联:复用 `serialization-schema-checker` 的 Schema 提取、Diff、企微通知与 CI 框架
|
||||||
> 业务样本仓:`jnpf-java-cloud`(**RocketMQ + Kafka**)
|
> 业务样本仓:`jnpf-java-cloud`(**RocketMQ + Kafka**)
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -124,7 +124,7 @@ public void handleMessage(String message) {
|
|||||||
|
|
||||||
### 3.1 产品形态
|
### 3.1 产品形态
|
||||||
|
|
||||||
并入现有 `cache-schema-checker`(或后续更名 `serialization-schema-checker`):
|
并入现有 `serialization-schema-checker`:
|
||||||
|
|
||||||
- 同一 CLI / 流水线 / Schema Diff / 企微模板
|
- 同一 CLI / 流水线 / Schema Diff / 企微模板
|
||||||
- 配置增加 `mq_patterns`(含 RocketMQ + Kafka)
|
- 配置增加 `mq_patterns`(含 RocketMQ + Kafka)
|
||||||
|
|||||||
36
docs/实施方案.md
36
docs/实施方案.md
@@ -104,12 +104,12 @@
|
|||||||
schemaCheck 仓库
|
schemaCheck 仓库
|
||||||
├── 开发 Java 分析工具
|
├── 开发 Java 分析工具
|
||||||
├── mvn package 打 fat-jar
|
├── mvn package 打 fat-jar
|
||||||
├── 发布到 Nexus:com.codechecker:cache-schema-checker:{version}
|
├── 发布到 Nexus:com.codechecker:serialization-schema-checker:{version}
|
||||||
└── 提供默认配置模板
|
└── 提供默认配置模板
|
||||||
|
|
||||||
jnpf-java-cloud 仓库
|
jnpf-java-cloud 仓库
|
||||||
├── .gitea/workflows/cache-schema-check.yaml
|
├── .gitea/workflows/serialization-schema-check.yaml
|
||||||
├── .gitea/config/cache-schema-check-config.yaml
|
├── .gitea/config/serialization-schema-check-config.yaml
|
||||||
└── push 时下载 jar 并执行检测
|
└── push 时下载 jar 并执行检测
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -119,11 +119,11 @@ jnpf-java-cloud 仓库
|
|||||||
flowchart TB
|
flowchart TB
|
||||||
subgraph Gitea["Gitea Push Pipeline"]
|
subgraph Gitea["Gitea Push Pipeline"]
|
||||||
A[push 事件] --> B[浅克隆 old/new 提交]
|
A[push 事件] --> B[浅克隆 old/new 提交]
|
||||||
B --> C[下载 cache-schema-checker.jar]
|
B --> C[下载 serialization-schema-checker.jar]
|
||||||
C --> D[java -jar 执行检测]
|
C --> D[java -jar 执行检测]
|
||||||
end
|
end
|
||||||
|
|
||||||
subgraph Checker["cache-schema-checker (JDK 11)"]
|
subgraph Checker["serialization-schema-checker (JDK 11)"]
|
||||||
D --> E[GitDiffScanner]
|
D --> E[GitDiffScanner]
|
||||||
E --> F[RedisWritePointDetector]
|
E --> F[RedisWritePointDetector]
|
||||||
F --> G[JavaSchemaExtractor]
|
F --> G[JavaSchemaExtractor]
|
||||||
@@ -196,8 +196,8 @@ schemaCheck/
|
|||||||
│ ├── resources/fixtures/{tenant,lock,template}/
|
│ ├── resources/fixtures/{tenant,lock,template}/
|
||||||
│ └── java/...
|
│ └── java/...
|
||||||
├── .gitea/
|
├── .gitea/
|
||||||
│ ├── workflows/cache-schema-check.yaml
|
│ ├── workflows/serialization-schema-check.yaml
|
||||||
│ └── config/cache-schema-check-config.yaml
|
│ └── config/serialization-schema-check-config.yaml
|
||||||
└── target/ # 构建产物
|
└── target/ # 构建产物
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -205,11 +205,11 @@ schemaCheck/
|
|||||||
|
|
||||||
```xml
|
```xml
|
||||||
<groupId>com.codechecker</groupId>
|
<groupId>com.codechecker</groupId>
|
||||||
<artifactId>cache-schema-checker</artifactId>
|
<artifactId>serialization-schema-checker</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
```
|
```
|
||||||
|
|
||||||
打包为 **shaded/fat jar**,主类:`com.codechecker.cache.cli.CacheSchemaCheckerMain`
|
打包为 **shaded/fat jar**,主类:`com.codechecker.cache.cli.SerializationSchemaCheckerMain`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -218,8 +218,8 @@ schemaCheck/
|
|||||||
### 6.1 CLI 参数
|
### 6.1 CLI 参数
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
java -jar cache-schema-checker-1.0.0.jar \
|
java -jar serialization-schema-checker-1.0.0.jar \
|
||||||
--config .gitea/config/cache-schema-check-config.yaml \
|
--config .gitea/config/serialization-schema-check-config.yaml \
|
||||||
--repo-root /path/to/jnpf-java-cloud \
|
--repo-root /path/to/jnpf-java-cloud \
|
||||||
--old-sha abc123 \
|
--old-sha abc123 \
|
||||||
--new-sha def456 \
|
--new-sha def456 \
|
||||||
@@ -256,7 +256,7 @@ java -jar cache-schema-checker-1.0.0.jar \
|
|||||||
|
|
||||||
#### Step 1:加载配置
|
#### Step 1:加载配置
|
||||||
|
|
||||||
读取 `cache-schema-check-config.yaml`,合并默认值(见 `docs/配置说明.md`)。
|
读取 `serialization-schema-check-config.yaml`,合并默认值(见 `docs/配置说明.md`)。
|
||||||
|
|
||||||
#### Step 2:Git Diff 扫描
|
#### Step 2:Git Diff 扫描
|
||||||
|
|
||||||
@@ -444,15 +444,15 @@ manual_mappings:
|
|||||||
| 层级 | 位置 | 职责 |
|
| 层级 | 位置 | 职责 |
|
||||||
|------|------|------|
|
|------|------|------|
|
||||||
| 默认配置 | 工具 jar 内 `default-config.yaml` | 检测模式、忽略规则等默认值 |
|
| 默认配置 | 工具 jar 内 `default-config.yaml` | 检测模式、忽略规则等默认值 |
|
||||||
| 业务覆盖 | `jnpf-java-cloud/.gitea/config/cache-schema-check-config.yaml` | mode、notify、include_modules、manual_mappings |
|
| 业务覆盖 | `jnpf-java-cloud/.gitea/config/serialization-schema-check-config.yaml` | mode、notify、include_modules、manual_mappings |
|
||||||
|
|
||||||
合并规则:**业务配置覆盖默认配置**,未声明的项沿用默认值。
|
合并规则:**业务配置覆盖默认配置**,未声明的项沿用默认值。
|
||||||
|
|
||||||
CLI 调用:
|
CLI 调用:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
java -jar cache-schema-checker.jar \
|
java -jar serialization-schema-checker.jar \
|
||||||
--config .gitea/config/cache-schema-check-config.yaml \
|
--config .gitea/config/serialization-schema-check-config.yaml \
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -482,13 +482,13 @@ notify:
|
|||||||
详见 `docs/CI集成说明.md`。核心流程:
|
详见 `docs/CI集成说明.md`。核心流程:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# jnpf-java-cloud/.gitea/workflows/cache-schema-check.yaml(要点)
|
# jnpf-java-cloud/.gitea/workflows/serialization-schema-check.yaml(要点)
|
||||||
# 检出:浅克隆 tip(depth 1)
|
# 检出:浅克隆 tip(depth 1)
|
||||||
# 检测:--old-sha = gitea.event.before,--new-sha = gitea.sha
|
# 检测:--old-sha = gitea.event.before,--new-sha = gitea.sha
|
||||||
# 按需 fetch before 提交对象,覆盖一次 push 的多 commit 累计 diff
|
# 按需 fetch before 提交对象,覆盖一次 push 的多 commit 累计 diff
|
||||||
```
|
```
|
||||||
|
|
||||||
完整模板见 `docs/CI集成说明.md` / `.gitea/workflows/cache-schema-check.yaml`。
|
完整模板见 `docs/CI集成说明.md` / `.gitea/workflows/serialization-schema-check.yaml`。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -600,7 +600,7 @@ notify:
|
|||||||
| # | 决策项 | 结论 |
|
| # | 决策项 | 结论 |
|
||||||
|---|--------|------|
|
|---|--------|------|
|
||||||
| 1 | 阻断范围 | `block` 模式下 **任意结构变更均阻断**(exit 1) |
|
| 1 | 阻断范围 | `block` 模式下 **任意结构变更均阻断**(exit 1) |
|
||||||
| 2 | 发布坐标 | 独立产物 `com.codechecker:cache-schema-checker:1.0.0` |
|
| 2 | 发布坐标 | 独立产物 `com.codechecker:serialization-schema-checker:1.0.0` |
|
||||||
| 3 | 配置归属 | **双层配置**:jar 内 `default-config.yaml` + 业务仓覆盖合并 |
|
| 3 | 配置归属 | **双层配置**:jar 内 `default-config.yaml` + 业务仓覆盖合并 |
|
||||||
| 4 | 上线策略 | 先 `notify` ,稳定后手动切 `block` |
|
| 4 | 上线策略 | 先 `notify` ,稳定后手动切 `block` |
|
||||||
| 5 | 检测范围 | **仅 `src/main/java`**,不扫描测试代码 |
|
| 5 | 检测范围 | **仅 `src/main/java`**,不扫描测试代码 |
|
||||||
|
|||||||
18
docs/配置说明.md
18
docs/配置说明.md
@@ -1,8 +1,8 @@
|
|||||||
# 缓存序列化结构检测 — 配置说明
|
# 序列化结构检测 — 配置说明
|
||||||
|
|
||||||
> **双层配置**:工具 jar 内置 `default-config.yaml`(默认) + 业务仓库 `.gitea/config/cache-schema-check-config.yaml`(覆盖)
|
> **双层配置**:工具 jar 内置 `default-config.yaml`(默认) + 业务仓库 `.gitea/config/serialization-schema-check-config.yaml`(覆盖)
|
||||||
> 工具坐标:`com.codechecker:cache-schema-checker:1.0.0`
|
> 工具坐标:`com.codechecker:serialization-schema-checker:1.0.0`
|
||||||
> 主类:`com.codechecker.cache.cli.CacheSchemaCheckerMain`
|
> 主类:`com.codechecker.cache.cli.SerializationSchemaCheckerMain`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
```text
|
```text
|
||||||
jar 内 default-config.yaml(工具仓维护)
|
jar 内 default-config.yaml(工具仓维护)
|
||||||
↓ 深度合并
|
↓ 深度合并
|
||||||
业务仓 cache-schema-check-config.yaml(业务仓维护)
|
业务仓 serialization-schema-check-config.yaml(业务仓维护)
|
||||||
↓
|
↓
|
||||||
最终生效配置
|
最终生效配置
|
||||||
```
|
```
|
||||||
@@ -23,7 +23,7 @@ jar 内 default-config.yaml(工具仓维护)
|
|||||||
### 1.1 业务仓最小配置示例
|
### 1.1 业务仓最小配置示例
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# jnpf-java-cloud/.gitea/config/cache-schema-check-config.yaml
|
# jnpf-java-cloud/.gitea/config/serialization-schema-check-config.yaml
|
||||||
enabled: true
|
enabled: true
|
||||||
mode: notify
|
mode: notify
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ notify:
|
|||||||
# 无变更时是否也发通知(一般 false)
|
# 无变更时是否也发通知(一般 false)
|
||||||
notify_on_clean: false
|
notify_on_clean: false
|
||||||
# 消息标题前缀
|
# 消息标题前缀
|
||||||
title_prefix: "[缓存结构变更]"
|
title_prefix: "[序列化结构变更]"
|
||||||
|
|
||||||
# 忽略规则
|
# 忽略规则
|
||||||
ignore:
|
ignore:
|
||||||
@@ -182,7 +182,7 @@ mode: block
|
|||||||
| `webhook_url` | string | `""` | 企微机器人 Webhook 完整 URL(优先) |
|
| `webhook_url` | string | `""` | 企微机器人 Webhook 完整 URL(优先) |
|
||||||
| `webhook_env` | string | — | 兼容旧字段;值为 `http` 开头时当作 URL |
|
| `webhook_env` | string | — | 兼容旧字段;值为 `http` 开头时当作 URL |
|
||||||
| `notify_on_clean` | boolean | false | 无变更时是否通知 |
|
| `notify_on_clean` | boolean | false | 无变更时是否通知 |
|
||||||
| `title_prefix` | string | [缓存结构变更] | 消息标题前缀 |
|
| `title_prefix` | string | [序列化结构变更] | 消息标题前缀 |
|
||||||
|
|
||||||
### 3.4 ignore.key_patterns
|
### 3.4 ignore.key_patterns
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ suppressions:
|
|||||||
### 5.3 示例(已解析 key)
|
### 5.3 示例(已解析 key)
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
## [缓存结构变更] jnpf-java-cloud
|
## [序列化结构变更] jnpf-java-cloud
|
||||||
|
|
||||||
> **分支**: code/redis_change_detection_v1.0
|
> **分支**: code/redis_change_detection_v1.0
|
||||||
> **提交**: cedd161c → 67c8a6eb
|
> **提交**: cedd161c → 67c8a6eb
|
||||||
|
|||||||
10
pom.xml
10
pom.xml
@@ -5,12 +5,12 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.codechecker</groupId>
|
<groupId>com.codechecker</groupId>
|
||||||
<artifactId>cache-schema-checker</artifactId>
|
<artifactId>serialization-schema-checker</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>cache-schema-checker</name>
|
<name>serialization-schema-checker</name>
|
||||||
<description>基于 JavaParser 的缓存 value 序列化结构变更检测器</description>
|
<description>基于 JavaParser 的缓存/MQ value 序列化结构变更检测器</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>cache-schema-checker-${project.version}</finalName>
|
<finalName>serialization-schema-checker-${project.version}</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
<transformers>
|
<transformers>
|
||||||
<transformer
|
<transformer
|
||||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
<mainClass>com.codechecker.cache.cli.CacheSchemaCheckerMain</mainClass>
|
<mainClass>com.codechecker.cache.cli.SerializationSchemaCheckerMain</mainClass>
|
||||||
</transformer>
|
</transformer>
|
||||||
<transformer
|
<transformer
|
||||||
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ import java.util.concurrent.Callable;
|
|||||||
/**
|
/**
|
||||||
* 命令行入口。退出码:0 通过 / 1 阻断 / 2 执行错误。
|
* 命令行入口。退出码:0 通过 / 1 阻断 / 2 执行错误。
|
||||||
*/
|
*/
|
||||||
@Command(name = "cache-schema-checker",
|
@Command(name = "serialization-schema-checker",
|
||||||
mixinStandardHelpOptions = true,
|
mixinStandardHelpOptions = true,
|
||||||
version = "cache-schema-checker 1.0.0",
|
version = "serialization-schema-checker 1.0.0",
|
||||||
description = "检测两次提交间缓存 value 序列化结构变更并通过企微机器人通知。")
|
description = "检测两次提交间缓存/MQ 等 value 序列化结构变更并通过企微机器人通知。")
|
||||||
public class CacheSchemaCheckerMain implements Callable<Integer> {
|
public class SerializationSchemaCheckerMain implements Callable<Integer> {
|
||||||
|
|
||||||
@Option(names = "--config", required = true, description = "业务仓库检测配置文件路径")
|
@Option(names = "--config", required = true, description = "业务仓库检测配置文件路径")
|
||||||
private Path configPath;
|
private Path configPath;
|
||||||
@@ -56,12 +56,12 @@ public class CacheSchemaCheckerMain implements Callable<Integer> {
|
|||||||
CheckerConfig config = ConfigLoader.load(configPath);
|
CheckerConfig config = ConfigLoader.load(configPath);
|
||||||
|
|
||||||
if (!config.isEnabled()) {
|
if (!config.isEnabled()) {
|
||||||
System.out.println("[cache-schema-checker] 总开关 enabled=false,跳过检测。");
|
System.out.println("[serialization-schema-checker] 总开关 enabled=false,跳过检测。");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldSha == null || oldSha.trim().isEmpty()) {
|
if (oldSha == null || oldSha.trim().isEmpty()) {
|
||||||
System.out.println("[cache-schema-checker] 无对比基准提交,跳过检测。");
|
System.out.println("[serialization-schema-checker] 无对比基准提交,跳过检测。");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,6 @@ public class CacheSchemaCheckerMain implements Callable<Integer> {
|
|||||||
report.setRepository(repository != null ? repository : root.getFileName().toString());
|
report.setRepository(repository != null ? repository : root.getFileName().toString());
|
||||||
|
|
||||||
ReportBuilder builder = new ReportBuilder(config.getNotify().getTitlePrefix());
|
ReportBuilder builder = new ReportBuilder(config.getNotify().getTitlePrefix());
|
||||||
// CI:字段明细 + 完整企微 Markdown
|
|
||||||
System.out.println(builder.toConsole(report));
|
System.out.println(builder.toConsole(report));
|
||||||
|
|
||||||
boolean shouldNotify = config.getNotify().isEnabled()
|
boolean shouldNotify = config.getNotify().isEnabled()
|
||||||
@@ -84,24 +83,24 @@ public class CacheSchemaCheckerMain implements Callable<Integer> {
|
|||||||
String webhook = config.getNotify().getWebhookUrl();
|
String webhook = config.getNotify().getWebhookUrl();
|
||||||
List<String> messages = builder.toWeComMessages(report);
|
List<String> messages = builder.toWeComMessages(report);
|
||||||
int ok = new WeComNotifier().sendMarkdownMessages(webhook, messages);
|
int ok = new WeComNotifier().sendMarkdownMessages(webhook, messages);
|
||||||
System.out.println("[cache-schema-checker] 企微通知发送: "
|
System.out.println("[serialization-schema-checker] 企微通知发送: "
|
||||||
+ ok + "/" + messages.size()
|
+ ok + "/" + messages.size()
|
||||||
+ (messages.size() > 1 ? "(已按 key 拆分)" : ""));
|
+ (messages.size() > 1 ? "(已按 key 拆分)" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (report.isBlocked()) {
|
if (report.isBlocked()) {
|
||||||
System.out.println("[cache-schema-checker] block 模式命中,流水线将被阻断(exit 1)。");
|
System.out.println("[serialization-schema-checker] block 模式命中,流水线将被阻断(exit 1)。");
|
||||||
}
|
}
|
||||||
return report.getExitCode();
|
return report.getExitCode();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("[cache-schema-checker] 执行错误: " + e.getMessage());
|
System.err.println("[serialization-schema-checker] 执行错误: " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = new CommandLine(new CacheSchemaCheckerMain()).execute(args);
|
int exitCode = new CommandLine(new SerializationSchemaCheckerMain()).execute(args);
|
||||||
System.exit(exitCode);
|
System.exit(exitCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ public class CheckerConfig {
|
|||||||
/** 企微机器人 Webhook 完整 URL */
|
/** 企微机器人 Webhook 完整 URL */
|
||||||
private String webhookUrl = "";
|
private String webhookUrl = "";
|
||||||
private boolean notifyOnClean = false;
|
private boolean notifyOnClean = false;
|
||||||
private String titlePrefix = "[缓存结构变更]";
|
private String titlePrefix = "[序列化结构变更]";
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled;
|
return enabled;
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public final class ConfigLoader {
|
|||||||
n.setEnabled(bool(notify, "enabled", true));
|
n.setEnabled(bool(notify, "enabled", true));
|
||||||
n.setWebhookUrl(resolveWebhookUrl(notify));
|
n.setWebhookUrl(resolveWebhookUrl(notify));
|
||||||
n.setNotifyOnClean(bool(notify, "notify_on_clean", false));
|
n.setNotifyOnClean(bool(notify, "notify_on_clean", false));
|
||||||
n.setTitlePrefix(str(notify, "title_prefix", "[缓存结构变更]"));
|
n.setTitlePrefix(str(notify, "title_prefix", "[序列化结构变更]"));
|
||||||
|
|
||||||
Map<String, Object> ignore = asMap(map.get("ignore"));
|
Map<String, Object> ignore = asMap(map.get("ignore"));
|
||||||
CheckerConfig.Ignore ig = config.getIgnore();
|
CheckerConfig.Ignore ig = config.getIgnore();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class ReportBuilder {
|
|||||||
private final String titlePrefix;
|
private final String titlePrefix;
|
||||||
|
|
||||||
public ReportBuilder(String titlePrefix) {
|
public ReportBuilder(String titlePrefix) {
|
||||||
this.titlePrefix = titlePrefix == null ? "[缓存结构变更]" : titlePrefix;
|
this.titlePrefix = titlePrefix == null ? "[序列化结构变更]" : titlePrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,7 +63,7 @@ public class ReportBuilder {
|
|||||||
String header = buildHeader(report);
|
String header = buildHeader(report);
|
||||||
List<String> bodies = buildKeyBodies(report);
|
List<String> bodies = buildKeyBodies(report);
|
||||||
if (bodies.isEmpty()) {
|
if (bodies.isEmpty()) {
|
||||||
return Collections.singletonList(header + "未检测到缓存序列化结构变更。\n");
|
return Collections.singletonList(header + "未检测到序列化结构变更。\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder combined = new StringBuilder(header);
|
StringBuilder combined = new StringBuilder(header);
|
||||||
@@ -182,7 +182,7 @@ public class ReportBuilder {
|
|||||||
public String toConsole(CheckReport report) {
|
public String toConsole(CheckReport report) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (!report.hasChanges()) {
|
if (!report.hasChanges()) {
|
||||||
sb.append("未检测到缓存序列化结构变更。\n");
|
sb.append("未检测到序列化结构变更。\n");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# cache-schema-checker 内置默认配置
|
# serialization-schema-checker 内置默认配置
|
||||||
# 业务仓库通过 --config 指定的配置会与本文件深度合并(业务配置优先)。
|
# 业务仓库通过 --config 指定的配置会与本文件深度合并(业务配置优先)。
|
||||||
|
|
||||||
# 总开关:false 时不执行检测、不发通知、流水线直接通过
|
# 总开关:false 时不执行检测、不发通知、流水线直接通过
|
||||||
@@ -19,7 +19,7 @@ notify:
|
|||||||
enabled: true
|
enabled: true
|
||||||
webhook_url: ""
|
webhook_url: ""
|
||||||
notify_on_clean: false
|
notify_on_clean: false
|
||||||
title_prefix: "[缓存结构变更]"
|
title_prefix: "[序列化结构变更]"
|
||||||
|
|
||||||
# 忽略规则
|
# 忽略规则
|
||||||
ignore:
|
ignore:
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class ReportBuilderTest {
|
|||||||
key.getFieldDetails().add(addedErr);
|
key.getFieldDetails().add(addedErr);
|
||||||
report.getKeyChanges().add(key);
|
report.getKeyChanges().add(key);
|
||||||
|
|
||||||
String md = new ReportBuilder("[缓存结构变更]").toMarkdown(report);
|
String md = new ReportBuilder("[序列化结构变更]").toMarkdown(report);
|
||||||
|
|
||||||
assertTrue(md.contains("- Key --> `saas:period-config:migration:current`"));
|
assertTrue(md.contains("- Key --> `saas:period-config:migration:current`"));
|
||||||
assertFalse(md.contains("(key 无法解析)"));
|
assertFalse(md.contains("(key 无法解析)"));
|
||||||
@@ -133,7 +133,7 @@ class ReportBuilderTest {
|
|||||||
key.getFieldDetails().add(detail);
|
key.getFieldDetails().add(detail);
|
||||||
report.getKeyChanges().add(key);
|
report.getKeyChanges().add(key);
|
||||||
|
|
||||||
String console = new ReportBuilder("[缓存结构变更]").toConsole(report);
|
String console = new ReportBuilder("[序列化结构变更]").toConsole(report);
|
||||||
assertTrue(console.contains("======== 字段明细 ========"));
|
assertTrue(console.contains("======== 字段明细 ========"));
|
||||||
assertTrue(console.contains("**删除字段**: x"));
|
assertTrue(console.contains("**删除字段**: x"));
|
||||||
assertTrue(console.contains("<font color=\"warning\">\"x\":\"\"</font>"));
|
assertTrue(console.contains("<font color=\"warning\">\"x\":\"\"</font>"));
|
||||||
@@ -161,7 +161,7 @@ class ReportBuilderTest {
|
|||||||
key.getFieldDetails().add(added);
|
key.getFieldDetails().add(added);
|
||||||
report.getKeyChanges().add(key);
|
report.getKeyChanges().add(key);
|
||||||
|
|
||||||
String md = new ReportBuilder("[缓存结构变更]").toMarkdown(report);
|
String md = new ReportBuilder("[序列化结构变更]").toMarkdown(report);
|
||||||
assertTrue(md.contains("- Key --> `req.getKey()` <font color=\"comment\">(key 无法解析)</font>"));
|
assertTrue(md.contains("- Key --> `req.getKey()` <font color=\"comment\">(key 无法解析)</font>"));
|
||||||
assertTrue(md.contains("> **位置**: `ClockInXxxService#export:128`"));
|
assertTrue(md.contains("> **位置**: `ClockInXxxService#export:128`"));
|
||||||
assertTrue(md.contains("> **类型**: `List<ClockInExportVo>`"));
|
assertTrue(md.contains("> **类型**: `List<ClockInExportVo>`"));
|
||||||
@@ -185,7 +185,7 @@ class ReportBuilderTest {
|
|||||||
report.getKeyChanges().add(simpleKey("k-a", "{\"a\":\"\"}", "{\"a\":\"\",\"x\":\"\"}", "x"));
|
report.getKeyChanges().add(simpleKey("k-a", "{\"a\":\"\"}", "{\"a\":\"\",\"x\":\"\"}", "x"));
|
||||||
report.getKeyChanges().add(simpleKey("k-b", "{\"b\":\"\"}", "{\"b\":\"\",\"y\":\"\"}", "y"));
|
report.getKeyChanges().add(simpleKey("k-b", "{\"b\":\"\"}", "{\"b\":\"\",\"y\":\"\"}", "y"));
|
||||||
|
|
||||||
List<String> messages = new ReportBuilder("[缓存结构变更]").toWeComMessages(report);
|
List<String> messages = new ReportBuilder("[序列化结构变更]").toWeComMessages(report);
|
||||||
assertEquals(1, messages.size());
|
assertEquals(1, messages.size());
|
||||||
assertTrue(messages.get(0).contains("k-a"));
|
assertTrue(messages.get(0).contains("k-a"));
|
||||||
assertTrue(messages.get(0).contains("k-b"));
|
assertTrue(messages.get(0).contains("k-b"));
|
||||||
@@ -200,7 +200,7 @@ class ReportBuilderTest {
|
|||||||
report.getKeyChanges().add(simpleKey("fat-key-1", fat, fat + "1", null));
|
report.getKeyChanges().add(simpleKey("fat-key-1", fat, fat + "1", null));
|
||||||
report.getKeyChanges().add(simpleKey("fat-key-2", fat, fat + "2", null));
|
report.getKeyChanges().add(simpleKey("fat-key-2", fat, fat + "2", null));
|
||||||
|
|
||||||
List<String> messages = new ReportBuilder("[缓存结构变更]").toWeComMessages(report);
|
List<String> messages = new ReportBuilder("[序列化结构变更]").toWeComMessages(report);
|
||||||
assertEquals(2, messages.size(), "超长应按 key 拆成 2 条");
|
assertEquals(2, messages.size(), "超长应按 key 拆成 2 条");
|
||||||
assertTrue(messages.get(0).contains("fat-key-1"));
|
assertTrue(messages.get(0).contains("fat-key-1"));
|
||||||
assertFalse(messages.get(0).contains("fat-key-2"));
|
assertFalse(messages.get(0).contains("fat-key-2"));
|
||||||
@@ -209,10 +209,10 @@ class ReportBuilderTest {
|
|||||||
assertTrue(ReportBuilder.utf8Bytes(messages.get(0)) <= ReportBuilder.WECOM_MARKDOWN_MAX_BYTES);
|
assertTrue(ReportBuilder.utf8Bytes(messages.get(0)) <= ReportBuilder.WECOM_MARKDOWN_MAX_BYTES);
|
||||||
assertTrue(ReportBuilder.utf8Bytes(messages.get(1)) <= ReportBuilder.WECOM_MARKDOWN_MAX_BYTES);
|
assertTrue(ReportBuilder.utf8Bytes(messages.get(1)) <= ReportBuilder.WECOM_MARKDOWN_MAX_BYTES);
|
||||||
// 抬头在每条中重复
|
// 抬头在每条中重复
|
||||||
assertTrue(messages.get(0).contains("## [缓存结构变更] jnpf-java-cloud"));
|
assertTrue(messages.get(0).contains("## [序列化结构变更] jnpf-java-cloud"));
|
||||||
assertTrue(messages.get(1).contains("## [缓存结构变更] jnpf-java-cloud"));
|
assertTrue(messages.get(1).contains("## [序列化结构变更] jnpf-java-cloud"));
|
||||||
|
|
||||||
String console = new ReportBuilder("[缓存结构变更]").toConsole(report);
|
String console = new ReportBuilder("[序列化结构变更]").toConsole(report);
|
||||||
assertTrue(console.contains("超长已按 key 拆为 2 条"));
|
assertTrue(console.contains("超长已按 key 拆为 2 条"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user