From 9c1f9de9c113d0b60aca0cba8edf4106cfee9ac1 Mon Sep 17 00:00:00 2001 From: Hong Jiarong Date: Thu, 30 Jul 2026 13:12:08 +0800 Subject: [PATCH] fix(hub): give integration tests skill-store root and portable DB URL Admin routes always construct OrganizationAgentConfiguration via readSkillStoreRoot(); CI and local runs without HUB_SKILL_STORE_ROOT failed open. Seed a tmp root when unset. Also make preflight CLI tests honor DATABASE_URL and set the skill-store env in hub-check. --- .gitea/workflows/hub-check.yml | 1 + .../integration/deployment-preflight-cli.test.ts | 4 +++- hub/test/integration/helpers.ts | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/hub-check.yml b/.gitea/workflows/hub-check.yml index 45d8f7a..a6ea8ce 100644 --- a/.gitea/workflows/hub-check.yml +++ b/.gitea/workflows/hub-check.yml @@ -154,6 +154,7 @@ jobs: --exclude test/integration/agent-sandbox-linux.test.ts env: DATABASE_URL: postgresql://paradigm:paradigm@postgres:5432/cph_hub_test + HUB_SKILL_STORE_ROOT: /tmp/cph-hub-check-skills # Real-model tests are opt-in: set RUN_REAL_MODEL_TESTS=true and provide # OPENROUTER_API_KEY when a branch should hit live OpenRouter. diff --git a/hub/test/integration/deployment-preflight-cli.test.ts b/hub/test/integration/deployment-preflight-cli.test.ts index 97726aa..11a4e02 100644 --- a/hub/test/integration/deployment-preflight-cli.test.ts +++ b/hub/test/integration/deployment-preflight-cli.test.ts @@ -16,7 +16,9 @@ import { ProviderConnectionService } from "../../src/connections/providerConnect import { FeishuApplicationConnectionService } from "../../src/connections/feishuApplicationConnections.js"; const execFileAsync = promisify(execFile); -const TEST_DATABASE_URL = "postgresql://paradigm:paradigm@127.0.0.1:5432/cph_hub_test"; +const TEST_DATABASE_URL = + process.env.DATABASE_URL?.trim() || + "postgresql://paradigm:paradigm@127.0.0.1:5432/cph_hub_test"; describe("deployment preflight CLI", { timeout: 20_000 }, () => { let root: string; diff --git a/hub/test/integration/helpers.ts b/hub/test/integration/helpers.ts index dd941d2..dc3efb6 100644 --- a/hub/test/integration/helpers.ts +++ b/hub/test/integration/helpers.ts @@ -5,6 +5,8 @@ * FeishuRuntime (sendText/sendCard are no-ops that record calls), and a mock * AI SDK model factory (doGenerate() returns canned responses - no network). */ +import { mkdirSync } from "node:fs"; +import { tmpdir } from "node:os"; import { PrismaClient } from "@prisma/client"; import type { FastifyBaseLogger } from "fastify"; import type { @@ -19,6 +21,18 @@ import type { FeishuRuntime } from "../../src/feishu/client.js"; import type { ModelFactory } from "../../src/agent/runner.js"; import { LocalSecretEnvelope } from "../../src/security/secretEnvelope.js"; + +// Admin routes and agent-config tests need a skill store root; seed once for +// the whole vitest process when CI/dev didn't set one. +if ( + (process.env.HUB_SKILL_STORE_ROOT === undefined || process.env.HUB_SKILL_STORE_ROOT.trim() === "") && + (process.env.XDG_STATE_HOME === undefined || process.env.XDG_STATE_HOME.trim() === "") +) { + process.env.HUB_SKILL_STORE_ROOT = `${tmpdir()}/cph-test-skills`; +} +if (process.env.HUB_SKILL_STORE_ROOT !== undefined && process.env.HUB_SKILL_STORE_ROOT.trim() !== "") { + mkdirSync(process.env.HUB_SKILL_STORE_ROOT, { recursive: true }); +} export const TEST_DATABASE_URL = process.env.DATABASE_URL?.trim() || "postgresql://paradigm:paradigm@127.0.0.1:5432/cph_hub_test";