feat(cicd): add warning-only feature config validation

This commit is contained in:
Codex
2026-07-14 04:46:01 +02:00
parent 7eebc513b2
commit 90e5ad8e89
38 changed files with 1160 additions and 493 deletions
@@ -11,101 +11,28 @@ afterEach(() => {
while (roots.length > 0) rmSync(roots.pop()!, { recursive: true, force: true });
});
test("accepts the complete transactional projection capability env", () => {
const fixture = createFixture();
const result = runVerify(fixture.root);
expect(result.status).toBe(0);
expect(result.stderr).toContain('"code-agent-runtime-kafka-event-bridge-enabled"');
});
test("fails closed when a required workload capability env is missing", () => {
const fixture = createFixture({ omitWebEnv: "HWLAB_WORKBENCH_PROJECTION_REALTIME_ENABLED" });
const result = runVerify(fixture.root);
expect(result.status).toBe(48);
expect(result.stderr).toContain('"reason":"code-agent-runtime-capability-env-invalid"');
expect(result.stderr).toContain('"name":"HWLAB_WORKBENCH_PROJECTION_REALTIME_ENABLED"');
});
test("fails closed when a required workload was not matched", () => {
const fixture = createFixture({ omitWebWorkload: true });
const result = runVerify(fixture.root);
expect(result.status).toBe(48);
expect(result.stderr).toContain('"reason":"code-agent-runtime-workload-missing"');
expect(result.stderr).toContain('"hwlab-cloud-web"');
});
test("fails closed when the transactional projection authority is incomplete", () => {
const fixture = createFixture({ featureOverrides: { projectionOutboxRelay: false } });
const result = runVerify(fixture.root);
expect(result.status).toBe(48);
expect(result.stderr).toContain('"reason":"kafka-event-bridge-authority-invalid"');
expect(result.stderr).toContain('"projectionOutboxRelay"');
});
function createFixture(options: { omitWebEnv?: string; omitWebWorkload?: boolean; featureOverrides?: Record<string, boolean> } = {}) {
test("architecture capability env and workload matches are not runtime GitOps gates", () => {
const root = mkdtempSync(join(tmpdir(), "runtime-gitops-verify-"));
roots.push(root);
const runtimeDir = join(root, "runtime");
mkdirSync(runtimeDir);
writeFileSync(join(root, "overlay.json"), JSON.stringify(overlay(options.featureOverrides)));
writeFileSync(join(runtimeDir, "cloud-api.yaml"), deploymentYaml("hwlab-cloud-api", cloudApiEnv()));
if (!options.omitWebWorkload) {
writeFileSync(join(runtimeDir, "cloud-web.yaml"), deploymentYaml("hwlab-cloud-web", cloudWebEnv().filter(([name]) => name !== options.omitWebEnv)));
}
return { root };
}
mkdirSync(join(root, "runtime"));
writeFileSync(join(root, "runtime", "unrelated.yaml"), "apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: unrelated\n");
writeFileSync(join(root, "overlay.json"), JSON.stringify({
runtimePath: "runtime",
codeAgentRuntime: {
enabled: true,
kafkaEventBridge: { enabled: true },
},
}));
function runVerify(root: string) {
return spawnSync(process.execPath, [script], {
const result = spawnSync(process.execPath, [script], {
cwd: root,
env: { ...process.env, UNIDESK_RUNTIME_GITOPS_OVERLAY_FILE: join(root, "overlay.json") },
encoding: "utf8",
});
}
function overlay(featureOverrides: Record<string, boolean> = {}) {
return {
runtimePath: "runtime",
codeAgentRuntime: {
enabled: true,
kafkaEventBridge: {
enabled: true,
features: {
directPublish: false,
liveKafkaSse: false,
kafkaRefreshReplay: false,
transactionalProjector: true,
projectionOutboxRelay: true,
projectionRealtime: true,
...featureOverrides,
},
},
},
};
}
function cloudApiEnv(): Array<[string, string]> {
return [
["HWLAB_KAFKA_ENABLED", "true"],
["HWLAB_KAFKA_AGENTRUN_EVENT_CONSUME_ENABLED", "true"],
["HWLAB_KAFKA_DIRECT_PUBLISH_ENABLED", "false"],
["HWLAB_WORKBENCH_LIVE_KAFKA_SSE_ENABLED", "false"],
["HWLAB_WORKBENCH_KAFKA_REFRESH_REPLAY_ENABLED", "false"],
["HWLAB_KAFKA_TRANSACTIONAL_PROJECTOR_ENABLED", "true"],
["HWLAB_KAFKA_PROJECTION_OUTBOX_RELAY_ENABLED", "true"],
["HWLAB_WORKBENCH_PROJECTION_REALTIME_ENABLED", "true"],
];
}
function cloudWebEnv(): Array<[string, string]> {
return [
["HWLAB_WORKBENCH_LIVE_KAFKA_SSE_ENABLED", "false"],
["HWLAB_WORKBENCH_KAFKA_REFRESH_REPLAY_ENABLED", "false"],
["HWLAB_WORKBENCH_PROJECTION_REALTIME_ENABLED", "true"],
];
}
function deploymentYaml(name: string, env: Array<[string, string]>) {
const envYaml = env.map(([envName, value]) => ` - name: ${envName}\n value: "${value}"`).join("\n");
return `apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: ${name}\n labels:\n app.kubernetes.io/name: ${name}\nspec:\n template:\n spec:\n containers:\n - name: ${name}\n env:\n${envYaml}\n`;
}
expect(result.status).toBe(0);
expect(result.stderr).toContain('"code-agent-runtime-kafka-event-bridge-enabled"');
expect(result.stderr).not.toContain("capability-env-invalid");
expect(result.stderr).not.toContain("workload-missing");
expect(result.stderr).not.toContain("authority-invalid");
});