playwright-performance-regression 0.1.0-next.0 → 0.1.0-next.3
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/CHANGELOG.md +199 -0
- package/README.md +73 -52
- package/dist/{chunk-GCA73FFP.cjs → chunk-2JO5HVPC.cjs} +351 -44
- package/dist/{chunk-R2NPYGB7.cjs → chunk-44ASXVQN.cjs} +96 -198
- package/dist/{chunk-HES6BVZT.js → chunk-AQ2XKYNV.js} +349 -47
- package/dist/chunk-BAOTUUTV.cjs +611 -0
- package/dist/chunk-DX36GFOZ.js +558 -0
- package/dist/chunk-LTRHMBVY.js +5592 -0
- package/dist/{chunk-UTTU4FUC.js → chunk-MUZFQKGQ.js} +82 -184
- package/dist/cli.js +3500 -1157
- package/dist/config.cjs +91 -44
- package/dist/config.d.cts +4 -2
- package/dist/config.d.ts +4 -2
- package/dist/config.js +84 -37
- package/dist/fixture.cjs +5 -5
- package/dist/fixture.d.cts +2 -2
- package/dist/fixture.d.ts +2 -2
- package/dist/fixture.js +3 -3
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +110 -22
- package/dist/index.d.ts +110 -22
- package/dist/index.js +1 -1
- package/dist/perf-api-Rm1h1O_-.d.cts +12 -0
- package/dist/perf-api-Rm1h1O_-.d.ts +12 -0
- package/dist/reporter.cjs +5204 -1209
- package/dist/reporter.js +2035 -254
- package/dist/test.cjs +4 -4
- package/dist/test.js +3 -3
- package/package.json +5 -3
- package/schemas/common.schema.json +2 -2
- package/schemas/config.schema.json +57 -21
- package/schemas/outcome.schema.json +1 -1
- package/schemas/run-report.schema.json +534 -19
- package/schemas/samples.schema.json +4 -39
- package/schemas/thresholds.schema.json +1 -1
- package/dist/chunk-6AB42SPF.js +0 -254
- package/dist/chunk-JEHUFIY3.js +0 -3390
- package/dist/chunk-LV3O2BAT.cjs +0 -319
- package/dist/perf-api-V4PeHVE0.d.cts +0 -22
- package/dist/perf-api-V4PeHVE0.d.ts +0 -22
|
@@ -234,7 +234,7 @@ var envLabel = str({
|
|
|
234
234
|
format: 'a label of lowercase letters, digits and "-", like "staging"'
|
|
235
235
|
});
|
|
236
236
|
var envLabelOrNull = nullable(envLabel);
|
|
237
|
-
var kind = enumOf(["api", "
|
|
237
|
+
var kind = enumOf(["api", "step"]);
|
|
238
238
|
var percentileName = str({
|
|
239
239
|
pattern: /^p(?:[1-9][0-9]?)(?:\.[0-9])?$/u,
|
|
240
240
|
format: 'a percentile name like "p95" or "p99.9"'
|
|
@@ -270,7 +270,13 @@ var isoDate = str({ pattern: /^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])
|
|
|
270
270
|
|
|
271
271
|
// src/core/config/generated/defaults.ts
|
|
272
272
|
var DEFAULT_CONFIG = {
|
|
273
|
-
run: {
|
|
273
|
+
run: {
|
|
274
|
+
env: null,
|
|
275
|
+
passes: { test: 5, thresholds: 10 },
|
|
276
|
+
projects: "auto",
|
|
277
|
+
grep: null,
|
|
278
|
+
keepReporters: []
|
|
279
|
+
},
|
|
274
280
|
measure: {
|
|
275
281
|
resourceTypes: ["document", "xhr", "fetch"],
|
|
276
282
|
ignoreExtensions: [
|
|
@@ -297,6 +303,7 @@ var DEFAULT_CONFIG = {
|
|
|
297
303
|
exclude: ["/socket.io/"],
|
|
298
304
|
excludeKnownThirdParty: true,
|
|
299
305
|
successStatuses: ["2xx", "3xx"],
|
|
306
|
+
steps: false,
|
|
300
307
|
pendingTimeoutMs: 2e3
|
|
301
308
|
},
|
|
302
309
|
keys: {
|
|
@@ -313,64 +320,59 @@ var DEFAULT_CONFIG = {
|
|
|
313
320
|
enabled: true,
|
|
314
321
|
minSamples: 5,
|
|
315
322
|
margin: { relative: 0.4, minMs: 100, smallSampleRelative: 0.8 },
|
|
316
|
-
limit: { api: 2e3,
|
|
323
|
+
limit: { api: 2e3, step: 1e4 }
|
|
317
324
|
},
|
|
318
325
|
percentile: {
|
|
319
326
|
enabled: true,
|
|
320
327
|
minSamples: 20,
|
|
321
328
|
level: "p95",
|
|
322
|
-
limit: { api: 2e3,
|
|
329
|
+
limit: { api: 2e3, step: 15e3 },
|
|
323
330
|
margin: { relative: 0.4, minMs: 100, smallSampleRelative: 0.8 }
|
|
324
331
|
},
|
|
325
332
|
p99: {
|
|
326
333
|
enabled: true,
|
|
327
334
|
minSamples: 100,
|
|
328
335
|
margin: { relative: 0.2, minGapMs: 50, minGapRelative: 0.1 },
|
|
329
|
-
limit: { api: 4e3,
|
|
336
|
+
limit: { api: 4e3, step: 3e4 }
|
|
330
337
|
}
|
|
331
338
|
},
|
|
332
339
|
slowShare: {
|
|
333
340
|
t: {
|
|
334
341
|
api: { min: 500, max: 2e3, medianFactor: 2 },
|
|
335
|
-
|
|
342
|
+
step: { min: 1e3, max: 1e4, medianFactor: 2 }
|
|
336
343
|
},
|
|
337
344
|
apdex: {
|
|
338
345
|
enabled: true,
|
|
339
346
|
minSamples: 20,
|
|
340
347
|
margin: { absolute: 0.05, smallSampleAbsolute: 0.1 },
|
|
341
|
-
limit: { api: 0.85,
|
|
348
|
+
limit: { api: 0.85, step: 0.85 }
|
|
342
349
|
},
|
|
343
350
|
wilson: {
|
|
344
351
|
enabled: true,
|
|
345
352
|
minSamples: 20,
|
|
346
353
|
margin: { factor: 1.5, add: 0.02, min: 0.03, max: 0.15, smallSampleMin: 0.1 },
|
|
347
|
-
limit: { api: 0.05,
|
|
354
|
+
limit: { api: 0.05, step: 0.05 }
|
|
348
355
|
}
|
|
349
356
|
},
|
|
350
357
|
errors: {
|
|
351
358
|
enabled: true,
|
|
352
359
|
minSamples: 5,
|
|
353
360
|
statuses: ["5xx", "FAILED", "PENDING"],
|
|
354
|
-
limit: { api: 0.05,
|
|
361
|
+
limit: { api: 0.05, step: 0.05 },
|
|
355
362
|
margin: { factor: 1.5, add: 0.02, min: 0.05 }
|
|
356
363
|
}
|
|
357
364
|
},
|
|
358
|
-
gate: {
|
|
359
|
-
tolerance: 0,
|
|
360
|
-
hardLimitFactor: 2,
|
|
361
|
-
defaultThresholds: "block",
|
|
362
|
-
warnOnly: false,
|
|
363
|
-
maxFailedTestShare: 0.1
|
|
364
|
-
},
|
|
365
|
+
gate: { tolerance: 0, hardLimitFactor: 2, defaultThresholds: "block", maxFailedTestShare: 0.1 },
|
|
365
366
|
thresholds: {
|
|
367
|
+
preset: "normal",
|
|
366
368
|
dir: ".",
|
|
367
|
-
filePrefix: "perf-thresholds",
|
|
369
|
+
filePrefix: "pw-perf-thresholds",
|
|
368
370
|
update: "all",
|
|
369
371
|
smallSampleN: 20,
|
|
370
372
|
hysteresis: { relative: 0.1, ratio: 0.01 },
|
|
371
373
|
loosenWarnRelative: 0.5
|
|
372
374
|
},
|
|
373
|
-
report: { dir: "perf-results", html: true, rawUrls: false },
|
|
375
|
+
report: { dir: "pw-perf-results", html: true, rawUrls: false },
|
|
374
376
|
advanced: { maxSamplesPerKey: 5e3, seed: 1 }
|
|
375
377
|
};
|
|
376
378
|
|
|
@@ -435,7 +437,7 @@ function describeValue(value) {
|
|
|
435
437
|
text = void 0;
|
|
436
438
|
}
|
|
437
439
|
if (text === void 0) return Array.isArray(value) ? "an array" : "an object";
|
|
438
|
-
return text.length > MAX_SHOWN ? `${text.slice(0, MAX_SHOWN - 1)}
|
|
440
|
+
return text.length > MAX_SHOWN ? `${text.slice(0, MAX_SHOWN - 1)}…` : text;
|
|
439
441
|
}
|
|
440
442
|
function editDistance(a, b) {
|
|
441
443
|
let previous = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
@@ -450,6 +452,100 @@ function editDistance(a, b) {
|
|
|
450
452
|
return previous[b.length] ?? 0;
|
|
451
453
|
}
|
|
452
454
|
|
|
455
|
+
// src/core/config/steps.ts
|
|
456
|
+
var STEP_OPTION_NAMES = [
|
|
457
|
+
"enabled",
|
|
458
|
+
"include",
|
|
459
|
+
"exclude",
|
|
460
|
+
"maxDepth",
|
|
461
|
+
"categories",
|
|
462
|
+
"groupBy",
|
|
463
|
+
"normalizeTitles",
|
|
464
|
+
"redactQuotedValues"
|
|
465
|
+
];
|
|
466
|
+
var STEP_DEFAULTS = {
|
|
467
|
+
include: [],
|
|
468
|
+
exclude: [],
|
|
469
|
+
maxDepth: 3,
|
|
470
|
+
categories: ["test.step"],
|
|
471
|
+
groupBy: "step",
|
|
472
|
+
normalizeTitles: true,
|
|
473
|
+
redactQuotedValues: false
|
|
474
|
+
};
|
|
475
|
+
function expandSteps(value) {
|
|
476
|
+
const defaults = () => ({
|
|
477
|
+
...STEP_DEFAULTS,
|
|
478
|
+
include: [],
|
|
479
|
+
exclude: [],
|
|
480
|
+
categories: [...STEP_DEFAULTS.categories]
|
|
481
|
+
});
|
|
482
|
+
if (value === void 0 || typeof value === "boolean") {
|
|
483
|
+
return { enabled: value === true, ...defaults() };
|
|
484
|
+
}
|
|
485
|
+
return {
|
|
486
|
+
enabled: value.enabled ?? true,
|
|
487
|
+
...defaults(),
|
|
488
|
+
...Object.fromEntries(Object.entries(value).filter(([, v]) => v !== void 0))
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// src/core/config/presets.ts
|
|
493
|
+
var MARGIN_PRESETS = ["strict", "normal", "loose"];
|
|
494
|
+
var VALUES = {
|
|
495
|
+
strict: {
|
|
496
|
+
relative: 0.25,
|
|
497
|
+
minMs: 50,
|
|
498
|
+
smallSampleRelative: 0.5,
|
|
499
|
+
p99Relative: 0.1,
|
|
500
|
+
apdexAbsolute: 0.03,
|
|
501
|
+
apdexSmallSampleAbsolute: 0.06,
|
|
502
|
+
factor: 1.25
|
|
503
|
+
},
|
|
504
|
+
normal: {
|
|
505
|
+
relative: 0.4,
|
|
506
|
+
minMs: 100,
|
|
507
|
+
smallSampleRelative: 0.8,
|
|
508
|
+
p99Relative: 0.2,
|
|
509
|
+
apdexAbsolute: 0.05,
|
|
510
|
+
apdexSmallSampleAbsolute: 0.1,
|
|
511
|
+
factor: 1.5
|
|
512
|
+
},
|
|
513
|
+
loose: {
|
|
514
|
+
relative: 0.6,
|
|
515
|
+
minMs: 200,
|
|
516
|
+
smallSampleRelative: 1.2,
|
|
517
|
+
p99Relative: 0.35,
|
|
518
|
+
apdexAbsolute: 0.08,
|
|
519
|
+
apdexSmallSampleAbsolute: 0.15,
|
|
520
|
+
factor: 2
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
function presetOf(input) {
|
|
524
|
+
const thresholds = isRecord(input) ? input.thresholds : void 0;
|
|
525
|
+
const preset = isRecord(thresholds) ? thresholds.preset : void 0;
|
|
526
|
+
return MARGIN_PRESETS.includes(preset) ? preset : "normal";
|
|
527
|
+
}
|
|
528
|
+
function presetLayer(preset) {
|
|
529
|
+
const v = VALUES[preset];
|
|
530
|
+
const time = { relative: v.relative, minMs: v.minMs, smallSampleRelative: v.smallSampleRelative };
|
|
531
|
+
return {
|
|
532
|
+
checks: {
|
|
533
|
+
time: {
|
|
534
|
+
median: { margin: time },
|
|
535
|
+
percentile: { margin: { ...time } },
|
|
536
|
+
p99: { margin: { relative: v.p99Relative } }
|
|
537
|
+
},
|
|
538
|
+
slowShare: {
|
|
539
|
+
apdex: {
|
|
540
|
+
margin: { absolute: v.apdexAbsolute, smallSampleAbsolute: v.apdexSmallSampleAbsolute }
|
|
541
|
+
},
|
|
542
|
+
wilson: { margin: { factor: v.factor } }
|
|
543
|
+
},
|
|
544
|
+
errors: { margin: { factor: v.factor } }
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
|
|
453
549
|
// src/core/schema/config.ts
|
|
454
550
|
var factor10 = num({ minimum: 0, maximum: 10 });
|
|
455
551
|
var unit = num({ minimum: 0, maximum: 1 });
|
|
@@ -463,7 +559,7 @@ var urlPattern = oneOf(
|
|
|
463
559
|
{ required: ["regex"] }
|
|
464
560
|
)
|
|
465
561
|
);
|
|
466
|
-
var limitByKind = (value) => obj({ api: value,
|
|
562
|
+
var limitByKind = (value) => obj({ api: value, step: value });
|
|
467
563
|
var relativeMargin = obj({
|
|
468
564
|
relative: factor10,
|
|
469
565
|
minMs: int({ minimum: 0 }),
|
|
@@ -503,7 +599,7 @@ var checks = obj({
|
|
|
503
599
|
p99: obj({ enabled, minSamples, margin: p99Margin, limit: limitByKind(msLimit) })
|
|
504
600
|
}),
|
|
505
601
|
slowShare: obj({
|
|
506
|
-
t: obj({ api: tSettings,
|
|
602
|
+
t: obj({ api: tSettings, step: tSettings }),
|
|
507
603
|
apdex: obj({ enabled, minSamples, margin: apdexMargin, limit: limitByKind(ratio) }),
|
|
508
604
|
wilson: obj({ enabled, minSamples, margin: wilsonMargin, limit: limitByKind(ratio) })
|
|
509
605
|
}),
|
|
@@ -528,11 +624,12 @@ var packageConfig = obj({
|
|
|
528
624
|
$schema: str(),
|
|
529
625
|
run: obj({
|
|
530
626
|
env: envLabelOrNull,
|
|
531
|
-
|
|
627
|
+
passes: obj({
|
|
532
628
|
test: int({ minimum: 1, maximum: 1e3 }),
|
|
533
629
|
thresholds: int({ minimum: 1, maximum: 1e3 })
|
|
534
630
|
}),
|
|
535
631
|
projects: oneOf(constant("auto"), arr(str(), { minItems: 1, uniqueItems: true })),
|
|
632
|
+
grep: nullable(str({ minLength: 1 })),
|
|
536
633
|
keepReporters: uniqueStrings(1)
|
|
537
634
|
}),
|
|
538
635
|
measure: obj({
|
|
@@ -570,13 +667,30 @@ var packageConfig = obj({
|
|
|
570
667
|
minItems: 1
|
|
571
668
|
}
|
|
572
669
|
),
|
|
670
|
+
steps: oneOf(
|
|
671
|
+
bool,
|
|
672
|
+
obj({
|
|
673
|
+
enabled: bool,
|
|
674
|
+
include: arr(urlPattern),
|
|
675
|
+
exclude: arr(urlPattern),
|
|
676
|
+
maxDepth: int({ minimum: 1, maximum: 10 }),
|
|
677
|
+
categories: arr(enumOf(["test.step", "expect", "pw:api", "fixture", "hook"]), {
|
|
678
|
+
minItems: 1,
|
|
679
|
+
uniqueItems: true
|
|
680
|
+
}),
|
|
681
|
+
groupBy: enumOf(["step", "test"]),
|
|
682
|
+
normalizeTitles: bool,
|
|
683
|
+
redactQuotedValues: bool
|
|
684
|
+
})
|
|
685
|
+
),
|
|
573
686
|
pendingTimeoutMs: int({ minimum: 0, maximum: 6e4 })
|
|
574
687
|
}),
|
|
575
688
|
keys: obj({
|
|
576
689
|
origins: record(
|
|
577
690
|
str({
|
|
578
|
-
|
|
579
|
-
|
|
691
|
+
// Keys with * are host patterns, checked by resolveConfig (03-REQ-20).
|
|
692
|
+
pattern: /^(?:https?:\/\/[^/?#]+|.*\*.*)$/u,
|
|
693
|
+
format: 'an origin without a path, like "https://api.example.com", or a host pattern like "https://*.ci.example.com"'
|
|
580
694
|
}),
|
|
581
695
|
str({
|
|
582
696
|
pattern: /^[a-z0-9.-]*$/u,
|
|
@@ -609,10 +723,10 @@ var packageConfig = obj({
|
|
|
609
723
|
),
|
|
610
724
|
hardLimitFactor: nullable(num({ minimum: 1 })),
|
|
611
725
|
defaultThresholds: enumOf(["block", "warn"]),
|
|
612
|
-
warnOnly: bool,
|
|
613
726
|
maxFailedTestShare: unit
|
|
614
727
|
}),
|
|
615
728
|
thresholds: obj({
|
|
729
|
+
preset: enumOf(["strict", "normal", "loose"]),
|
|
616
730
|
dir: str({ minLength: 1 }),
|
|
617
731
|
filePrefix: str({
|
|
618
732
|
pattern: /^[A-Za-z0-9._-]+$/u,
|
|
@@ -651,25 +765,127 @@ var derivationSettings = obj(
|
|
|
651
765
|
{ required: ["t", "smallSampleN", "margins"] }
|
|
652
766
|
);
|
|
653
767
|
|
|
768
|
+
// src/core/normalize/host-patterns.ts
|
|
769
|
+
var FORM = /^([A-Za-z]+):\/\/([^/?#@:]+)(?::([0-9]+))?\/?$/u;
|
|
770
|
+
var LABEL = /^[a-z0-9*-]+$/u;
|
|
771
|
+
var DEFAULT_PORT = { http: "80", https: "443" };
|
|
772
|
+
function isHostPattern(key2) {
|
|
773
|
+
return key2.includes("*");
|
|
774
|
+
}
|
|
775
|
+
function parseHostPattern(text, label) {
|
|
776
|
+
const match = FORM.exec(text);
|
|
777
|
+
if (match === null) {
|
|
778
|
+
return "a host pattern must have the form <scheme>://<host>[:<port>], without a path, query, fragment or credentials";
|
|
779
|
+
}
|
|
780
|
+
const scheme = (match[1] ?? "").toLowerCase();
|
|
781
|
+
if (scheme !== "http" && scheme !== "https")
|
|
782
|
+
return "the scheme of a host pattern must be http or https";
|
|
783
|
+
const host = (match[2] ?? "").toLowerCase();
|
|
784
|
+
const labels = host.split(".");
|
|
785
|
+
if (labels.length < 2) return "a host pattern needs at least two host labels, e.g. *.example.com";
|
|
786
|
+
for (const part of labels) {
|
|
787
|
+
if (part === "" || !LABEL.test(part)) {
|
|
788
|
+
return 'host labels may contain only letters, digits, "-" and "*" (international names in their xn-- form)';
|
|
789
|
+
}
|
|
790
|
+
if (part.split("*").length > 2) return 'a host label may contain at most one "*"';
|
|
791
|
+
}
|
|
792
|
+
if ((labels.at(-1) ?? "").includes("*"))
|
|
793
|
+
return 'the last host label (the top-level domain) cannot contain "*"';
|
|
794
|
+
if (labels.every((part) => part.includes("*"))) {
|
|
795
|
+
return 'at least one host label must be without "*", or the pattern would match every host';
|
|
796
|
+
}
|
|
797
|
+
let port = match[3] ?? "";
|
|
798
|
+
if (port !== "") {
|
|
799
|
+
const n = Number(port);
|
|
800
|
+
if (!Number.isInteger(n) || n < 1 || n > 65535)
|
|
801
|
+
return "the port must be a number from 1 to 65535";
|
|
802
|
+
port = String(n);
|
|
803
|
+
if (port === DEFAULT_PORT[scheme]) port = "";
|
|
804
|
+
}
|
|
805
|
+
return {
|
|
806
|
+
scheme,
|
|
807
|
+
labels,
|
|
808
|
+
port,
|
|
809
|
+
canonical: `${scheme}://${host}${port === "" ? "" : `:${port}`}`,
|
|
810
|
+
label
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
function labelMatches(pattern, label) {
|
|
814
|
+
const star = pattern.indexOf("*");
|
|
815
|
+
if (star < 0) return pattern === label;
|
|
816
|
+
const before = pattern.slice(0, star);
|
|
817
|
+
const after = pattern.slice(star + 1);
|
|
818
|
+
return label.length > before.length + after.length && label.startsWith(before) && label.endsWith(after);
|
|
819
|
+
}
|
|
820
|
+
function patternMatches(pattern, url) {
|
|
821
|
+
if (url.protocol !== `${pattern.scheme}:`) return false;
|
|
822
|
+
if (url.port !== pattern.port) return false;
|
|
823
|
+
if (url.hostname.startsWith("[")) return false;
|
|
824
|
+
const labels = url.hostname.toLowerCase().split(".");
|
|
825
|
+
if (labels.length !== pattern.labels.length) return false;
|
|
826
|
+
return pattern.labels.every((part, i) => labelMatches(part, labels[i] ?? ""));
|
|
827
|
+
}
|
|
828
|
+
function literal(pattern) {
|
|
829
|
+
return pattern.labels.join(".").replaceAll("*", "").length;
|
|
830
|
+
}
|
|
831
|
+
function stars(pattern) {
|
|
832
|
+
return pattern.labels.filter((part) => part.includes("*")).length;
|
|
833
|
+
}
|
|
834
|
+
function sortPatterns(patterns) {
|
|
835
|
+
return [...patterns].sort(
|
|
836
|
+
(a, b) => literal(b) - literal(a) || stars(a) - stars(b) || (a.canonical < b.canonical ? -1 : a.canonical > b.canonical ? 1 : 0)
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
function compileHostPatterns(origins) {
|
|
840
|
+
const out = [];
|
|
841
|
+
for (const [key2, label] of Object.entries(origins)) {
|
|
842
|
+
if (!isHostPattern(key2)) continue;
|
|
843
|
+
const parsed = parseHostPattern(key2, label);
|
|
844
|
+
if (typeof parsed !== "string") out.push(parsed);
|
|
845
|
+
}
|
|
846
|
+
return sortPatterns(out);
|
|
847
|
+
}
|
|
848
|
+
function matchingPattern(patterns, url) {
|
|
849
|
+
return patterns.find((p) => patternMatches(p, url)) ?? null;
|
|
850
|
+
}
|
|
851
|
+
|
|
654
852
|
// src/core/config/validate.ts
|
|
655
853
|
var SCHEMA_FILE = "schemas/config.schema.json";
|
|
854
|
+
var REMOVED_WARN_ONLY_HINT = "The trial mode was removed in 0.1.0-next.3; to keep a CI job green on a regression, set continue-on-error on the job (see docs/ci.md), or use gate.tolerance or gate.defaultThresholds: 'warn'.";
|
|
855
|
+
var REMOVED_CUSTOM_HINT = "custom measurements were removed in 0.1.0-next.3; use measure.steps and limit.step (test.step durations) instead.";
|
|
656
856
|
var MAX_SUGGESTION_DISTANCE = 2;
|
|
657
857
|
var MAX_SCHEMA_PROBLEMS = 1e3;
|
|
658
858
|
var PATTERN_LISTS = [
|
|
659
859
|
["measure", "include"],
|
|
660
860
|
["measure", "exclude"],
|
|
861
|
+
["measure", "steps", "include"],
|
|
862
|
+
["measure", "steps", "exclude"],
|
|
661
863
|
["keys", "extraIdPatterns"]
|
|
662
864
|
];
|
|
865
|
+
var RESERVED_ENV_LABELS = ["steps", "requests"];
|
|
866
|
+
function reservedEnvIssue(segments, label) {
|
|
867
|
+
return issue2(
|
|
868
|
+
"CONFIG_INVALID_VALUE",
|
|
869
|
+
segments,
|
|
870
|
+
`the environment label ${JSON.stringify(label)} is reserved: it is a part of the thresholds file names (pw-perf-thresholds.${label}.json)`,
|
|
871
|
+
`Use another environment label, e.g. "${label}-env".`
|
|
872
|
+
);
|
|
873
|
+
}
|
|
663
874
|
function issue2(code, segments, message, hint) {
|
|
664
875
|
const path = formatPath(segments);
|
|
665
876
|
return { code, path, message: `${path === "" ? "config" : path}: ${message}`, hint };
|
|
666
877
|
}
|
|
667
878
|
function isPatternItem(segments) {
|
|
668
|
-
return
|
|
879
|
+
return typeof segments.at(-1) === "number" && PATTERN_LISTS.some(
|
|
880
|
+
(list) => segments.length === list.length + 1 && list.every((name, i) => segments[i] === name)
|
|
881
|
+
);
|
|
669
882
|
}
|
|
670
883
|
function knownOptions(parent) {
|
|
671
884
|
if (isPatternItem(parent)) return ["regex", "flags"];
|
|
672
885
|
if (parent[0] === "keys" && parent[1] === "origins") return [];
|
|
886
|
+
if (parent.length === 2 && parent[0] === "measure" && parent[1] === "steps") {
|
|
887
|
+
return [...STEP_OPTION_NAMES];
|
|
888
|
+
}
|
|
673
889
|
const node = valueAt(DEFAULT_CONFIG, parent);
|
|
674
890
|
const names = isRecord(node) ? Object.keys(node) : [];
|
|
675
891
|
if (parent.length === 0) names.push("$schema");
|
|
@@ -695,20 +911,47 @@ function suggestOption(parent, name) {
|
|
|
695
911
|
const moved = allOptionPaths(DEFAULT_CONFIG).find((path) => path.at(-1) === name);
|
|
696
912
|
return moved === void 0 ? void 0 : formatPath(moved);
|
|
697
913
|
}
|
|
914
|
+
function isRemovedCustomOption(parent, name) {
|
|
915
|
+
if (name !== "custom" || parent[0] !== "checks") return false;
|
|
916
|
+
if (parent.at(-1) === "limit") return true;
|
|
917
|
+
return parent.length === 3 && parent[1] === "slowShare" && parent[2] === "t";
|
|
918
|
+
}
|
|
698
919
|
function exampleHint(segments) {
|
|
699
|
-
let example = valueAt(DEFAULT_CONFIG, segments);
|
|
920
|
+
let example = segments[0] === "measure" && segments[1] === "steps" && segments.length > 2 ? valueAt(STEP_DEFAULTS, segments.slice(2)) : valueAt(DEFAULT_CONFIG, segments);
|
|
700
921
|
if (example === void 0 && typeof segments.at(-1) === "number") {
|
|
701
922
|
const list = valueAt(DEFAULT_CONFIG, segments.slice(0, -1));
|
|
702
923
|
if (Array.isArray(list)) example = list[0];
|
|
703
924
|
}
|
|
704
925
|
const shown = example === void 0 || isRecord(example) ? void 0 : describeValue(example);
|
|
705
|
-
const prefix = shown === void 0 || shown.endsWith("
|
|
926
|
+
const prefix = shown === void 0 || shown.endsWith("…") ? "" : `Default: ${shown}. `;
|
|
706
927
|
return `${prefix}${SCHEMA_FILE} in the package lists every option and its format.`;
|
|
707
928
|
}
|
|
708
929
|
function problemToIssue(problem, document) {
|
|
709
930
|
const segments = pointerSegments(problem.pointer, document);
|
|
710
931
|
if (problem.kind === "unknown" && problem.property !== void 0) {
|
|
711
932
|
const option = [...segments, problem.property];
|
|
933
|
+
if (isRemovedCustomOption(segments, problem.property)) {
|
|
934
|
+
return issue2("CONFIG_UNKNOWN_OPTION", option, "unknown option", REMOVED_CUSTOM_HINT);
|
|
935
|
+
}
|
|
936
|
+
if (problem.property === "keepQuotedValues" && segments.length === 2 && segments[0] === "measure" && segments[1] === "steps") {
|
|
937
|
+
return issue2(
|
|
938
|
+
"CONFIG_UNKNOWN_OPTION",
|
|
939
|
+
option,
|
|
940
|
+
"unknown option",
|
|
941
|
+
"keepQuotedValues was renamed to redactQuotedValues with the opposite meaning: quoted values stay in step keys by default; set measure.steps.redactQuotedValues to true to replace them."
|
|
942
|
+
);
|
|
943
|
+
}
|
|
944
|
+
if (problem.property === "repeat" && segments.length === 1 && segments[0] === "run") {
|
|
945
|
+
return issue2(
|
|
946
|
+
"CONFIG_UNKNOWN_OPTION",
|
|
947
|
+
option,
|
|
948
|
+
"unknown option",
|
|
949
|
+
"Renamed to run.passes: the test command now runs once per pass (repeatEach is 1); e.g. run: { passes: { test: 5, thresholds: 10 } }."
|
|
950
|
+
);
|
|
951
|
+
}
|
|
952
|
+
if (problem.property === "warnOnly" && segments.length === 1 && segments[0] === "gate") {
|
|
953
|
+
return issue2("CONFIG_UNKNOWN_OPTION", option, "unknown option", REMOVED_WARN_ONLY_HINT);
|
|
954
|
+
}
|
|
712
955
|
const suggestion = suggestOption(segments, problem.property);
|
|
713
956
|
return issue2(
|
|
714
957
|
"CONFIG_UNKNOWN_OPTION",
|
|
@@ -732,8 +975,8 @@ function schemaIssues(document) {
|
|
|
732
975
|
}
|
|
733
976
|
function regexIssues(document) {
|
|
734
977
|
const issues = [];
|
|
735
|
-
for (const
|
|
736
|
-
const list = valueAt(document,
|
|
978
|
+
for (const path of PATTERN_LISTS) {
|
|
979
|
+
const list = valueAt(document, path);
|
|
737
980
|
if (!Array.isArray(list)) continue;
|
|
738
981
|
list.forEach((item, index) => {
|
|
739
982
|
if (!isRecord(item) || typeof item.regex !== "string") return;
|
|
@@ -745,7 +988,7 @@ function regexIssues(document) {
|
|
|
745
988
|
issues.push(
|
|
746
989
|
issue2(
|
|
747
990
|
"CONFIG_INVALID_REGEX",
|
|
748
|
-
[
|
|
991
|
+
[...path, index],
|
|
749
992
|
`regular expression does not compile (${reason})`,
|
|
750
993
|
'Fix the expression; it uses JavaScript RegExp syntax, e.g. { "regex": "^/api/v[0-9]+/", "flags": "i" }.'
|
|
751
994
|
)
|
|
@@ -753,6 +996,22 @@ function regexIssues(document) {
|
|
|
753
996
|
}
|
|
754
997
|
});
|
|
755
998
|
}
|
|
999
|
+
const grep = valueAt(document, ["run", "grep"]);
|
|
1000
|
+
if (typeof grep === "string" && grep !== "") {
|
|
1001
|
+
try {
|
|
1002
|
+
new RegExp(grep, "i");
|
|
1003
|
+
} catch (error) {
|
|
1004
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
1005
|
+
issues.push(
|
|
1006
|
+
issue2(
|
|
1007
|
+
"CONFIG_INVALID_REGEX",
|
|
1008
|
+
["run", "grep"],
|
|
1009
|
+
`regular expression does not compile (${reason})`,
|
|
1010
|
+
"Fix the expression; it uses JavaScript RegExp syntax, e.g. '@perf' or '@perf|@smoke'."
|
|
1011
|
+
)
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
756
1015
|
return issues;
|
|
757
1016
|
}
|
|
758
1017
|
var numberAt = (config, segments) => {
|
|
@@ -767,7 +1026,7 @@ var RULES = [
|
|
|
767
1026
|
["checks", "slowShare", "wilson"],
|
|
768
1027
|
["checks", "errors"]
|
|
769
1028
|
];
|
|
770
|
-
var KINDS = ["api", "
|
|
1029
|
+
var KINDS = ["api", "step"];
|
|
771
1030
|
var MIN_PERCENTILE = 50;
|
|
772
1031
|
function percentileLevel(name) {
|
|
773
1032
|
if (typeof name !== "string" || !/^p\d+(?:\.\d)?$/u.test(name)) return void 0;
|
|
@@ -837,21 +1096,57 @@ function relationalIssues(config, isSet) {
|
|
|
837
1096
|
);
|
|
838
1097
|
}
|
|
839
1098
|
const enabled2 = RULES.some((rule) => valueAt(config, [...rule, "enabled"]) !== false);
|
|
840
|
-
if (!enabled2
|
|
1099
|
+
if (!enabled2) {
|
|
841
1100
|
errors.push(
|
|
842
1101
|
issue2(
|
|
843
1102
|
"CONFIG_INVALID_VALUE",
|
|
844
1103
|
["checks"],
|
|
845
1104
|
"every rule is disabled, so nothing would be checked",
|
|
846
|
-
"Enable at least one rule in checks
|
|
1105
|
+
"Enable at least one rule in checks."
|
|
847
1106
|
)
|
|
848
1107
|
);
|
|
849
1108
|
}
|
|
1109
|
+
const env = valueAt(config, ["run", "env"]);
|
|
1110
|
+
if (typeof env === "string" && RESERVED_ENV_LABELS.includes(env)) {
|
|
1111
|
+
errors.push(reservedEnvIssue(["run", "env"], env));
|
|
1112
|
+
}
|
|
1113
|
+
const originMap = valueAt(config, ["keys", "origins"]);
|
|
1114
|
+
if (isRecord(originMap)) {
|
|
1115
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1116
|
+
for (const [key2, label] of Object.entries(originMap)) {
|
|
1117
|
+
if (!isHostPattern(key2) || typeof label !== "string") continue;
|
|
1118
|
+
const parsed = parseHostPattern(key2, label);
|
|
1119
|
+
if (typeof parsed === "string") {
|
|
1120
|
+
errors.push(
|
|
1121
|
+
issue2(
|
|
1122
|
+
"CONFIG_INVALID_VALUE",
|
|
1123
|
+
["keys", "origins", key2],
|
|
1124
|
+
parsed,
|
|
1125
|
+
'Write a host pattern like "https://*.ci.example.com": one "*" inside a host label, a top-level domain without "*" (docs/dynamic-environments.md).'
|
|
1126
|
+
)
|
|
1127
|
+
);
|
|
1128
|
+
continue;
|
|
1129
|
+
}
|
|
1130
|
+
const other = seen.get(parsed.canonical);
|
|
1131
|
+
if (other !== void 0) {
|
|
1132
|
+
errors.push(
|
|
1133
|
+
issue2(
|
|
1134
|
+
"CONFIG_INVALID_VALUE",
|
|
1135
|
+
["keys", "origins", key2],
|
|
1136
|
+
`the host pattern is the same as ${JSON.stringify(other)} after canonicalization (${parsed.canonical})`,
|
|
1137
|
+
"Keep one of the two patterns."
|
|
1138
|
+
)
|
|
1139
|
+
);
|
|
1140
|
+
} else {
|
|
1141
|
+
seen.set(parsed.canonical, key2);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
850
1145
|
const origins = valueAt(config, ["keys", "origins"]);
|
|
851
1146
|
if (isRecord(origins)) {
|
|
852
1147
|
const byLabel = /* @__PURE__ */ new Map();
|
|
853
1148
|
for (const [origin, label] of Object.entries(origins)) {
|
|
854
|
-
if (typeof label !== "string") continue;
|
|
1149
|
+
if (typeof label !== "string" || isHostPattern(origin)) continue;
|
|
855
1150
|
byLabel.set(label, [...byLabel.get(label) ?? [], origin]);
|
|
856
1151
|
}
|
|
857
1152
|
for (const [label, list] of byLabel) {
|
|
@@ -882,7 +1177,7 @@ function relationalIssues(config, isSet) {
|
|
|
882
1177
|
|
|
883
1178
|
// src/core/config/resolve.ts
|
|
884
1179
|
var KEY_BUILDER_SNAPSHOT = "[function]";
|
|
885
|
-
var
|
|
1180
|
+
var passesSchema = int({ minimum: 1, maximum: 1e3 });
|
|
886
1181
|
function isPlainObject(value) {
|
|
887
1182
|
if (!isRecord(value)) return false;
|
|
888
1183
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -1003,13 +1298,13 @@ function overrideIssues(overrides) {
|
|
|
1003
1298
|
)
|
|
1004
1299
|
);
|
|
1005
1300
|
}
|
|
1006
|
-
if (overrides.
|
|
1301
|
+
if (overrides.passes !== void 0 && !matches(passesSchema, overrides.passes)) {
|
|
1007
1302
|
issues.push(
|
|
1008
1303
|
issue2(
|
|
1009
1304
|
"CONFIG_INVALID_VALUE",
|
|
1010
|
-
["run", "
|
|
1011
|
-
`the
|
|
1012
|
-
"Fix the number of
|
|
1305
|
+
["run", "passes", overrides.mode ?? "test"],
|
|
1306
|
+
`the passes override must be an integer from 1 to 1000, got ${describeValue(overrides.passes)}`,
|
|
1307
|
+
"Fix the number of passes, e.g. 5."
|
|
1013
1308
|
)
|
|
1014
1309
|
);
|
|
1015
1310
|
}
|
|
@@ -1017,8 +1312,8 @@ function overrideIssues(overrides) {
|
|
|
1017
1312
|
}
|
|
1018
1313
|
function applyOverrides(config, overrides) {
|
|
1019
1314
|
if (overrides.env !== void 0) config.run.env = overrides.env;
|
|
1020
|
-
if (overrides.
|
|
1021
|
-
config.run.
|
|
1315
|
+
if (overrides.passes !== void 0) {
|
|
1316
|
+
config.run.passes[overrides.mode === "thresholds" ? "thresholds" : "test"] = overrides.passes;
|
|
1022
1317
|
}
|
|
1023
1318
|
}
|
|
1024
1319
|
function snapshotPattern(pattern) {
|
|
@@ -1040,13 +1335,15 @@ function resolveConfig(input, overrides) {
|
|
|
1040
1335
|
...overrideIssues(overrides)
|
|
1041
1336
|
];
|
|
1042
1337
|
const { $schema: _schema, ...withoutSchema } = isRecord(document) ? document : {};
|
|
1043
|
-
const
|
|
1338
|
+
const defaults = merge(DEFAULT_CONFIG, presetLayer(presetOf(withoutSchema)));
|
|
1339
|
+
const merged = merge(defaults, withoutSchema);
|
|
1044
1340
|
if (errors.length === 0) applyOverrides(merged, overrides);
|
|
1045
1341
|
const relational = relationalIssues(merged, (path) => order.has(formatPath(path)));
|
|
1046
1342
|
errors.push(...relational.errors);
|
|
1047
1343
|
if (errors.length > 0) return { ok: false, issues: sortByInput(errors, order) };
|
|
1048
|
-
|
|
1049
|
-
|
|
1344
|
+
merged.measure.steps = expandSteps(merged.measure.steps);
|
|
1345
|
+
for (const path of PATTERN_LISTS) {
|
|
1346
|
+
const list = valueAt(merged, path);
|
|
1050
1347
|
list.splice(0, list.length, ...list.map(snapshotPattern));
|
|
1051
1348
|
}
|
|
1052
1349
|
if (keyBuilder.inSnapshot) merged.keys.keyBuilder = KEY_BUILDER_SNAPSHOT;
|
|
@@ -1058,7 +1355,12 @@ function resolveConfig(input, overrides) {
|
|
|
1058
1355
|
measure: {
|
|
1059
1356
|
...copy.measure,
|
|
1060
1357
|
include: snapshot.measure.include.map(compilePattern),
|
|
1061
|
-
exclude: snapshot.measure.exclude.map(compilePattern)
|
|
1358
|
+
exclude: snapshot.measure.exclude.map(compilePattern),
|
|
1359
|
+
steps: {
|
|
1360
|
+
...copy.measure.steps,
|
|
1361
|
+
include: snapshot.measure.steps.include.map(compilePattern),
|
|
1362
|
+
exclude: snapshot.measure.steps.exclude.map(compilePattern)
|
|
1363
|
+
}
|
|
1062
1364
|
},
|
|
1063
1365
|
keys: {
|
|
1064
1366
|
...clone(keys),
|
|
@@ -1094,4 +1396,4 @@ function resolveDefaults() {
|
|
|
1094
1396
|
}
|
|
1095
1397
|
var perfDefaults = deepFreeze(resolveDefaults());
|
|
1096
1398
|
|
|
1097
|
-
export { DEFAULT_CONFIG, Sink, anyObject, arr, bool, child, constant, count, definePerfConfig, derivationSettings, enumOf, envLabelOrNull, epochMs, evaluationStatus, fingerprint, hostFingerprint, int, isRecord, isoDate, issue, key, kind, mode, ms, msLimit, msOrNull, nul, nullable, num, obj, oneOf, packageConfig, percentileName, perfDefaults, ratio, record, resolveConfig, runId, str, testsStatus, timestamp, tool };
|
|
1399
|
+
export { DEFAULT_CONFIG, MARGIN_PRESETS, Sink, anyObject, arr, bool, child, compileHostPatterns, constant, count, definePerfConfig, derivationSettings, enumOf, envLabelOrNull, epochMs, evaluationStatus, expandSteps, fingerprint, hostFingerprint, int, isHostPattern, isRecord, isoDate, issue, key, kind, matchingPattern, mode, ms, msLimit, msOrNull, nul, nullable, num, obj, oneOf, packageConfig, percentileName, perfDefaults, ratio, record, resolveConfig, runId, str, testsStatus, timestamp, tool };
|