From cc9050d7cb866fcaaa675e86069ad3b1e634e3aa Mon Sep 17 00:00:00 2001 From: Xetera Date: Thu, 18 Jun 2026 20:05:23 +0300 Subject: [PATCH 1/2] feat: push schema from CI runs --- src/main.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main.ts b/src/main.ts index 7635bf4..fda1ea3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,6 +19,7 @@ import { Remote } from "./remote/remote.ts"; import { ConnectionManager } from "./sync/connection-manager.ts"; import { PgbadgerSource } from "./sql/pgbadger.ts"; import type { RecentQuerySource } from "./sql/recent-query.ts"; +import type { FullSchema } from "@query-doctor/core"; async function runInCI( targetPostgresUrl: Connectable, @@ -47,6 +48,17 @@ async function runInCI( log.warn(`API connection broken during CI run: ${err}`, "main"); }); + // `Runner.build` triggers `remote.syncFrom`, which emits `schemaSynced` with + // the schema dumped from the source DB. CI doesn't wire up `hookUpApiReporter` + // (that's the persistent-server path), so capture the schema here and push it + // explicitly. We await the push before `disposeApi` so the short-lived CI + // process doesn't exit before the WS write flushes. + let syncedSchema: FullSchema | undefined; + const onSchemaSynced = (schema: FullSchema) => { + syncedSchema = schema; + }; + remote.on("schemaSynced", onSchemaSynced); + try { const config = repo ? await api.getRepoConfig(repo, branch).catch( @@ -81,6 +93,12 @@ async function runInCI( await runner.close(); } + if (syncedSchema) { + await api.pushSchema(JSON.parse(JSON.stringify(syncedSchema))).catch((err) => { + log.warn(`Failed to push schema: ${err}`, "main"); + }); + } + const queries = buildQueries(allResults, config); // POST to Site API first so we get the run ID (for baseline exclusion) and @@ -198,6 +216,7 @@ async function runInCI( } } } finally { + remote.off("schemaSynced", onSchemaSynced); disposeApi(); } } From 2cd5a19464d493c20c1c83641a255a7e2ad6d320 Mon Sep 17 00:00:00 2001 From: Xetera Date: Thu, 18 Jun 2026 20:05:31 +0300 Subject: [PATCH 2/2] chore: bump @query-doctor/core --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7c47db9..86738bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@libpg-query/parser": "^17.6.3", "@opentelemetry/api": "^1.9.0", "@pgsql/types": "^17.6.2", - "@query-doctor/core": "^0.10.3", + "@query-doctor/core": "^0.10.4", "async-sema": "^3.1.1", "capnweb": "^0.7.0", "dedent": "^1.7.1", @@ -1187,9 +1187,9 @@ "license": "BSD-3-Clause" }, "node_modules/@query-doctor/core": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/@query-doctor/core/-/core-0.10.3.tgz", - "integrity": "sha512-q+FGoA1EsaDPi1EpZ1JV68g2FPkb0BpPVJop3OJwVsZ16RMfNLG+vk4ekedaPmQR6RV8Cr6iVk+6y4AaoFUXgQ==", + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/@query-doctor/core/-/core-0.10.4.tgz", + "integrity": "sha512-n9a1hriF75ezcuMPW8ob8sYlGTlTftCzFfS4Na4mLkF4dlZqIrt+29tRRWd2mHEZoSL87H47sCsyg/XGqZpezQ==", "dependencies": { "@pgsql/types": "^17.6.2", "capnweb": "^0.7.0", diff --git a/package.json b/package.json index 0d77e04..0621f3e 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "@libpg-query/parser": "^17.6.3", "@opentelemetry/api": "^1.9.0", "@pgsql/types": "^17.6.2", - "@query-doctor/core": "^0.10.3", + "@query-doctor/core": "^0.10.4", "async-sema": "^3.1.1", "capnweb": "^0.7.0", "dedent": "^1.7.1",