@elench/testkit 0.1.45 → 0.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -6
- package/lib/cli/args.mjs +25 -4
- package/lib/cli/args.test.mjs +32 -0
- package/lib/cli/db.mjs +115 -0
- package/lib/cli/index.mjs +23 -1
- package/lib/cli/known-failures.mjs +164 -0
- package/lib/config/index.mjs +155 -28
- package/lib/database/fingerprint.mjs +9 -5
- package/lib/database/fingerprint.test.mjs +10 -4
- package/lib/database/index.mjs +34 -11
- package/lib/database/template-steps.mjs +232 -0
- package/lib/known-failures/github.mjs +40 -4
- package/lib/known-failures/github.test.mjs +190 -0
- package/lib/known-failures/index.d.ts +5 -1
- package/lib/runner/reporting.mjs +2 -2
- package/lib/runner/reporting.test.mjs +2 -2
- package/lib/runner/runtime-contexts.mjs +2 -41
- package/lib/runner/template.mjs +30 -24
- package/lib/runner/template.test.mjs +1 -2
- package/lib/setup/index.d.ts +37 -7
- package/lib/setup/index.mjs +21 -3
- package/package.json +1 -1
|
@@ -125,7 +125,7 @@ export async function validateKnownFailureIssues({
|
|
|
125
125
|
|
|
126
126
|
const summary = buildIssueValidationSummary(entries, globalFindings);
|
|
127
127
|
return {
|
|
128
|
-
schemaVersion:
|
|
128
|
+
schemaVersion: 2,
|
|
129
129
|
provider: "github",
|
|
130
130
|
mode: normalizedConfig.mode,
|
|
131
131
|
checkedAt: new Date(now).toISOString(),
|
|
@@ -363,7 +363,15 @@ function collectObservedKnownFailureEntries(document, runArtifact, statusArtifac
|
|
|
363
363
|
const observed = checks.get(entry.id) || createObservedCheck(entry);
|
|
364
364
|
observed.matchedTests += 1;
|
|
365
365
|
if (test.status === "failed") {
|
|
366
|
+
observed.executedTests += 1;
|
|
366
367
|
observed.failedTests += 1;
|
|
368
|
+
} else if (test.status === "passed") {
|
|
369
|
+
observed.executedTests += 1;
|
|
370
|
+
observed.passedTests += 1;
|
|
371
|
+
} else if (test.status === "skipped") {
|
|
372
|
+
observed.skippedTests += 1;
|
|
373
|
+
} else if (test.status === "not_run") {
|
|
374
|
+
observed.notRunTests += 1;
|
|
367
375
|
}
|
|
368
376
|
checks.set(entry.id, observed);
|
|
369
377
|
}
|
|
@@ -399,7 +407,11 @@ function createObservedCheck(entry) {
|
|
|
399
407
|
return {
|
|
400
408
|
id: entry.id,
|
|
401
409
|
matchedTests: 0,
|
|
410
|
+
executedTests: 0,
|
|
411
|
+
passedTests: 0,
|
|
402
412
|
failedTests: 0,
|
|
413
|
+
skippedTests: 0,
|
|
414
|
+
notRunTests: 0,
|
|
403
415
|
};
|
|
404
416
|
}
|
|
405
417
|
|
|
@@ -457,7 +469,12 @@ function buildIssueValidationEntry({ entry, observed, issueData }) {
|
|
|
457
469
|
});
|
|
458
470
|
}
|
|
459
471
|
|
|
460
|
-
if (
|
|
472
|
+
if (
|
|
473
|
+
issueData?.exists &&
|
|
474
|
+
observed.executedTests > 0 &&
|
|
475
|
+
observed.failedTests === 0 &&
|
|
476
|
+
observed.passedTests > 0
|
|
477
|
+
) {
|
|
461
478
|
if (normalizedIssueState === "open") {
|
|
462
479
|
findings.push({
|
|
463
480
|
code: "open_not_reproduced",
|
|
@@ -479,7 +496,11 @@ function buildIssueValidationEntry({ entry, observed, issueData }) {
|
|
|
479
496
|
issue: entry.issue,
|
|
480
497
|
observed: {
|
|
481
498
|
matchedTests: observed.matchedTests,
|
|
499
|
+
executedTests: observed.executedTests,
|
|
500
|
+
passedTests: observed.passedTests,
|
|
482
501
|
failedTests: observed.failedTests,
|
|
502
|
+
skippedTests: observed.skippedTests,
|
|
503
|
+
notRunTests: observed.notRunTests,
|
|
483
504
|
reproduced: observed.failedTests > 0,
|
|
484
505
|
},
|
|
485
506
|
github: issueData
|
|
@@ -510,8 +531,23 @@ function resolveIssueValidationStatus(issueData, observed, findings) {
|
|
|
510
531
|
const normalizedState = normalizeIssueState(issueData.state);
|
|
511
532
|
if (observed.failedTests > 0 && normalizedState === "closed") return "closed_but_failing";
|
|
512
533
|
if (observed.failedTests > 0 && normalizedState === "open") return "open_and_failing";
|
|
513
|
-
if (observed.
|
|
514
|
-
if (
|
|
534
|
+
if (observed.executedTests === 0 && observed.matchedTests > 0) return "not_executed";
|
|
535
|
+
if (
|
|
536
|
+
observed.executedTests > 0 &&
|
|
537
|
+
observed.failedTests === 0 &&
|
|
538
|
+
observed.passedTests > 0 &&
|
|
539
|
+
normalizedState === "open"
|
|
540
|
+
) {
|
|
541
|
+
return "open_not_reproduced";
|
|
542
|
+
}
|
|
543
|
+
if (
|
|
544
|
+
observed.executedTests > 0 &&
|
|
545
|
+
observed.failedTests === 0 &&
|
|
546
|
+
observed.passedTests > 0 &&
|
|
547
|
+
normalizedState === "closed"
|
|
548
|
+
) {
|
|
549
|
+
return "closed_not_reproduced";
|
|
550
|
+
}
|
|
515
551
|
if (findings.length > 0) return "metadata_mismatch";
|
|
516
552
|
return "not_observed";
|
|
517
553
|
}
|
|
@@ -279,6 +279,196 @@ describe("known failures GitHub validation", () => {
|
|
|
279
279
|
expect(result.summary.errors).toBe(0);
|
|
280
280
|
expect(result.summary.warnings).toBeGreaterThan(0);
|
|
281
281
|
expect(shouldFailKnownFailureIssueValidation(result)).toBe(false);
|
|
282
|
+
expect(result.entries[0].observed).toMatchObject({
|
|
283
|
+
matchedTests: 1,
|
|
284
|
+
executedTests: 1,
|
|
285
|
+
passedTests: 1,
|
|
286
|
+
failedTests: 0,
|
|
287
|
+
skippedTests: 0,
|
|
288
|
+
notRunTests: 0,
|
|
289
|
+
reproduced: false,
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it("does not treat skipped or not_run files as not reproduced", async () => {
|
|
294
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "testkit-gh-not-executed-"));
|
|
295
|
+
tempDirs.push(tempDir);
|
|
296
|
+
const document = normalizeKnownFailuresDocument({
|
|
297
|
+
schemaVersion: 1,
|
|
298
|
+
issueRepo: "acme/repo",
|
|
299
|
+
entries: [
|
|
300
|
+
{
|
|
301
|
+
id: "bad-message",
|
|
302
|
+
title: "Bad message bug",
|
|
303
|
+
classification: "product_bug",
|
|
304
|
+
state: "open",
|
|
305
|
+
issue: {
|
|
306
|
+
repo: "acme/repo",
|
|
307
|
+
number: 12,
|
|
308
|
+
url: "https://github.com/acme/repo/issues/12",
|
|
309
|
+
},
|
|
310
|
+
description: "Wrong message",
|
|
311
|
+
whyFailing: "Payload is wrong",
|
|
312
|
+
lastReviewedAt: "2026-04-27",
|
|
313
|
+
matches: [
|
|
314
|
+
{
|
|
315
|
+
service: "api",
|
|
316
|
+
type: "int",
|
|
317
|
+
path: "src/api/routes/__testkit__/failing.int.testkit.ts",
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
service: "api",
|
|
321
|
+
type: "int",
|
|
322
|
+
path: "src/api/routes/__testkit__/blocked.int.testkit.ts",
|
|
323
|
+
},
|
|
324
|
+
],
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
const result = await validateKnownFailureIssues({
|
|
330
|
+
productDir: tempDir,
|
|
331
|
+
document,
|
|
332
|
+
statusArtifact: {
|
|
333
|
+
tests: [
|
|
334
|
+
{
|
|
335
|
+
service: "api",
|
|
336
|
+
type: "int",
|
|
337
|
+
path: "src/api/routes/__testkit__/failing.int.testkit.ts",
|
|
338
|
+
status: "skipped",
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
service: "api",
|
|
342
|
+
type: "int",
|
|
343
|
+
path: "src/api/routes/__testkit__/blocked.int.testkit.ts",
|
|
344
|
+
status: "not_run",
|
|
345
|
+
},
|
|
346
|
+
],
|
|
347
|
+
},
|
|
348
|
+
config: {
|
|
349
|
+
provider: "github",
|
|
350
|
+
mode: "warn",
|
|
351
|
+
},
|
|
352
|
+
transport: {
|
|
353
|
+
async fetchRepoIssues(repo, numbers) {
|
|
354
|
+
const map = new Map();
|
|
355
|
+
map.set(numbers[0], {
|
|
356
|
+
repo,
|
|
357
|
+
number: numbers[0],
|
|
358
|
+
exists: true,
|
|
359
|
+
title: "Bad message bug",
|
|
360
|
+
state: "OPEN",
|
|
361
|
+
url: `https://github.com/${repo}/issues/${numbers[0]}`,
|
|
362
|
+
checkedAt: "2026-04-27T00:00:00.000Z",
|
|
363
|
+
source: "github",
|
|
364
|
+
});
|
|
365
|
+
return map;
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
expect(result.summary.byCode.open_not_reproduced).toBeUndefined();
|
|
371
|
+
expect(result.entries[0].findings).toEqual([]);
|
|
372
|
+
expect(result.entries[0].status).toBe("not_executed");
|
|
373
|
+
expect(result.entries[0].observed).toMatchObject({
|
|
374
|
+
matchedTests: 2,
|
|
375
|
+
executedTests: 0,
|
|
376
|
+
passedTests: 0,
|
|
377
|
+
failedTests: 0,
|
|
378
|
+
skippedTests: 1,
|
|
379
|
+
notRunTests: 1,
|
|
380
|
+
reproduced: false,
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it("still treats mixed passed and skipped execution as not reproduced", async () => {
|
|
385
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "testkit-gh-mixed-execution-"));
|
|
386
|
+
tempDirs.push(tempDir);
|
|
387
|
+
const document = normalizeKnownFailuresDocument({
|
|
388
|
+
schemaVersion: 1,
|
|
389
|
+
issueRepo: "acme/repo",
|
|
390
|
+
entries: [
|
|
391
|
+
{
|
|
392
|
+
id: "bad-message",
|
|
393
|
+
title: "Bad message bug",
|
|
394
|
+
classification: "product_bug",
|
|
395
|
+
state: "open",
|
|
396
|
+
issue: {
|
|
397
|
+
repo: "acme/repo",
|
|
398
|
+
number: 12,
|
|
399
|
+
url: "https://github.com/acme/repo/issues/12",
|
|
400
|
+
},
|
|
401
|
+
description: "Wrong message",
|
|
402
|
+
whyFailing: "Payload is wrong",
|
|
403
|
+
lastReviewedAt: "2026-04-27",
|
|
404
|
+
matches: [
|
|
405
|
+
{
|
|
406
|
+
service: "api",
|
|
407
|
+
type: "int",
|
|
408
|
+
path: "src/api/routes/__testkit__/passed.int.testkit.ts",
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
service: "api",
|
|
412
|
+
type: "int",
|
|
413
|
+
path: "src/api/routes/__testkit__/skipped.int.testkit.ts",
|
|
414
|
+
},
|
|
415
|
+
],
|
|
416
|
+
},
|
|
417
|
+
],
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
const result = await validateKnownFailureIssues({
|
|
421
|
+
productDir: tempDir,
|
|
422
|
+
document,
|
|
423
|
+
statusArtifact: {
|
|
424
|
+
tests: [
|
|
425
|
+
{
|
|
426
|
+
service: "api",
|
|
427
|
+
type: "int",
|
|
428
|
+
path: "src/api/routes/__testkit__/passed.int.testkit.ts",
|
|
429
|
+
status: "passed",
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
service: "api",
|
|
433
|
+
type: "int",
|
|
434
|
+
path: "src/api/routes/__testkit__/skipped.int.testkit.ts",
|
|
435
|
+
status: "skipped",
|
|
436
|
+
},
|
|
437
|
+
],
|
|
438
|
+
},
|
|
439
|
+
config: {
|
|
440
|
+
provider: "github",
|
|
441
|
+
mode: "warn",
|
|
442
|
+
},
|
|
443
|
+
transport: {
|
|
444
|
+
async fetchRepoIssues(repo, numbers) {
|
|
445
|
+
const map = new Map();
|
|
446
|
+
map.set(numbers[0], {
|
|
447
|
+
repo,
|
|
448
|
+
number: numbers[0],
|
|
449
|
+
exists: true,
|
|
450
|
+
title: "Bad message bug",
|
|
451
|
+
state: "OPEN",
|
|
452
|
+
url: `https://github.com/${repo}/issues/${numbers[0]}`,
|
|
453
|
+
checkedAt: "2026-04-27T00:00:00.000Z",
|
|
454
|
+
source: "github",
|
|
455
|
+
});
|
|
456
|
+
return map;
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
expect(result.summary.byCode.open_not_reproduced).toBe(1);
|
|
462
|
+
expect(result.entries[0].status).toBe("open_not_reproduced");
|
|
463
|
+
expect(result.entries[0].observed).toMatchObject({
|
|
464
|
+
matchedTests: 2,
|
|
465
|
+
executedTests: 1,
|
|
466
|
+
passedTests: 1,
|
|
467
|
+
failedTests: 0,
|
|
468
|
+
skippedTests: 1,
|
|
469
|
+
notRunTests: 0,
|
|
470
|
+
reproduced: false,
|
|
471
|
+
});
|
|
282
472
|
});
|
|
283
473
|
|
|
284
474
|
it("falls back to warning when validation is unavailable", async () => {
|
|
@@ -72,7 +72,11 @@ export interface KnownFailureIssueValidationEntry {
|
|
|
72
72
|
issue: KnownFailureIssueRef;
|
|
73
73
|
observed: {
|
|
74
74
|
matchedTests: number;
|
|
75
|
+
executedTests: number;
|
|
76
|
+
passedTests: number;
|
|
75
77
|
failedTests: number;
|
|
78
|
+
skippedTests: number;
|
|
79
|
+
notRunTests: number;
|
|
76
80
|
reproduced: boolean;
|
|
77
81
|
};
|
|
78
82
|
github: {
|
|
@@ -88,7 +92,7 @@ export interface KnownFailureIssueValidationEntry {
|
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
export interface KnownFailureIssueValidationResult {
|
|
91
|
-
schemaVersion:
|
|
95
|
+
schemaVersion: 2;
|
|
92
96
|
provider: "github";
|
|
93
97
|
mode: "off" | "warn" | "error";
|
|
94
98
|
checkedAt: string;
|
package/lib/runner/reporting.mjs
CHANGED
|
@@ -78,7 +78,7 @@ export function buildStatusArtifact({
|
|
|
78
78
|
scope.serviceFilter === null;
|
|
79
79
|
|
|
80
80
|
return {
|
|
81
|
-
schemaVersion:
|
|
81
|
+
schemaVersion: 6,
|
|
82
82
|
source: "testkit",
|
|
83
83
|
notice: "Generated file. Do not edit manually.",
|
|
84
84
|
product: {
|
|
@@ -127,7 +127,7 @@ export function buildRunArtifact({
|
|
|
127
127
|
const dbBackend = summarizeDbBackend(results);
|
|
128
128
|
|
|
129
129
|
return {
|
|
130
|
-
schemaVersion:
|
|
130
|
+
schemaVersion: 6,
|
|
131
131
|
source: "testkit",
|
|
132
132
|
generatedAt: new Date(finishedAt).toISOString(),
|
|
133
133
|
product: {
|
|
@@ -78,7 +78,7 @@ describe("runner reporting", () => {
|
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
expect(artifact.product.name).toBe("my-product");
|
|
81
|
-
expect(artifact.schemaVersion).toBe(
|
|
81
|
+
expect(artifact.schemaVersion).toBe(6);
|
|
82
82
|
expect(artifact.run).toMatchObject({
|
|
83
83
|
workers: 2,
|
|
84
84
|
fileTimeoutSeconds: 60,
|
|
@@ -149,7 +149,7 @@ describe("runner reporting", () => {
|
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
expect(status).toEqual({
|
|
152
|
-
schemaVersion:
|
|
152
|
+
schemaVersion: 6,
|
|
153
153
|
source: "testkit",
|
|
154
154
|
notice: "Generated file. Do not edit manually.",
|
|
155
155
|
product: {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { execaCommand } from "execa";
|
|
4
|
-
import { resolveServiceCwd } from "../config/index.mjs";
|
|
5
3
|
import { prepareDatabaseRuntime } from "../database/index.mjs";
|
|
6
4
|
import { taskNeedsLocalRuntime } from "./planning.mjs";
|
|
7
5
|
import { writeGraphMetadata } from "./state.mjs";
|
|
8
6
|
import { startLocalServices, stopLocalServices } from "./services.mjs";
|
|
9
|
-
import {
|
|
7
|
+
import { resolveRuntimeInstanceConfigs } from "./template.mjs";
|
|
10
8
|
|
|
11
9
|
export function createRuntimeInstanceContext(runtimeId, graph, productDir) {
|
|
12
10
|
const graphDir = path.join(productDir, ".testkit", "_graphs", graph.dirName);
|
|
@@ -78,43 +76,6 @@ export async function cleanupRuntimeInstanceContext(context, lifecycle) {
|
|
|
78
76
|
|
|
79
77
|
export async function prepareDatabases(runtimeConfigs) {
|
|
80
78
|
for (const config of runtimeConfigs) {
|
|
81
|
-
await prepareDatabaseRuntime(config
|
|
82
|
-
runMigrate: config.testkit.migrate
|
|
83
|
-
? (databaseUrl) => runMigrate(config, databaseUrl)
|
|
84
|
-
: null,
|
|
85
|
-
runSeed: config.testkit.seed ? (databaseUrl) => runSeed(config, databaseUrl) : null,
|
|
86
|
-
});
|
|
79
|
+
await prepareDatabaseRuntime(config);
|
|
87
80
|
}
|
|
88
81
|
}
|
|
89
|
-
|
|
90
|
-
async function runMigrate(config, databaseUrl) {
|
|
91
|
-
const migrate = config.testkit.migrate;
|
|
92
|
-
if (!migrate) return;
|
|
93
|
-
|
|
94
|
-
const env = buildExecutionEnv(config, {}, process.env);
|
|
95
|
-
if (databaseUrl) env.DATABASE_URL = databaseUrl;
|
|
96
|
-
|
|
97
|
-
console.log(`\n── migrate:${config.runtimeLabel}:${config.name} ──`);
|
|
98
|
-
await execaCommand(migrate.cmd, {
|
|
99
|
-
cwd: resolveServiceCwd(config.productDir, migrate.cwd),
|
|
100
|
-
env,
|
|
101
|
-
stdio: "inherit",
|
|
102
|
-
shell: true,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async function runSeed(config, databaseUrl) {
|
|
107
|
-
const seed = config.testkit.seed;
|
|
108
|
-
if (!seed) return;
|
|
109
|
-
|
|
110
|
-
const env = buildExecutionEnv(config, {}, process.env);
|
|
111
|
-
if (databaseUrl) env.DATABASE_URL = databaseUrl;
|
|
112
|
-
|
|
113
|
-
console.log(`\n── seed:${config.runtimeLabel}:${config.name} ──`);
|
|
114
|
-
await execaCommand(seed.cmd, {
|
|
115
|
-
cwd: resolveServiceCwd(config.productDir, seed.cwd),
|
|
116
|
-
env,
|
|
117
|
-
stdio: "inherit",
|
|
118
|
-
shell: true,
|
|
119
|
-
});
|
|
120
|
-
}
|
package/lib/runner/template.mjs
CHANGED
|
@@ -131,28 +131,7 @@ export function resolveRuntimeConfig(
|
|
|
131
131
|
const database = config.testkit.database
|
|
132
132
|
? {
|
|
133
133
|
...config.testkit.database,
|
|
134
|
-
|
|
135
|
-
: undefined;
|
|
136
|
-
|
|
137
|
-
const migrate = config.testkit.migrate
|
|
138
|
-
? {
|
|
139
|
-
...config.testkit.migrate,
|
|
140
|
-
cmd: finalizeString(config.testkit.migrate.cmd, context),
|
|
141
|
-
cwd:
|
|
142
|
-
config.testkit.migrate.cwd !== undefined
|
|
143
|
-
? finalizeString(config.testkit.migrate.cwd, context)
|
|
144
|
-
: config.testkit.migrate.cwd,
|
|
145
|
-
}
|
|
146
|
-
: undefined;
|
|
147
|
-
|
|
148
|
-
const seed = config.testkit.seed
|
|
149
|
-
? {
|
|
150
|
-
...config.testkit.seed,
|
|
151
|
-
cmd: finalizeString(config.testkit.seed.cmd, context),
|
|
152
|
-
cwd:
|
|
153
|
-
config.testkit.seed.cwd !== undefined
|
|
154
|
-
? finalizeString(config.testkit.seed.cwd, context)
|
|
155
|
-
: config.testkit.seed.cwd,
|
|
134
|
+
template: finalizeDatabaseTemplate(config.testkit.database.template, context),
|
|
156
135
|
}
|
|
157
136
|
: undefined;
|
|
158
137
|
|
|
@@ -179,14 +158,41 @@ export function resolveRuntimeConfig(
|
|
|
179
158
|
testkit: {
|
|
180
159
|
...config.testkit,
|
|
181
160
|
database,
|
|
182
|
-
migrate,
|
|
183
|
-
seed,
|
|
184
161
|
templateContext: context,
|
|
185
162
|
local,
|
|
186
163
|
},
|
|
187
164
|
};
|
|
188
165
|
}
|
|
189
166
|
|
|
167
|
+
function finalizeDatabaseTemplate(template, context) {
|
|
168
|
+
if (!template) {
|
|
169
|
+
return {
|
|
170
|
+
inputs: [],
|
|
171
|
+
migrate: [],
|
|
172
|
+
seed: [],
|
|
173
|
+
verify: [],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const finalizeStep = (step) => ({
|
|
178
|
+
...step,
|
|
179
|
+
...(typeof step.cmd === "string" ? { cmd: finalizeString(step.cmd, context) } : {}),
|
|
180
|
+
...(typeof step.cwd === "string" ? { cwd: finalizeString(step.cwd, context) } : {}),
|
|
181
|
+
...(typeof step.path === "string" ? { path: finalizeString(step.path, context) } : {}),
|
|
182
|
+
...(typeof step.specifier === "string"
|
|
183
|
+
? { specifier: finalizeString(step.specifier, context) }
|
|
184
|
+
: {}),
|
|
185
|
+
inputs: (step.inputs || []).map((input) => finalizeString(input, context)),
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
inputs: (template.inputs || []).map((input) => finalizeString(input, context)),
|
|
190
|
+
migrate: (template.migrate || []).map(finalizeStep),
|
|
191
|
+
seed: (template.seed || []).map(finalizeStep),
|
|
192
|
+
verify: (template.verify || []).map(finalizeStep),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
190
196
|
export function resolveServiceStateDir(runtimeDir, config) {
|
|
191
197
|
return path.join(runtimeDir, "services", config.name);
|
|
192
198
|
}
|
|
@@ -26,8 +26,7 @@ function makeRuntimeConfig(name, local, extras = {}) {
|
|
|
26
26
|
local,
|
|
27
27
|
serviceEnv: extras.serviceEnv || {},
|
|
28
28
|
databaseFrom: extras.databaseFrom,
|
|
29
|
-
|
|
30
|
-
seed: extras.seed,
|
|
29
|
+
database: extras.database,
|
|
31
30
|
templateContext: extras.templateContext,
|
|
32
31
|
},
|
|
33
32
|
};
|
package/lib/setup/index.d.ts
CHANGED
|
@@ -8,17 +8,38 @@ export interface LocalDatabaseConfig {
|
|
|
8
8
|
reset?: boolean;
|
|
9
9
|
template?: {
|
|
10
10
|
inputs?: string[];
|
|
11
|
+
migrate?: TemplateLifecycleStepConfig[];
|
|
12
|
+
seed?: TemplateLifecycleStepConfig[];
|
|
13
|
+
verify?: TemplateLifecycleStepConfig[];
|
|
11
14
|
};
|
|
12
15
|
user?: string;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
export interface
|
|
16
|
-
cmd: string;
|
|
18
|
+
export interface TemplateStepBaseConfig {
|
|
17
19
|
cwd?: string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
inputs?: string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface TemplateCommandStepConfig extends TemplateStepBaseConfig {
|
|
24
|
+
kind: "command";
|
|
25
|
+
cmd: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface TemplateSqlFileStepConfig extends TemplateStepBaseConfig {
|
|
29
|
+
kind: "sql-file";
|
|
30
|
+
path: string;
|
|
20
31
|
}
|
|
21
32
|
|
|
33
|
+
export interface TemplateModuleStepConfig extends TemplateStepBaseConfig {
|
|
34
|
+
kind: "module";
|
|
35
|
+
specifier: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type TemplateLifecycleStepConfig =
|
|
39
|
+
| TemplateCommandStepConfig
|
|
40
|
+
| TemplateSqlFileStepConfig
|
|
41
|
+
| TemplateModuleStepConfig;
|
|
42
|
+
|
|
22
43
|
export interface SkipFileRule {
|
|
23
44
|
path: string;
|
|
24
45
|
reason: string;
|
|
@@ -84,8 +105,6 @@ export interface ServiceConfig {
|
|
|
84
105
|
readyUrl: string;
|
|
85
106
|
start: string;
|
|
86
107
|
};
|
|
87
|
-
migrate?: LifecycleConfig;
|
|
88
|
-
seed?: LifecycleConfig;
|
|
89
108
|
runtime?: RuntimeConfig;
|
|
90
109
|
requirements?: ServiceRequirementConfig;
|
|
91
110
|
skip?: SkipConfig;
|
|
@@ -113,7 +132,18 @@ export declare function defineTestkitSetup<T extends TestkitSetup>(setup: T): T;
|
|
|
113
132
|
export declare function defineHttpProfile<T extends HttpSuiteConfig>(profile: T): T;
|
|
114
133
|
export declare function service<T extends ServiceConfig>(config: T): T;
|
|
115
134
|
export declare function localDatabase(options?: Omit<LocalDatabaseConfig, "provider">): LocalDatabaseConfig;
|
|
116
|
-
export declare function
|
|
135
|
+
export declare function commandStep(
|
|
136
|
+
cmd: string,
|
|
137
|
+
options?: Omit<TemplateCommandStepConfig, "kind" | "cmd">
|
|
138
|
+
): TemplateCommandStepConfig;
|
|
139
|
+
export declare function sqlFileStep(
|
|
140
|
+
filePath: string,
|
|
141
|
+
options?: Omit<TemplateSqlFileStepConfig, "kind" | "path">
|
|
142
|
+
): TemplateSqlFileStepConfig;
|
|
143
|
+
export declare function moduleStep(
|
|
144
|
+
specifier: string,
|
|
145
|
+
options?: Omit<TemplateModuleStepConfig, "kind" | "specifier">
|
|
146
|
+
): TemplateModuleStepConfig;
|
|
117
147
|
export declare function goService(options: ServiceConfig["local"] & {
|
|
118
148
|
command?: string;
|
|
119
149
|
entrypoint?: string;
|
package/lib/setup/index.mjs
CHANGED
|
@@ -29,12 +29,30 @@ export function localDatabase(options = {}) {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export function
|
|
32
|
+
export function commandStep(cmd, options = {}) {
|
|
33
33
|
return {
|
|
34
|
+
kind: "command",
|
|
34
35
|
cmd,
|
|
35
36
|
cwd: options.cwd,
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
inputs: Array.isArray(options.inputs) ? [...options.inputs] : undefined,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function sqlFileStep(filePath, options = {}) {
|
|
42
|
+
return {
|
|
43
|
+
kind: "sql-file",
|
|
44
|
+
path: filePath,
|
|
45
|
+
cwd: options.cwd,
|
|
46
|
+
inputs: Array.isArray(options.inputs) ? [...options.inputs] : undefined,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function moduleStep(specifier, options = {}) {
|
|
51
|
+
return {
|
|
52
|
+
kind: "module",
|
|
53
|
+
specifier,
|
|
54
|
+
cwd: options.cwd,
|
|
55
|
+
inputs: Array.isArray(options.inputs) ? [...options.inputs] : undefined,
|
|
38
56
|
};
|
|
39
57
|
}
|
|
40
58
|
|