From 6aab14bd1ea33f4b370e098e90372115acc1128e Mon Sep 17 00:00:00 2001 From: dongzi Date: Mon, 13 Jul 2026 15:41:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF=E8=A1=A5?= =?UTF-8?q?=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/config/redis-schema-check-config.yaml | 40 ++++++++++ .gitea/workflows/redis-schema-check.yaml | 81 ++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 .gitea/config/redis-schema-check-config.yaml create mode 100644 .gitea/workflows/redis-schema-check.yaml diff --git a/.gitea/config/redis-schema-check-config.yaml b/.gitea/config/redis-schema-check-config.yaml new file mode 100644 index 0000000..57f77e3 --- /dev/null +++ b/.gitea/config/redis-schema-check-config.yaml @@ -0,0 +1,40 @@ +# ============================================================ +# Redis 序列化结构变更检测 — 业务仓库配置 +# ============================================================ +# 说明: +# - 本文件为业务覆盖配置,会与 jar 内 default-config.yaml 深度合并 +# - 未声明的项沿用工具内置默认值(忽略规则、检测模式等) +# - 上线策略:先 notify 观察 1 周,稳定后改为 mode: block + +# 运行模式 +# notify - 仅通知,不阻断流水线 +# block - 按 block_severities 阻断流水线(exit 1) +mode: notify + +# block 模式下触发阻断的严重级别(P0/P1/P2 全部阻断) +block_severities: + - P0 + - P1 + - P2 + +# 通知配置 +notify: + enabled: true + webhook_env: WECOM_ROBOT_WEBHOOK + notify_on_clean: false + title_prefix: "[Redis结构变更]" + +# 观察期:先只扫描 jnpf-tenant 模块,稳定后改为 include_modules: [] +include_modules: + - jnpf-tenant + +# 人工补充映射(自动推断不准时使用) +manual_mappings: + - id: tenant-db-content + writer_method: "jnpf.util.TenantDbContentCacheHelper#cacheSuccess" + key_pattern: "tenant:db:content:*" + value_type: "jnpf.util.TenantDbContentCacheHelper.CacheEnvelope" + description: "租户库信息缓存" + +# 已知误报抑制(按需添加) +suppressions: [] diff --git a/.gitea/workflows/redis-schema-check.yaml b/.gitea/workflows/redis-schema-check.yaml new file mode 100644 index 0000000..4ffc517 --- /dev/null +++ b/.gitea/workflows/redis-schema-check.yaml @@ -0,0 +1,81 @@ +name: Redis序列化结构检查 +run-name: ${{ gitea.actor }}的Redis结构检查 + +on: + push: + workflow_dispatch: + +env: + # redis-schema-checker 私库坐标:com.codechecker:redis-schema-checker:1.0.0 + REDIS_SCHEMA_CHECKER_VERSION: "1.0.0" + REDIS_SCHEMA_CHECKER_REPO_URL: "http://192.168.3.25:18081/nexus/repository/maven-releases" + +jobs: + redis-schema-check: + if: ${{ gitea.ref != 'refs/heads/pre' && gitea.ref != 'refs/heads/dev' && gitea.ref != 'refs/heads/master-2.0' }} + runs-on: jdk11 + steps: + # 浅克隆:仅需 HEAD 与 HEAD~1,避免全量拉取 + # 指定 --branch 确保非默认分支推送时也能正确检出 gitea.sha + - name: 检出代码 + run: | + git config --global http.sslVerify false + 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: | + if [ ! -f .gitea/config/redis-schema-check-config.yaml ]; then + echo "错误: 缺少 .gitea/config/redis-schema-check-config.yaml" + exit 1 + fi + + - name: 从 Nexus 私库下载 redis-schema-checker + run: | + GROUP_PATH="com/codechecker/redis-schema-checker" + JAR_NAME="redis-schema-checker-${REDIS_SCHEMA_CHECKER_VERSION}.jar" + JAR_URL="${REDIS_SCHEMA_CHECKER_REPO_URL}/${GROUP_PATH}/${REDIS_SCHEMA_CHECKER_VERSION}/${JAR_NAME}" + JAR_PATH="/tmp/${JAR_NAME}" + + echo "下载: ${JAR_URL}" + if command -v curl >/dev/null 2>&1; then + curl -fsSL -o "${JAR_PATH}" "${JAR_URL}" + elif command -v wget >/dev/null 2>&1; then + wget -q -O "${JAR_PATH}" "${JAR_URL}" + else + echo "错误: Runner 缺少 curl 或 wget,无法从 Nexus 下载 jar" + exit 1 + fi + + if [ ! -s "${JAR_PATH}" ]; then + echo "错误: 下载失败或文件为空: ${JAR_PATH}" + exit 1 + fi + + ls -lh "${JAR_PATH}" + + - name: 验证 JDK + run: | + echo "Java: $(java -version 2>&1 | head -1)" + + - name: 执行 Redis 序列化结构检测 + env: + WECOM_ROBOT_WEBHOOK: ${{ secrets.WECOM_ROBOT_WEBHOOK }} + run: | + OLD_SHA=$(git rev-parse HEAD~1 2>/dev/null || echo "") + if [ -z "$OLD_SHA" ]; then + echo "首次提交,跳过检测" + exit 0 + fi + + COMMIT_TIME=$(git log -1 --format=%cd --date=format:'%Y-%m-%d %H:%M:%S') + + java -jar "/tmp/redis-schema-checker-${REDIS_SCHEMA_CHECKER_VERSION}.jar" \ + --config .gitea/config/redis-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 "$COMMIT_TIME"