playwright-performance-regression 0.1.0-next.1 → 0.1.0-next.4
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 +431 -0
- package/README.md +96 -64
- package/dist/{chunk-L5C63HEF.js → chunk-CISGJCFW.js} +378 -48
- package/dist/chunk-CXE5IWZY.js +1648 -0
- package/dist/{chunk-B64P2D5A.js → chunk-E2IX265O.js} +395 -206
- package/dist/chunk-IUI4AFE5.cjs +658 -0
- package/dist/{chunk-WZVQK7CQ.cjs → chunk-KELMALEG.cjs} +408 -218
- package/dist/{chunk-GCA73FFP.cjs → chunk-LUA4WRIQ.cjs} +382 -47
- package/dist/chunk-RL27E3AB.js +595 -0
- package/dist/{chunk-DYLCGMI2.js → chunk-S6UH6QPK.js} +6 -1
- package/dist/cli.js +2761 -2339
- package/dist/config.cjs +122 -137
- package/dist/config.d.cts +3 -2
- package/dist/config.d.ts +3 -2
- package/dist/config.js +117 -132
- package/dist/fixture.cjs +9 -5
- package/dist/fixture.d.cts +10 -4
- package/dist/fixture.d.ts +10 -4
- package/dist/fixture.js +4 -4
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +121 -25
- package/dist/index.d.ts +121 -25
- package/dist/index.js +1 -1
- package/dist/perf-api-2DH_keLh.d.cts +17 -0
- package/dist/perf-api-2DH_keLh.d.ts +17 -0
- package/dist/reporter.cjs +5713 -1237
- package/dist/reporter.js +6905 -693
- package/dist/test.cjs +4 -4
- package/dist/test.js +4 -4
- package/package.json +19 -1
- package/schemas/common.schema.json +2 -2
- package/schemas/config.schema.json +72 -26
- package/schemas/outcome.schema.json +2 -2
- package/schemas/run-report.schema.json +549 -20
- package/schemas/samples.schema.json +48 -37
- package/schemas/thresholds.schema.json +1 -1
- package/dist/chunk-3CLCMD2Q.js +0 -3411
- package/dist/chunk-4SFI55HF.cjs +0 -319
- package/dist/chunk-HBGADXLP.js +0 -254
- package/dist/perf-api-V4PeHVE0.d.cts +0 -22
- package/dist/perf-api-V4PeHVE0.d.ts +0 -22
|
@@ -236,7 +236,7 @@ var envLabel = str({
|
|
|
236
236
|
format: 'a label of lowercase letters, digits and "-", like "staging"'
|
|
237
237
|
});
|
|
238
238
|
var envLabelOrNull = nullable(envLabel);
|
|
239
|
-
var kind = enumOf(["api", "
|
|
239
|
+
var kind = enumOf(["api", "step"]);
|
|
240
240
|
var percentileName = str({
|
|
241
241
|
pattern: /^p(?:[1-9][0-9]?)(?:\.[0-9])?$/u,
|
|
242
242
|
format: 'a percentile name like "p95" or "p99.9"'
|
|
@@ -272,8 +272,15 @@ var isoDate = str({ pattern: /^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])
|
|
|
272
272
|
|
|
273
273
|
// src/core/config/generated/defaults.ts
|
|
274
274
|
var DEFAULT_CONFIG = {
|
|
275
|
-
run: {
|
|
275
|
+
run: {
|
|
276
|
+
env: null,
|
|
277
|
+
passes: { test: 5, thresholds: 10 },
|
|
278
|
+
grep: null,
|
|
279
|
+
keepReporters: [],
|
|
280
|
+
overrideSlowMo: false
|
|
281
|
+
},
|
|
276
282
|
measure: {
|
|
283
|
+
api: true,
|
|
277
284
|
resourceTypes: ["document", "xhr", "fetch"],
|
|
278
285
|
ignoreExtensions: [
|
|
279
286
|
".js",
|
|
@@ -299,11 +306,20 @@ var DEFAULT_CONFIG = {
|
|
|
299
306
|
exclude: ["/socket.io/"],
|
|
300
307
|
excludeKnownThirdParty: true,
|
|
301
308
|
successStatuses: ["2xx", "3xx"],
|
|
309
|
+
steps: true,
|
|
302
310
|
pendingTimeoutMs: 2e3
|
|
303
311
|
},
|
|
304
312
|
keys: {
|
|
305
313
|
origins: {},
|
|
306
|
-
idPatterns: {
|
|
314
|
+
idPatterns: {
|
|
315
|
+
number: true,
|
|
316
|
+
uuid: true,
|
|
317
|
+
hex: true,
|
|
318
|
+
token: true,
|
|
319
|
+
mixed: true,
|
|
320
|
+
prefixed: true,
|
|
321
|
+
email: true
|
|
322
|
+
},
|
|
307
323
|
extraIdPatterns: [],
|
|
308
324
|
query: "names",
|
|
309
325
|
keepQueryValues: [],
|
|
@@ -315,64 +331,59 @@ var DEFAULT_CONFIG = {
|
|
|
315
331
|
enabled: true,
|
|
316
332
|
minSamples: 5,
|
|
317
333
|
margin: { relative: 0.4, minMs: 100, smallSampleRelative: 0.8 },
|
|
318
|
-
limit: { api: 2e3,
|
|
334
|
+
limit: { api: 2e3, step: 1e4 }
|
|
319
335
|
},
|
|
320
336
|
percentile: {
|
|
321
337
|
enabled: true,
|
|
322
338
|
minSamples: 20,
|
|
323
339
|
level: "p95",
|
|
324
|
-
limit: { api: 2e3,
|
|
340
|
+
limit: { api: 2e3, step: 15e3 },
|
|
325
341
|
margin: { relative: 0.4, minMs: 100, smallSampleRelative: 0.8 }
|
|
326
342
|
},
|
|
327
343
|
p99: {
|
|
328
344
|
enabled: true,
|
|
329
345
|
minSamples: 100,
|
|
330
346
|
margin: { relative: 0.2, minGapMs: 50, minGapRelative: 0.1 },
|
|
331
|
-
limit: { api: 4e3,
|
|
347
|
+
limit: { api: 4e3, step: 3e4 }
|
|
332
348
|
}
|
|
333
349
|
},
|
|
334
350
|
slowShare: {
|
|
335
351
|
t: {
|
|
336
352
|
api: { min: 500, max: 2e3, medianFactor: 2 },
|
|
337
|
-
|
|
353
|
+
step: { min: 1e3, max: 1e4, medianFactor: 2 }
|
|
338
354
|
},
|
|
339
355
|
apdex: {
|
|
340
356
|
enabled: true,
|
|
341
357
|
minSamples: 20,
|
|
342
358
|
margin: { absolute: 0.05, smallSampleAbsolute: 0.1 },
|
|
343
|
-
limit: { api: 0.85,
|
|
359
|
+
limit: { api: 0.85, step: 0.85 }
|
|
344
360
|
},
|
|
345
361
|
wilson: {
|
|
346
362
|
enabled: true,
|
|
347
363
|
minSamples: 20,
|
|
348
364
|
margin: { factor: 1.5, add: 0.02, min: 0.03, max: 0.15, smallSampleMin: 0.1 },
|
|
349
|
-
limit: { api: 0.05,
|
|
365
|
+
limit: { api: 0.05, step: 0.05 }
|
|
350
366
|
}
|
|
351
367
|
},
|
|
352
368
|
errors: {
|
|
353
369
|
enabled: true,
|
|
354
370
|
minSamples: 5,
|
|
355
371
|
statuses: ["5xx", "FAILED", "PENDING"],
|
|
356
|
-
limit: { api: 0.05,
|
|
372
|
+
limit: { api: 0.05, step: 0.05 },
|
|
357
373
|
margin: { factor: 1.5, add: 0.02, min: 0.05 }
|
|
358
374
|
}
|
|
359
375
|
},
|
|
360
|
-
gate: {
|
|
361
|
-
tolerance: 0,
|
|
362
|
-
hardLimitFactor: 2,
|
|
363
|
-
defaultThresholds: "block",
|
|
364
|
-
warnOnly: false,
|
|
365
|
-
maxFailedTestShare: 0.1
|
|
366
|
-
},
|
|
376
|
+
gate: { tolerance: 0, hardLimitFactor: 2, defaultThresholds: "block", maxFailedTestShare: 0.1 },
|
|
367
377
|
thresholds: {
|
|
378
|
+
preset: "normal",
|
|
368
379
|
dir: ".",
|
|
369
|
-
filePrefix: "perf-thresholds",
|
|
380
|
+
filePrefix: "pw-perf-thresholds",
|
|
370
381
|
update: "all",
|
|
371
382
|
smallSampleN: 20,
|
|
372
383
|
hysteresis: { relative: 0.1, ratio: 0.01 },
|
|
373
384
|
loosenWarnRelative: 0.5
|
|
374
385
|
},
|
|
375
|
-
report: { dir: "perf
|
|
386
|
+
report: { dir: "reports/pw-perf", html: true, rawUrls: false },
|
|
376
387
|
advanced: { maxSamplesPerKey: 5e3, seed: 1 }
|
|
377
388
|
};
|
|
378
389
|
|
|
@@ -452,6 +463,100 @@ function editDistance(a, b) {
|
|
|
452
463
|
return previous[b.length] ?? 0;
|
|
453
464
|
}
|
|
454
465
|
|
|
466
|
+
// src/core/config/steps.ts
|
|
467
|
+
var STEP_OPTION_NAMES = [
|
|
468
|
+
"enabled",
|
|
469
|
+
"include",
|
|
470
|
+
"exclude",
|
|
471
|
+
"maxDepth",
|
|
472
|
+
"categories",
|
|
473
|
+
"groupBy",
|
|
474
|
+
"normalizeTitles",
|
|
475
|
+
"redactQuotedValues"
|
|
476
|
+
];
|
|
477
|
+
var STEP_DEFAULTS = {
|
|
478
|
+
include: [],
|
|
479
|
+
exclude: [],
|
|
480
|
+
maxDepth: 3,
|
|
481
|
+
categories: ["test.step"],
|
|
482
|
+
groupBy: "step",
|
|
483
|
+
normalizeTitles: true,
|
|
484
|
+
redactQuotedValues: false
|
|
485
|
+
};
|
|
486
|
+
function expandSteps(value) {
|
|
487
|
+
const defaults = () => ({
|
|
488
|
+
...STEP_DEFAULTS,
|
|
489
|
+
include: [],
|
|
490
|
+
exclude: [],
|
|
491
|
+
categories: [...STEP_DEFAULTS.categories]
|
|
492
|
+
});
|
|
493
|
+
if (value === void 0 || typeof value === "boolean") {
|
|
494
|
+
return { enabled: value === true, ...defaults() };
|
|
495
|
+
}
|
|
496
|
+
return {
|
|
497
|
+
enabled: value.enabled ?? true,
|
|
498
|
+
...defaults(),
|
|
499
|
+
...Object.fromEntries(Object.entries(value).filter(([, v]) => v !== void 0))
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// src/core/config/presets.ts
|
|
504
|
+
var MARGIN_PRESETS = ["strict", "normal", "loose"];
|
|
505
|
+
var VALUES = {
|
|
506
|
+
strict: {
|
|
507
|
+
relative: 0.25,
|
|
508
|
+
minMs: 50,
|
|
509
|
+
smallSampleRelative: 0.5,
|
|
510
|
+
p99Relative: 0.1,
|
|
511
|
+
apdexAbsolute: 0.03,
|
|
512
|
+
apdexSmallSampleAbsolute: 0.06,
|
|
513
|
+
factor: 1.25
|
|
514
|
+
},
|
|
515
|
+
normal: {
|
|
516
|
+
relative: 0.4,
|
|
517
|
+
minMs: 100,
|
|
518
|
+
smallSampleRelative: 0.8,
|
|
519
|
+
p99Relative: 0.2,
|
|
520
|
+
apdexAbsolute: 0.05,
|
|
521
|
+
apdexSmallSampleAbsolute: 0.1,
|
|
522
|
+
factor: 1.5
|
|
523
|
+
},
|
|
524
|
+
loose: {
|
|
525
|
+
relative: 0.6,
|
|
526
|
+
minMs: 200,
|
|
527
|
+
smallSampleRelative: 1.2,
|
|
528
|
+
p99Relative: 0.35,
|
|
529
|
+
apdexAbsolute: 0.08,
|
|
530
|
+
apdexSmallSampleAbsolute: 0.15,
|
|
531
|
+
factor: 2
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
function presetOf(input) {
|
|
535
|
+
const thresholds = isRecord(input) ? input.thresholds : void 0;
|
|
536
|
+
const preset = isRecord(thresholds) ? thresholds.preset : void 0;
|
|
537
|
+
return MARGIN_PRESETS.includes(preset) ? preset : "normal";
|
|
538
|
+
}
|
|
539
|
+
function presetLayer(preset) {
|
|
540
|
+
const v = VALUES[preset];
|
|
541
|
+
const time = { relative: v.relative, minMs: v.minMs, smallSampleRelative: v.smallSampleRelative };
|
|
542
|
+
return {
|
|
543
|
+
checks: {
|
|
544
|
+
time: {
|
|
545
|
+
median: { margin: time },
|
|
546
|
+
percentile: { margin: { ...time } },
|
|
547
|
+
p99: { margin: { relative: v.p99Relative } }
|
|
548
|
+
},
|
|
549
|
+
slowShare: {
|
|
550
|
+
apdex: {
|
|
551
|
+
margin: { absolute: v.apdexAbsolute, smallSampleAbsolute: v.apdexSmallSampleAbsolute }
|
|
552
|
+
},
|
|
553
|
+
wilson: { margin: { factor: v.factor } }
|
|
554
|
+
},
|
|
555
|
+
errors: { margin: { factor: v.factor } }
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
|
|
455
560
|
// src/core/schema/config.ts
|
|
456
561
|
var factor10 = num({ minimum: 0, maximum: 10 });
|
|
457
562
|
var unit = num({ minimum: 0, maximum: 1 });
|
|
@@ -465,7 +570,7 @@ var urlPattern = oneOf(
|
|
|
465
570
|
{ required: ["regex"] }
|
|
466
571
|
)
|
|
467
572
|
);
|
|
468
|
-
var limitByKind = (value) => obj({ api: value,
|
|
573
|
+
var limitByKind = (value) => obj({ api: value, step: value });
|
|
469
574
|
var relativeMargin = obj({
|
|
470
575
|
relative: factor10,
|
|
471
576
|
minMs: int({ minimum: 0 }),
|
|
@@ -505,7 +610,7 @@ var checks = obj({
|
|
|
505
610
|
p99: obj({ enabled, minSamples, margin: p99Margin, limit: limitByKind(msLimit) })
|
|
506
611
|
}),
|
|
507
612
|
slowShare: obj({
|
|
508
|
-
t: obj({ api: tSettings,
|
|
613
|
+
t: obj({ api: tSettings, step: tSettings }),
|
|
509
614
|
apdex: obj({ enabled, minSamples, margin: apdexMargin, limit: limitByKind(ratio) }),
|
|
510
615
|
wilson: obj({ enabled, minSamples, margin: wilsonMargin, limit: limitByKind(ratio) })
|
|
511
616
|
}),
|
|
@@ -530,14 +635,16 @@ var packageConfig = obj({
|
|
|
530
635
|
$schema: str(),
|
|
531
636
|
run: obj({
|
|
532
637
|
env: envLabelOrNull,
|
|
533
|
-
|
|
638
|
+
passes: obj({
|
|
534
639
|
test: int({ minimum: 1, maximum: 1e3 }),
|
|
535
640
|
thresholds: int({ minimum: 1, maximum: 1e3 })
|
|
536
641
|
}),
|
|
537
|
-
|
|
538
|
-
keepReporters: uniqueStrings(1)
|
|
642
|
+
grep: nullable(str({ minLength: 1 })),
|
|
643
|
+
keepReporters: uniqueStrings(1),
|
|
644
|
+
overrideSlowMo: bool
|
|
539
645
|
}),
|
|
540
646
|
measure: obj({
|
|
647
|
+
api: bool,
|
|
541
648
|
resourceTypes: arr(
|
|
542
649
|
enumOf([
|
|
543
650
|
"document",
|
|
@@ -572,13 +679,30 @@ var packageConfig = obj({
|
|
|
572
679
|
minItems: 1
|
|
573
680
|
}
|
|
574
681
|
),
|
|
682
|
+
steps: oneOf(
|
|
683
|
+
bool,
|
|
684
|
+
obj({
|
|
685
|
+
enabled: bool,
|
|
686
|
+
include: arr(urlPattern),
|
|
687
|
+
exclude: arr(urlPattern),
|
|
688
|
+
maxDepth: int({ minimum: 1, maximum: 10 }),
|
|
689
|
+
categories: arr(enumOf(["test.step", "expect", "pw:api", "fixture", "hook"]), {
|
|
690
|
+
minItems: 1,
|
|
691
|
+
uniqueItems: true
|
|
692
|
+
}),
|
|
693
|
+
groupBy: enumOf(["step", "test"]),
|
|
694
|
+
normalizeTitles: bool,
|
|
695
|
+
redactQuotedValues: bool
|
|
696
|
+
})
|
|
697
|
+
),
|
|
575
698
|
pendingTimeoutMs: int({ minimum: 0, maximum: 6e4 })
|
|
576
699
|
}),
|
|
577
700
|
keys: obj({
|
|
578
701
|
origins: record(
|
|
579
702
|
str({
|
|
580
|
-
|
|
581
|
-
|
|
703
|
+
// Keys with * are host patterns, checked by resolveConfig (03-REQ-20).
|
|
704
|
+
pattern: /^(?:https?:\/\/[^/?#]+|.*\*.*)$/u,
|
|
705
|
+
format: 'an origin without a path, like "https://api.example.com", or a host pattern like "https://*.ci.example.com"'
|
|
582
706
|
}),
|
|
583
707
|
str({
|
|
584
708
|
pattern: /^[a-z0-9.-]*$/u,
|
|
@@ -592,6 +716,7 @@ var packageConfig = obj({
|
|
|
592
716
|
hex: bool,
|
|
593
717
|
token: bool,
|
|
594
718
|
mixed: bool,
|
|
719
|
+
prefixed: bool,
|
|
595
720
|
email: bool
|
|
596
721
|
}),
|
|
597
722
|
extraIdPatterns: arr(urlPattern),
|
|
@@ -611,10 +736,10 @@ var packageConfig = obj({
|
|
|
611
736
|
),
|
|
612
737
|
hardLimitFactor: nullable(num({ minimum: 1 })),
|
|
613
738
|
defaultThresholds: enumOf(["block", "warn"]),
|
|
614
|
-
warnOnly: bool,
|
|
615
739
|
maxFailedTestShare: unit
|
|
616
740
|
}),
|
|
617
741
|
thresholds: obj({
|
|
742
|
+
preset: enumOf(["strict", "normal", "loose"]),
|
|
618
743
|
dir: str({ minLength: 1 }),
|
|
619
744
|
filePrefix: str({
|
|
620
745
|
pattern: /^[A-Za-z0-9._-]+$/u,
|
|
@@ -653,25 +778,127 @@ var derivationSettings = obj(
|
|
|
653
778
|
{ required: ["t", "smallSampleN", "margins"] }
|
|
654
779
|
);
|
|
655
780
|
|
|
781
|
+
// src/core/normalize/host-patterns.ts
|
|
782
|
+
var FORM = /^([A-Za-z]+):\/\/([^/?#@:]+)(?::([0-9]+))?\/?$/u;
|
|
783
|
+
var LABEL = /^[a-z0-9*-]+$/u;
|
|
784
|
+
var DEFAULT_PORT = { http: "80", https: "443" };
|
|
785
|
+
function isHostPattern(key2) {
|
|
786
|
+
return key2.includes("*");
|
|
787
|
+
}
|
|
788
|
+
function parseHostPattern(text, label) {
|
|
789
|
+
const match = FORM.exec(text);
|
|
790
|
+
if (match === null) {
|
|
791
|
+
return "a host pattern must have the form <scheme>://<host>[:<port>], without a path, query, fragment or credentials";
|
|
792
|
+
}
|
|
793
|
+
const scheme = (match[1] ?? "").toLowerCase();
|
|
794
|
+
if (scheme !== "http" && scheme !== "https")
|
|
795
|
+
return "the scheme of a host pattern must be http or https";
|
|
796
|
+
const host = (match[2] ?? "").toLowerCase();
|
|
797
|
+
const labels = host.split(".");
|
|
798
|
+
if (labels.length < 2) return "a host pattern needs at least two host labels, e.g. *.example.com";
|
|
799
|
+
for (const part of labels) {
|
|
800
|
+
if (part === "" || !LABEL.test(part)) {
|
|
801
|
+
return 'host labels may contain only letters, digits, "-" and "*" (international names in their xn-- form)';
|
|
802
|
+
}
|
|
803
|
+
if (part.split("*").length > 2) return 'a host label may contain at most one "*"';
|
|
804
|
+
}
|
|
805
|
+
if ((labels.at(-1) ?? "").includes("*"))
|
|
806
|
+
return 'the last host label (the top-level domain) cannot contain "*"';
|
|
807
|
+
if (labels.every((part) => part.includes("*"))) {
|
|
808
|
+
return 'at least one host label must be without "*", or the pattern would match every host';
|
|
809
|
+
}
|
|
810
|
+
let port = match[3] ?? "";
|
|
811
|
+
if (port !== "") {
|
|
812
|
+
const n = Number(port);
|
|
813
|
+
if (!Number.isInteger(n) || n < 1 || n > 65535)
|
|
814
|
+
return "the port must be a number from 1 to 65535";
|
|
815
|
+
port = String(n);
|
|
816
|
+
if (port === DEFAULT_PORT[scheme]) port = "";
|
|
817
|
+
}
|
|
818
|
+
return {
|
|
819
|
+
scheme,
|
|
820
|
+
labels,
|
|
821
|
+
port,
|
|
822
|
+
canonical: `${scheme}://${host}${port === "" ? "" : `:${port}`}`,
|
|
823
|
+
label
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
function labelMatches(pattern, label) {
|
|
827
|
+
const star = pattern.indexOf("*");
|
|
828
|
+
if (star < 0) return pattern === label;
|
|
829
|
+
const before = pattern.slice(0, star);
|
|
830
|
+
const after = pattern.slice(star + 1);
|
|
831
|
+
return label.length > before.length + after.length && label.startsWith(before) && label.endsWith(after);
|
|
832
|
+
}
|
|
833
|
+
function patternMatches(pattern, url) {
|
|
834
|
+
if (url.protocol !== `${pattern.scheme}:`) return false;
|
|
835
|
+
if (url.port !== pattern.port) return false;
|
|
836
|
+
if (url.hostname.startsWith("[")) return false;
|
|
837
|
+
const labels = url.hostname.toLowerCase().split(".");
|
|
838
|
+
if (labels.length !== pattern.labels.length) return false;
|
|
839
|
+
return pattern.labels.every((part, i) => labelMatches(part, labels[i] ?? ""));
|
|
840
|
+
}
|
|
841
|
+
function literal(pattern) {
|
|
842
|
+
return pattern.labels.join(".").replaceAll("*", "").length;
|
|
843
|
+
}
|
|
844
|
+
function stars(pattern) {
|
|
845
|
+
return pattern.labels.filter((part) => part.includes("*")).length;
|
|
846
|
+
}
|
|
847
|
+
function sortPatterns(patterns) {
|
|
848
|
+
return [...patterns].sort(
|
|
849
|
+
(a, b) => literal(b) - literal(a) || stars(a) - stars(b) || (a.canonical < b.canonical ? -1 : a.canonical > b.canonical ? 1 : 0)
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
function compileHostPatterns(origins) {
|
|
853
|
+
const out = [];
|
|
854
|
+
for (const [key2, label] of Object.entries(origins)) {
|
|
855
|
+
if (!isHostPattern(key2)) continue;
|
|
856
|
+
const parsed = parseHostPattern(key2, label);
|
|
857
|
+
if (typeof parsed !== "string") out.push(parsed);
|
|
858
|
+
}
|
|
859
|
+
return sortPatterns(out);
|
|
860
|
+
}
|
|
861
|
+
function matchingPattern(patterns, url) {
|
|
862
|
+
return patterns.find((p) => patternMatches(p, url)) ?? null;
|
|
863
|
+
}
|
|
864
|
+
|
|
656
865
|
// src/core/config/validate.ts
|
|
657
866
|
var SCHEMA_FILE = "schemas/config.schema.json";
|
|
867
|
+
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'.";
|
|
868
|
+
var REMOVED_CUSTOM_HINT = "custom measurements were removed in 0.1.0-next.3; use measure.steps and limit.step (test.step durations) instead.";
|
|
658
869
|
var MAX_SUGGESTION_DISTANCE = 2;
|
|
659
870
|
var MAX_SCHEMA_PROBLEMS = 1e3;
|
|
660
871
|
var PATTERN_LISTS = [
|
|
661
872
|
["measure", "include"],
|
|
662
873
|
["measure", "exclude"],
|
|
874
|
+
["measure", "steps", "include"],
|
|
875
|
+
["measure", "steps", "exclude"],
|
|
663
876
|
["keys", "extraIdPatterns"]
|
|
664
877
|
];
|
|
878
|
+
var RESERVED_ENV_LABELS = ["steps", "requests"];
|
|
879
|
+
function reservedEnvIssue(segments, label) {
|
|
880
|
+
return issue2(
|
|
881
|
+
"CONFIG_INVALID_VALUE",
|
|
882
|
+
segments,
|
|
883
|
+
`the environment label ${JSON.stringify(label)} is reserved: it is a part of the thresholds file names (pw-perf-thresholds.${label}.json)`,
|
|
884
|
+
`Use another environment label, e.g. "${label}-env".`
|
|
885
|
+
);
|
|
886
|
+
}
|
|
665
887
|
function issue2(code, segments, message, hint) {
|
|
666
888
|
const path = formatPath(segments);
|
|
667
889
|
return { code, path, message: `${path === "" ? "config" : path}: ${message}`, hint };
|
|
668
890
|
}
|
|
669
891
|
function isPatternItem(segments) {
|
|
670
|
-
return
|
|
892
|
+
return typeof segments.at(-1) === "number" && PATTERN_LISTS.some(
|
|
893
|
+
(list) => segments.length === list.length + 1 && list.every((name, i) => segments[i] === name)
|
|
894
|
+
);
|
|
671
895
|
}
|
|
672
896
|
function knownOptions(parent) {
|
|
673
897
|
if (isPatternItem(parent)) return ["regex", "flags"];
|
|
674
898
|
if (parent[0] === "keys" && parent[1] === "origins") return [];
|
|
899
|
+
if (parent.length === 2 && parent[0] === "measure" && parent[1] === "steps") {
|
|
900
|
+
return [...STEP_OPTION_NAMES];
|
|
901
|
+
}
|
|
675
902
|
const node = valueAt(DEFAULT_CONFIG, parent);
|
|
676
903
|
const names = isRecord(node) ? Object.keys(node) : [];
|
|
677
904
|
if (parent.length === 0) names.push("$schema");
|
|
@@ -697,8 +924,13 @@ function suggestOption(parent, name) {
|
|
|
697
924
|
const moved = allOptionPaths(DEFAULT_CONFIG).find((path) => path.at(-1) === name);
|
|
698
925
|
return moved === void 0 ? void 0 : formatPath(moved);
|
|
699
926
|
}
|
|
927
|
+
function isRemovedCustomOption(parent, name) {
|
|
928
|
+
if (name !== "custom" || parent[0] !== "checks") return false;
|
|
929
|
+
if (parent.at(-1) === "limit") return true;
|
|
930
|
+
return parent.length === 3 && parent[1] === "slowShare" && parent[2] === "t";
|
|
931
|
+
}
|
|
700
932
|
function exampleHint(segments) {
|
|
701
|
-
let example = valueAt(DEFAULT_CONFIG, segments);
|
|
933
|
+
let example = segments[0] === "measure" && segments[1] === "steps" && segments.length > 2 ? valueAt(STEP_DEFAULTS, segments.slice(2)) : valueAt(DEFAULT_CONFIG, segments);
|
|
702
934
|
if (example === void 0 && typeof segments.at(-1) === "number") {
|
|
703
935
|
const list = valueAt(DEFAULT_CONFIG, segments.slice(0, -1));
|
|
704
936
|
if (Array.isArray(list)) example = list[0];
|
|
@@ -711,6 +943,28 @@ function problemToIssue(problem, document) {
|
|
|
711
943
|
const segments = pointerSegments(problem.pointer, document);
|
|
712
944
|
if (problem.kind === "unknown" && problem.property !== void 0) {
|
|
713
945
|
const option = [...segments, problem.property];
|
|
946
|
+
if (isRemovedCustomOption(segments, problem.property)) {
|
|
947
|
+
return issue2("CONFIG_UNKNOWN_OPTION", option, "unknown option", REMOVED_CUSTOM_HINT);
|
|
948
|
+
}
|
|
949
|
+
if (problem.property === "keepQuotedValues" && segments.length === 2 && segments[0] === "measure" && segments[1] === "steps") {
|
|
950
|
+
return issue2(
|
|
951
|
+
"CONFIG_UNKNOWN_OPTION",
|
|
952
|
+
option,
|
|
953
|
+
"unknown option",
|
|
954
|
+
"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."
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
if (problem.property === "repeat" && segments.length === 1 && segments[0] === "run") {
|
|
958
|
+
return issue2(
|
|
959
|
+
"CONFIG_UNKNOWN_OPTION",
|
|
960
|
+
option,
|
|
961
|
+
"unknown option",
|
|
962
|
+
"Renamed to run.passes: the test command now runs once per pass (repeatEach is 1); e.g. run: { passes: { test: 5, thresholds: 10 } }."
|
|
963
|
+
);
|
|
964
|
+
}
|
|
965
|
+
if (problem.property === "warnOnly" && segments.length === 1 && segments[0] === "gate") {
|
|
966
|
+
return issue2("CONFIG_UNKNOWN_OPTION", option, "unknown option", REMOVED_WARN_ONLY_HINT);
|
|
967
|
+
}
|
|
714
968
|
const suggestion = suggestOption(segments, problem.property);
|
|
715
969
|
return issue2(
|
|
716
970
|
"CONFIG_UNKNOWN_OPTION",
|
|
@@ -734,8 +988,8 @@ function schemaIssues(document) {
|
|
|
734
988
|
}
|
|
735
989
|
function regexIssues(document) {
|
|
736
990
|
const issues = [];
|
|
737
|
-
for (const
|
|
738
|
-
const list = valueAt(document,
|
|
991
|
+
for (const path of PATTERN_LISTS) {
|
|
992
|
+
const list = valueAt(document, path);
|
|
739
993
|
if (!Array.isArray(list)) continue;
|
|
740
994
|
list.forEach((item, index) => {
|
|
741
995
|
if (!isRecord(item) || typeof item.regex !== "string") return;
|
|
@@ -747,7 +1001,7 @@ function regexIssues(document) {
|
|
|
747
1001
|
issues.push(
|
|
748
1002
|
issue2(
|
|
749
1003
|
"CONFIG_INVALID_REGEX",
|
|
750
|
-
[
|
|
1004
|
+
[...path, index],
|
|
751
1005
|
`regular expression does not compile (${reason})`,
|
|
752
1006
|
'Fix the expression; it uses JavaScript RegExp syntax, e.g. { "regex": "^/api/v[0-9]+/", "flags": "i" }.'
|
|
753
1007
|
)
|
|
@@ -755,6 +1009,22 @@ function regexIssues(document) {
|
|
|
755
1009
|
}
|
|
756
1010
|
});
|
|
757
1011
|
}
|
|
1012
|
+
const grep = valueAt(document, ["run", "grep"]);
|
|
1013
|
+
if (typeof grep === "string" && grep !== "") {
|
|
1014
|
+
try {
|
|
1015
|
+
new RegExp(grep, "i");
|
|
1016
|
+
} catch (error) {
|
|
1017
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
1018
|
+
issues.push(
|
|
1019
|
+
issue2(
|
|
1020
|
+
"CONFIG_INVALID_REGEX",
|
|
1021
|
+
["run", "grep"],
|
|
1022
|
+
`regular expression does not compile (${reason})`,
|
|
1023
|
+
"Fix the expression; it uses JavaScript RegExp syntax, e.g. '@perf' or '@perf|@smoke'."
|
|
1024
|
+
)
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
758
1028
|
return issues;
|
|
759
1029
|
}
|
|
760
1030
|
var numberAt = (config, segments) => {
|
|
@@ -769,7 +1039,7 @@ var RULES = [
|
|
|
769
1039
|
["checks", "slowShare", "wilson"],
|
|
770
1040
|
["checks", "errors"]
|
|
771
1041
|
];
|
|
772
|
-
var KINDS = ["api", "
|
|
1042
|
+
var KINDS = ["api", "step"];
|
|
773
1043
|
var MIN_PERCENTILE = 50;
|
|
774
1044
|
function percentileLevel(name) {
|
|
775
1045
|
if (typeof name !== "string" || !/^p\d+(?:\.\d)?$/u.test(name)) return void 0;
|
|
@@ -839,21 +1109,69 @@ function relationalIssues(config, isSet) {
|
|
|
839
1109
|
);
|
|
840
1110
|
}
|
|
841
1111
|
const enabled2 = RULES.some((rule) => valueAt(config, [...rule, "enabled"]) !== false);
|
|
842
|
-
if (!enabled2
|
|
1112
|
+
if (!enabled2) {
|
|
843
1113
|
errors.push(
|
|
844
1114
|
issue2(
|
|
845
1115
|
"CONFIG_INVALID_VALUE",
|
|
846
1116
|
["checks"],
|
|
847
1117
|
"every rule is disabled, so nothing would be checked",
|
|
848
|
-
"Enable at least one rule in checks
|
|
1118
|
+
"Enable at least one rule in checks."
|
|
1119
|
+
)
|
|
1120
|
+
);
|
|
1121
|
+
}
|
|
1122
|
+
const steps = valueAt(config, ["measure", "steps"]);
|
|
1123
|
+
const stepsOff = steps === false || isRecord(steps) && steps["enabled"] === false;
|
|
1124
|
+
if (valueAt(config, ["measure", "api"]) === false && stepsOff) {
|
|
1125
|
+
errors.push(
|
|
1126
|
+
issue2(
|
|
1127
|
+
"CONFIG_INVALID_VALUE",
|
|
1128
|
+
["measure"],
|
|
1129
|
+
"measure.api and measure.steps are both off, so nothing would be measured",
|
|
1130
|
+
"Turn on at least one of them: measure.api (backend requests) or measure.steps (test.step durations)."
|
|
849
1131
|
)
|
|
850
1132
|
);
|
|
851
1133
|
}
|
|
1134
|
+
const env = valueAt(config, ["run", "env"]);
|
|
1135
|
+
if (typeof env === "string" && RESERVED_ENV_LABELS.includes(env)) {
|
|
1136
|
+
errors.push(reservedEnvIssue(["run", "env"], env));
|
|
1137
|
+
}
|
|
1138
|
+
const originMap = valueAt(config, ["keys", "origins"]);
|
|
1139
|
+
if (isRecord(originMap)) {
|
|
1140
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1141
|
+
for (const [key2, label] of Object.entries(originMap)) {
|
|
1142
|
+
if (!isHostPattern(key2) || typeof label !== "string") continue;
|
|
1143
|
+
const parsed = parseHostPattern(key2, label);
|
|
1144
|
+
if (typeof parsed === "string") {
|
|
1145
|
+
errors.push(
|
|
1146
|
+
issue2(
|
|
1147
|
+
"CONFIG_INVALID_VALUE",
|
|
1148
|
+
["keys", "origins", key2],
|
|
1149
|
+
parsed,
|
|
1150
|
+
'Write a host pattern like "https://*.ci.example.com": one "*" inside a host label, a top-level domain without "*" (docs/dynamic-environments.md).'
|
|
1151
|
+
)
|
|
1152
|
+
);
|
|
1153
|
+
continue;
|
|
1154
|
+
}
|
|
1155
|
+
const other = seen.get(parsed.canonical);
|
|
1156
|
+
if (other !== void 0) {
|
|
1157
|
+
errors.push(
|
|
1158
|
+
issue2(
|
|
1159
|
+
"CONFIG_INVALID_VALUE",
|
|
1160
|
+
["keys", "origins", key2],
|
|
1161
|
+
`the host pattern is the same as ${JSON.stringify(other)} after canonicalization (${parsed.canonical})`,
|
|
1162
|
+
"Keep one of the two patterns."
|
|
1163
|
+
)
|
|
1164
|
+
);
|
|
1165
|
+
} else {
|
|
1166
|
+
seen.set(parsed.canonical, key2);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
852
1170
|
const origins = valueAt(config, ["keys", "origins"]);
|
|
853
1171
|
if (isRecord(origins)) {
|
|
854
1172
|
const byLabel = /* @__PURE__ */ new Map();
|
|
855
1173
|
for (const [origin, label] of Object.entries(origins)) {
|
|
856
|
-
if (typeof label !== "string") continue;
|
|
1174
|
+
if (typeof label !== "string" || isHostPattern(origin)) continue;
|
|
857
1175
|
byLabel.set(label, [...byLabel.get(label) ?? [], origin]);
|
|
858
1176
|
}
|
|
859
1177
|
for (const [label, list] of byLabel) {
|
|
@@ -884,7 +1202,7 @@ function relationalIssues(config, isSet) {
|
|
|
884
1202
|
|
|
885
1203
|
// src/core/config/resolve.ts
|
|
886
1204
|
var KEY_BUILDER_SNAPSHOT = "[function]";
|
|
887
|
-
var
|
|
1205
|
+
var passesSchema = int({ minimum: 1, maximum: 1e3 });
|
|
888
1206
|
function isPlainObject(value) {
|
|
889
1207
|
if (!isRecord(value)) return false;
|
|
890
1208
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -1005,13 +1323,13 @@ function overrideIssues(overrides) {
|
|
|
1005
1323
|
)
|
|
1006
1324
|
);
|
|
1007
1325
|
}
|
|
1008
|
-
if (overrides.
|
|
1326
|
+
if (overrides.passes !== void 0 && !matches(passesSchema, overrides.passes)) {
|
|
1009
1327
|
issues.push(
|
|
1010
1328
|
issue2(
|
|
1011
1329
|
"CONFIG_INVALID_VALUE",
|
|
1012
|
-
["run", "
|
|
1013
|
-
`the
|
|
1014
|
-
"Fix the number of
|
|
1330
|
+
["run", "passes", overrides.mode ?? "test"],
|
|
1331
|
+
`the passes override must be an integer from 1 to 1000, got ${describeValue(overrides.passes)}`,
|
|
1332
|
+
"Fix the number of passes, e.g. 5."
|
|
1015
1333
|
)
|
|
1016
1334
|
);
|
|
1017
1335
|
}
|
|
@@ -1019,8 +1337,13 @@ function overrideIssues(overrides) {
|
|
|
1019
1337
|
}
|
|
1020
1338
|
function applyOverrides(config, overrides) {
|
|
1021
1339
|
if (overrides.env !== void 0) config.run.env = overrides.env;
|
|
1022
|
-
if (overrides.
|
|
1023
|
-
|
|
1340
|
+
if (overrides.thresholdsDir !== void 0) config.thresholds.dir = overrides.thresholdsDir;
|
|
1341
|
+
if (overrides.minSamples !== void 0) {
|
|
1342
|
+
const median = config.checks.time.median;
|
|
1343
|
+
median.minSamples = Math.min(median.minSamples, overrides.minSamples);
|
|
1344
|
+
}
|
|
1345
|
+
if (overrides.passes !== void 0) {
|
|
1346
|
+
config.run.passes[overrides.mode === "thresholds" ? "thresholds" : "test"] = overrides.passes;
|
|
1024
1347
|
}
|
|
1025
1348
|
}
|
|
1026
1349
|
function snapshotPattern(pattern) {
|
|
@@ -1042,13 +1365,15 @@ function resolveConfig(input, overrides) {
|
|
|
1042
1365
|
...overrideIssues(overrides)
|
|
1043
1366
|
];
|
|
1044
1367
|
const { $schema: _schema, ...withoutSchema } = isRecord(document) ? document : {};
|
|
1045
|
-
const
|
|
1368
|
+
const defaults = merge(DEFAULT_CONFIG, presetLayer(presetOf(withoutSchema)));
|
|
1369
|
+
const merged = merge(defaults, withoutSchema);
|
|
1046
1370
|
if (errors.length === 0) applyOverrides(merged, overrides);
|
|
1047
1371
|
const relational = relationalIssues(merged, (path) => order.has(formatPath(path)));
|
|
1048
1372
|
errors.push(...relational.errors);
|
|
1049
1373
|
if (errors.length > 0) return { ok: false, issues: sortByInput(errors, order) };
|
|
1050
|
-
|
|
1051
|
-
|
|
1374
|
+
merged.measure.steps = expandSteps(merged.measure.steps);
|
|
1375
|
+
for (const path of PATTERN_LISTS) {
|
|
1376
|
+
const list = valueAt(merged, path);
|
|
1052
1377
|
list.splice(0, list.length, ...list.map(snapshotPattern));
|
|
1053
1378
|
}
|
|
1054
1379
|
if (keyBuilder.inSnapshot) merged.keys.keyBuilder = KEY_BUILDER_SNAPSHOT;
|
|
@@ -1060,7 +1385,12 @@ function resolveConfig(input, overrides) {
|
|
|
1060
1385
|
measure: {
|
|
1061
1386
|
...copy.measure,
|
|
1062
1387
|
include: snapshot.measure.include.map(compilePattern),
|
|
1063
|
-
exclude: snapshot.measure.exclude.map(compilePattern)
|
|
1388
|
+
exclude: snapshot.measure.exclude.map(compilePattern),
|
|
1389
|
+
steps: {
|
|
1390
|
+
...copy.measure.steps,
|
|
1391
|
+
include: snapshot.measure.steps.include.map(compilePattern),
|
|
1392
|
+
exclude: snapshot.measure.steps.exclude.map(compilePattern)
|
|
1393
|
+
}
|
|
1064
1394
|
},
|
|
1065
1395
|
keys: {
|
|
1066
1396
|
...clone(keys),
|
|
@@ -1096,11 +1426,13 @@ function resolveDefaults() {
|
|
|
1096
1426
|
}
|
|
1097
1427
|
var perfDefaults = deepFreeze(resolveDefaults());
|
|
1098
1428
|
|
|
1429
|
+
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
|
1099
1430
|
exports.Sink = Sink;
|
|
1100
1431
|
exports.anyObject = anyObject;
|
|
1101
1432
|
exports.arr = arr;
|
|
1102
1433
|
exports.bool = bool;
|
|
1103
1434
|
exports.child = child;
|
|
1435
|
+
exports.compileHostPatterns = compileHostPatterns;
|
|
1104
1436
|
exports.constant = constant;
|
|
1105
1437
|
exports.count = count;
|
|
1106
1438
|
exports.definePerfConfig = definePerfConfig;
|
|
@@ -1109,14 +1441,17 @@ exports.enumOf = enumOf;
|
|
|
1109
1441
|
exports.envLabelOrNull = envLabelOrNull;
|
|
1110
1442
|
exports.epochMs = epochMs;
|
|
1111
1443
|
exports.evaluationStatus = evaluationStatus;
|
|
1444
|
+
exports.expandSteps = expandSteps;
|
|
1112
1445
|
exports.fingerprint = fingerprint;
|
|
1113
1446
|
exports.hostFingerprint = hostFingerprint;
|
|
1114
1447
|
exports.int = int;
|
|
1448
|
+
exports.isHostPattern = isHostPattern;
|
|
1115
1449
|
exports.isRecord = isRecord;
|
|
1116
1450
|
exports.isoDate = isoDate;
|
|
1117
1451
|
exports.issue = issue;
|
|
1118
1452
|
exports.key = key;
|
|
1119
1453
|
exports.kind = kind;
|
|
1454
|
+
exports.matchingPattern = matchingPattern;
|
|
1120
1455
|
exports.mode = mode;
|
|
1121
1456
|
exports.ms = ms;
|
|
1122
1457
|
exports.msLimit = msLimit;
|