feat: 1、流水线总开关配置 2、删除p0p1p2级别阻断
All checks were successful
Redis序列化结构检查 / redis-schema-check (push) Has been skipped
All checks were successful
Redis序列化结构检查 / redis-schema-check (push) Has been skipped
This commit is contained in:
@@ -330,16 +330,7 @@ public class SchemaCheckAnalyzer {
|
||||
report.getChanges().addAll(changes);
|
||||
report.getKeyChanges().addAll(keyChanges.values());
|
||||
|
||||
boolean blocked = false;
|
||||
if (config.isBlockMode()) {
|
||||
Set<String> blockSev = new HashSet<>(config.getBlockSeverities());
|
||||
for (SchemaChange c : changes) {
|
||||
if (blockSev.contains(c.getSeverity().name())) {
|
||||
blocked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean blocked = config.isBlockMode() && !changes.isEmpty();
|
||||
report.setBlocked(blocked);
|
||||
report.setExitCode(blocked ? 1 : 0);
|
||||
return report;
|
||||
|
||||
@@ -55,6 +55,11 @@ public class RedisSchemaCheckerMain implements Callable<Integer> {
|
||||
try {
|
||||
CheckerConfig config = ConfigLoader.load(configPath);
|
||||
|
||||
if (!config.isEnabled()) {
|
||||
System.out.println("[redis-schema-checker] 总开关 enabled=false,跳过检测。");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (oldSha == null || oldSha.trim().isEmpty()) {
|
||||
System.out.println("[redis-schema-checker] 无对比基准提交,跳过检测。");
|
||||
return 0;
|
||||
|
||||
@@ -10,11 +10,12 @@ import java.util.Map;
|
||||
*/
|
||||
public class CheckerConfig {
|
||||
|
||||
/** 总开关:false 时跳过检测与通知(流水线 exit 0) */
|
||||
private boolean enabled = true;
|
||||
|
||||
/** notify | block */
|
||||
private String mode = "notify";
|
||||
|
||||
private List<String> blockSeverities = new ArrayList<>();
|
||||
|
||||
private boolean scanTestSources = false;
|
||||
|
||||
private List<String> sourceRoots = new ArrayList<>();
|
||||
@@ -231,6 +232,14 @@ public class CheckerConfig {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return mode;
|
||||
}
|
||||
@@ -239,14 +248,6 @@ public class CheckerConfig {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public List<String> getBlockSeverities() {
|
||||
return blockSeverities;
|
||||
}
|
||||
|
||||
public void setBlockSeverities(List<String> blockSeverities) {
|
||||
this.blockSeverities = blockSeverities;
|
||||
}
|
||||
|
||||
public boolean isScanTestSources() {
|
||||
return scanTestSources;
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ public final class ConfigLoader {
|
||||
private static CheckerConfig bind(Map<String, Object> map) {
|
||||
CheckerConfig config = new CheckerConfig();
|
||||
|
||||
config.setEnabled(bool(map, "enabled", true));
|
||||
config.setMode(str(map, "mode", "notify"));
|
||||
config.setBlockSeverities(strList(map.get("block_severities")));
|
||||
config.setScanTestSources(bool(map, "scan_test_sources", false));
|
||||
config.setSourceRoots(strList(map.get("source_roots")));
|
||||
config.setIncludeModules(strList(map.get("include_modules")));
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
# redis-schema-checker 内置默认配置
|
||||
# 业务仓库通过 --config 指定的配置会与本文件深度合并(业务配置优先)。
|
||||
|
||||
# 运行模式:notify(仅通知)| block(按 block_severities 阻断,exit 1)
|
||||
mode: notify
|
||||
# 总开关:false 时不执行检测、不发通知、流水线直接通过
|
||||
enabled: true
|
||||
|
||||
# block 模式下触发阻断的严重级别(默认全部阻断)
|
||||
block_severities:
|
||||
- P0
|
||||
- P1
|
||||
- P2
|
||||
# 运行模式:notify(仅通知)| block(检测到结构变更即阻断,exit 1)
|
||||
mode: notify
|
||||
|
||||
# 是否扫描测试代码(第一版固定 false)
|
||||
scan_test_sources: false
|
||||
|
||||
Reference in New Issue
Block a user