mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-07 07:55:13 +02:00
fix(sl): skip TS/Python schema contract test when uv is unavailable
The TypeScript checks CI job does not install uv or Python, so the
module-level `execFileSync('uv', ...)` in schemas.contract.test.ts threw
ENOENT and failed the suite. Wrap the schema dump in a try/catch and
guard the describe block with `describe.skipIf` so the test skips in
environments without uv. Local dev and any CI job that has uv on PATH
still runs the cross-language contract assertion.
This commit is contained in:
parent
7072d3708c
commit
eff904b60d
1 changed files with 16 additions and 8 deletions
|
|
@ -6,12 +6,20 @@ import { resolvedSourceSchema } from './schemas.js';
|
|||
import { toResolvedWire } from './semantic-layer.service.js';
|
||||
import type { SemanticLayerSource } from './types.js';
|
||||
|
||||
const sourceDefinitionJsonSchema = JSON.parse(
|
||||
execFileSync('uv', ['run', 'python', '-m', 'semantic_layer', 'dump-schema'], {
|
||||
cwd: new URL('../../../../', import.meta.url),
|
||||
encoding: 'utf8',
|
||||
}),
|
||||
) as Record<string, unknown>;
|
||||
function loadPythonSourceDefinitionSchema(): Record<string, unknown> | null {
|
||||
try {
|
||||
const stdout = execFileSync('uv', ['run', 'python', '-m', 'semantic_layer', 'dump-schema'], {
|
||||
cwd: new URL('../../../../', import.meta.url),
|
||||
encoding: 'utf8',
|
||||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
});
|
||||
return JSON.parse(stdout) as Record<string, unknown>;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const sourceDefinitionJsonSchema = loadPythonSourceDefinitionSchema();
|
||||
|
||||
const fixtures: SemanticLayerSource[] = [
|
||||
{
|
||||
|
|
@ -46,10 +54,10 @@ const fixtures: SemanticLayerSource[] = [
|
|||
},
|
||||
];
|
||||
|
||||
describe('resolved source JSON Schema contract', () => {
|
||||
describe.skipIf(sourceDefinitionJsonSchema === null)('resolved source JSON Schema contract', () => {
|
||||
it('keeps TS resolved-source fixtures accepted by the Python SourceDefinition schema', () => {
|
||||
const ajv = new Ajv2020({ allErrors: true, strict: false });
|
||||
const validate = ajv.compile(sourceDefinitionJsonSchema);
|
||||
const validate = ajv.compile(sourceDefinitionJsonSchema as Record<string, unknown>);
|
||||
|
||||
for (const fixture of fixtures) {
|
||||
const wire = toResolvedWire(fixture);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue