@plune-ai/playwright 0.6.0 → 0.7.0

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 CHANGED
@@ -50,6 +50,7 @@ fills in what you left out. Anything set in the config file wins.
50
50
  |---|---|
51
51
  | `PLUNE_TOKEN` | the API token — so a CI job need not run `plune login` |
52
52
  | `PLUNE_RUN` | the shared run key: every process with the same value lands in one run |
53
+ | `PLUNE_CONFIGURATION` | the combination this job runs, `Browser=Chrome;Operating system=Windows`: its results land under that combination of the run (see [A matrix](#a-matrix-one-run-a-combination-per-job)) |
53
54
  | `PLUNE_API_URL` | the deployment to report to |
54
55
  | `PLUNE_SHARED_RUN` | this process is one of several — do not close the run |
55
56
  | `PLUNE_SHARD` | `k/N`: this process is shard k of N; it reports itself done and the run closes when all N have (implies `PLUNE_SHARED_RUN`) |
@@ -102,6 +103,40 @@ A shard **never closes the run** — it cannot know the others have finished. Wh
102
103
  closes it: your `merge-reports` step, or `plune run finish <id>`. Until then the run reads as
103
104
  still running, which is the truth.
104
105
 
106
+ ## A matrix: one run, a combination per job
107
+
108
+ The jobs of a matrix of browsers and systems report into one run, each under its own combination of
109
+ configuration values, when they share `PLUNE_RUN` and each names its cell in `PLUNE_CONFIGURATION`:
110
+
111
+ ```yaml
112
+ strategy:
113
+ matrix:
114
+ browser: [Chrome, Firefox]
115
+ os: [Windows, macOS]
116
+ env:
117
+ PLUNE_RUN: ${{ github.run_id }}-${{ github.run_attempt }}
118
+ PLUNE_SHARED_RUN: 1
119
+ PLUNE_CONFIGURATION: "Browser=${{ matrix.browser }};Operating system=${{ matrix.os }}"
120
+ ```
121
+
122
+ `PLUNE_SHARED_RUN` keeps each job from closing the run its siblings still report into; close it
123
+ once at the end with `plune run finish <id>`.
124
+
125
+ `PLUNE_CONFIGURATION` is `Group=Value` pairs split by `;`, with the names of the groups and values
126
+ as in Settings → Configurations. Case does not matter, spaces around a name or a value are dropped,
127
+ and so is an empty pair (`;;`, a `;` at the end); a value may hold `=`, since a pair splits at its
128
+ first one. Every results batch carries it, and Plune files the results under that combination of the
129
+ run: one the run already has (a run launched from the dashboard with configurations, joined by its
130
+ key), or one it adds. A value that is not in Settings is taken as sent, marked "not in the list".
131
+ Unset or blank, the batch is sent as before.
132
+
133
+ - A pair without `=`, without a group or without a value, or one group named twice, is a
134
+ configuration error: the reporter sends nothing and says why.
135
+ - Every job of a run names the same groups. Plune refuses with 422 a batch that names other groups,
136
+ or one that would take the run past its limits (25 combinations, 40 000 results to expect); the
137
+ reporter prints the platform's message as it came, and the batch goes to the fallback file, which
138
+ keeps the combination for `plune run report`.
139
+
105
140
  ## How a result finds its test case
106
141
 
107
142
  In order, first match wins:
package/dist/index.cjs CHANGED
@@ -305,6 +305,25 @@ function shardOf(env) {
305
305
  error: `PLUNE_SHARD=${JSON.stringify(raw.slice(0, 40))} is not "k/N" with 1 <= k <= N <= ${SHARDS_MAX} (for example 2/4) - nothing was sent.`
306
306
  };
307
307
  }
308
+ function configurationOf(env) {
309
+ const raw = value(env, "PLUNE_CONFIGURATION");
310
+ if (raw === void 0) return {};
311
+ const pairs = [];
312
+ for (const pair of raw.split(";").map((s) => s.trim()).filter((s) => s !== "")) {
313
+ const at = pair.indexOf("=");
314
+ const name = at < 0 ? "" : pair.slice(0, at).trim();
315
+ const label = at < 0 ? "" : pair.slice(at + 1).trim();
316
+ const twice = pairs.find(([seen]) => seen.toLowerCase() === name.toLowerCase());
317
+ const why = at < 0 ? 'has no "="' : name === "" ? "has no group name" : label === "" ? "has no value" : twice !== void 0 ? `names the group ${JSON.stringify(twice[0])} a second time` : void 0;
318
+ if (why !== void 0) {
319
+ return {
320
+ error: `PLUNE_CONFIGURATION: ${JSON.stringify(pair.slice(0, 40))} ${why} - write it as "Group=Value;Group=Value" (for example "Browser=Chrome;Operating system=Windows") - nothing was sent.`
321
+ };
322
+ }
323
+ pairs.push([name, label]);
324
+ }
325
+ return pairs.length === 0 ? {} : { configuration: Object.fromEntries(pairs) };
326
+ }
308
327
  var UPLOAD_CONCURRENCY = { min: 1, max: 32, default: 16 };
309
328
  var UPLOAD_RETRIES = { min: 0, max: 20, default: 6 };
310
329
  var IMPORT_TIMEOUT = { min: 0, max: 86400, default: 600 };
@@ -352,6 +371,7 @@ function readEnv(env = process.env) {
352
371
  const offerDiscovered = flag(env, "PLUNE_CREATE");
353
372
  const full = flag(env, "PLUNE_FULL_RUN");
354
373
  const { shard, error: shardError } = shardOf(env);
374
+ const { configuration, error: configurationError } = configurationOf(env);
355
375
  return {
356
376
  config: {
357
377
  ...externalKey !== void 0 ? { externalKey } : {},
@@ -364,6 +384,7 @@ function readEnv(env = process.env) {
364
384
  ...title !== void 0 ? { title } : {},
365
385
  ...environment !== void 0 ? { environment } : {},
366
386
  ...labels !== void 0 ? { labels } : {},
387
+ ...configuration !== void 0 ? { configuration } : {},
367
388
  // Only when set: `false` here would outrank a config file that asked for it, and an unset
368
389
  // variable is not an instruction.
369
390
  ...offerDiscovered ? { offerDiscovered } : {},
@@ -377,6 +398,7 @@ function readEnv(env = process.env) {
377
398
  keepOpen: flag(env, "PLUNE_SHARED_RUN") || flag(env, "PLUNE_PROCEED") || shard !== void 0 || shardError !== void 0,
378
399
  ...shard !== void 0 ? { shard } : {},
379
400
  ...shardError !== void 0 ? { shardError } : {},
401
+ ...configurationError !== void 0 ? { configurationError } : {},
380
402
  ...importTimeout !== void 0 ? { importTimeout } : {},
381
403
  ignored: UNSUPPORTED_VARS.filter((name) => value(env, name) !== void 0),
382
404
  warnings
@@ -570,6 +592,7 @@ function appendBatch(file, batch) {
570
592
  externalKey: batch.externalKey,
571
593
  ...batch.session !== void 0 ? { session: batch.session } : {},
572
594
  ...batch.meta !== void 0 ? { meta: batch.meta } : {},
595
+ ...batch.configuration !== void 0 ? { configuration: batch.configuration } : {},
573
596
  results: batch.results
574
597
  };
575
598
  fs.appendFileSync(file, `${JSON.stringify(line)}
@@ -718,8 +741,10 @@ function warnIfDropped(sent, run, log) {
718
741
  async function startRun(passed, declared2) {
719
742
  const env = readEnv();
720
743
  if (env.shardError !== void 0) throw new Error(env.shardError);
744
+ if (env.configurationError !== void 0 && passed.configuration === void 0) throw new Error(env.configurationError);
721
745
  const stated = Object.fromEntries(Object.entries(passed).filter(([, v]) => v !== void 0));
722
746
  const cfg = { ...env.config, ...stated };
747
+ const configuration = cfg.configuration !== void 0 && Object.keys(cfg.configuration).length > 0 ? cfg.configuration : void 0;
723
748
  const log = cfg.log ?? ((line) => void process.stderr.write(`${line}
724
749
  `));
725
750
  const fallbackPath = cfg.fallbackPath ?? DEFAULT_FALLBACK_PATH;
@@ -803,6 +828,7 @@ async function startRun(passed, declared2) {
803
828
  externalKey,
804
829
  session: sessionMarker,
805
830
  ...cfg.meta !== void 0 ? { meta: cfg.meta } : {},
831
+ ...configuration !== void 0 ? { configuration } : {},
806
832
  results: results.map(onDisk)
807
833
  });
808
834
  stats.deferred += results.length;
@@ -827,7 +853,7 @@ async function startRun(passed, declared2) {
827
853
  if (!offline) {
828
854
  if (expected !== void 0) await resolveKeys(expected.flat());
829
855
  const stated2 = expected?.slice(0, EXPECTED_MAX) ?? [];
830
- const configuration = stated2.length === 0 ? void 0 : {
856
+ const configuration2 = stated2.length === 0 ? void 0 : {
831
857
  expected: stated2.flatMap((keys) => {
832
858
  const hit = keys.map((k) => resolved.get(k.value)).find((v) => typeof v === "string");
833
859
  if (typeof hit === "string") return [{ testCaseId: hit }];
@@ -851,7 +877,7 @@ async function startRun(passed, declared2) {
851
877
  kind: cfg.kind ?? "automated",
852
878
  ...externalKey !== null ? { externalKey } : {},
853
879
  ...cfg.meta !== void 0 ? { meta: cfg.meta } : {},
854
- ...configuration !== void 0 ? { configuration } : {},
880
+ ...configuration2 !== void 0 ? { configuration: configuration2 } : {},
855
881
  // Named even when nobody named it — the list has to read without opening a row. Only what
856
882
  // the caller DESCRIBED goes to `warnIfDropped` below: a title this side invented is not one
857
883
  // a person will miss, and a deployment older than the field must not be nagged on every run.
@@ -859,7 +885,7 @@ async function startRun(passed, declared2) {
859
885
  ...described
860
886
  };
861
887
  let start = await client.post("/v1/runs", request);
862
- if (!start.ok && start.status === 413 && configuration !== void 0) {
888
+ if (!start.ok && start.status === 413 && configuration2 !== void 0) {
863
889
  log(
864
890
  `plune: the platform refused the run's list of expected tests as too large (${start.detail || start.kind}) \u2014 starting without it: the results still land, but this run counts no tests that did not run, and claims no full run.`
865
891
  );
@@ -1405,7 +1431,8 @@ async function startRun(passed, declared2) {
1405
1431
  }
1406
1432
  const out = await client.post(
1407
1433
  `/v1/runs/${runId}/results`,
1408
- { results: part }
1434
+ // The job's combination on every batch (plune-ai/plune#1251); a refusal of it is a 422 said below as it came.
1435
+ { results: part, ...configuration !== void 0 ? { configuration } : {} }
1409
1436
  );
1410
1437
  const counts = out.ok ? out.body?.counts : void 0;
1411
1438
  const told = COUNTED.filter((k) => typeof counts?.[k] === "number");
package/dist/index.js CHANGED
@@ -271,6 +271,25 @@ function shardOf(env) {
271
271
  error: `PLUNE_SHARD=${JSON.stringify(raw.slice(0, 40))} is not "k/N" with 1 <= k <= N <= ${SHARDS_MAX} (for example 2/4) - nothing was sent.`
272
272
  };
273
273
  }
274
+ function configurationOf(env) {
275
+ const raw = value(env, "PLUNE_CONFIGURATION");
276
+ if (raw === void 0) return {};
277
+ const pairs = [];
278
+ for (const pair of raw.split(";").map((s) => s.trim()).filter((s) => s !== "")) {
279
+ const at = pair.indexOf("=");
280
+ const name = at < 0 ? "" : pair.slice(0, at).trim();
281
+ const label = at < 0 ? "" : pair.slice(at + 1).trim();
282
+ const twice = pairs.find(([seen]) => seen.toLowerCase() === name.toLowerCase());
283
+ const why = at < 0 ? 'has no "="' : name === "" ? "has no group name" : label === "" ? "has no value" : twice !== void 0 ? `names the group ${JSON.stringify(twice[0])} a second time` : void 0;
284
+ if (why !== void 0) {
285
+ return {
286
+ error: `PLUNE_CONFIGURATION: ${JSON.stringify(pair.slice(0, 40))} ${why} - write it as "Group=Value;Group=Value" (for example "Browser=Chrome;Operating system=Windows") - nothing was sent.`
287
+ };
288
+ }
289
+ pairs.push([name, label]);
290
+ }
291
+ return pairs.length === 0 ? {} : { configuration: Object.fromEntries(pairs) };
292
+ }
274
293
  var UPLOAD_CONCURRENCY = { min: 1, max: 32, default: 16 };
275
294
  var UPLOAD_RETRIES = { min: 0, max: 20, default: 6 };
276
295
  var IMPORT_TIMEOUT = { min: 0, max: 86400, default: 600 };
@@ -318,6 +337,7 @@ function readEnv(env = process.env) {
318
337
  const offerDiscovered = flag(env, "PLUNE_CREATE");
319
338
  const full = flag(env, "PLUNE_FULL_RUN");
320
339
  const { shard, error: shardError } = shardOf(env);
340
+ const { configuration, error: configurationError } = configurationOf(env);
321
341
  return {
322
342
  config: {
323
343
  ...externalKey !== void 0 ? { externalKey } : {},
@@ -330,6 +350,7 @@ function readEnv(env = process.env) {
330
350
  ...title !== void 0 ? { title } : {},
331
351
  ...environment !== void 0 ? { environment } : {},
332
352
  ...labels !== void 0 ? { labels } : {},
353
+ ...configuration !== void 0 ? { configuration } : {},
333
354
  // Only when set: `false` here would outrank a config file that asked for it, and an unset
334
355
  // variable is not an instruction.
335
356
  ...offerDiscovered ? { offerDiscovered } : {},
@@ -343,6 +364,7 @@ function readEnv(env = process.env) {
343
364
  keepOpen: flag(env, "PLUNE_SHARED_RUN") || flag(env, "PLUNE_PROCEED") || shard !== void 0 || shardError !== void 0,
344
365
  ...shard !== void 0 ? { shard } : {},
345
366
  ...shardError !== void 0 ? { shardError } : {},
367
+ ...configurationError !== void 0 ? { configurationError } : {},
346
368
  ...importTimeout !== void 0 ? { importTimeout } : {},
347
369
  ignored: UNSUPPORTED_VARS.filter((name) => value(env, name) !== void 0),
348
370
  warnings
@@ -536,6 +558,7 @@ function appendBatch(file, batch) {
536
558
  externalKey: batch.externalKey,
537
559
  ...batch.session !== void 0 ? { session: batch.session } : {},
538
560
  ...batch.meta !== void 0 ? { meta: batch.meta } : {},
561
+ ...batch.configuration !== void 0 ? { configuration: batch.configuration } : {},
539
562
  results: batch.results
540
563
  };
541
564
  fs.appendFileSync(file, `${JSON.stringify(line)}
@@ -684,8 +707,10 @@ function warnIfDropped(sent, run, log) {
684
707
  async function startRun(passed, declared2) {
685
708
  const env = readEnv();
686
709
  if (env.shardError !== void 0) throw new Error(env.shardError);
710
+ if (env.configurationError !== void 0 && passed.configuration === void 0) throw new Error(env.configurationError);
687
711
  const stated = Object.fromEntries(Object.entries(passed).filter(([, v]) => v !== void 0));
688
712
  const cfg = { ...env.config, ...stated };
713
+ const configuration = cfg.configuration !== void 0 && Object.keys(cfg.configuration).length > 0 ? cfg.configuration : void 0;
689
714
  const log = cfg.log ?? ((line) => void process.stderr.write(`${line}
690
715
  `));
691
716
  const fallbackPath = cfg.fallbackPath ?? DEFAULT_FALLBACK_PATH;
@@ -769,6 +794,7 @@ async function startRun(passed, declared2) {
769
794
  externalKey,
770
795
  session: sessionMarker,
771
796
  ...cfg.meta !== void 0 ? { meta: cfg.meta } : {},
797
+ ...configuration !== void 0 ? { configuration } : {},
772
798
  results: results.map(onDisk)
773
799
  });
774
800
  stats.deferred += results.length;
@@ -793,7 +819,7 @@ async function startRun(passed, declared2) {
793
819
  if (!offline) {
794
820
  if (expected !== void 0) await resolveKeys(expected.flat());
795
821
  const stated2 = expected?.slice(0, EXPECTED_MAX) ?? [];
796
- const configuration = stated2.length === 0 ? void 0 : {
822
+ const configuration2 = stated2.length === 0 ? void 0 : {
797
823
  expected: stated2.flatMap((keys) => {
798
824
  const hit = keys.map((k) => resolved.get(k.value)).find((v) => typeof v === "string");
799
825
  if (typeof hit === "string") return [{ testCaseId: hit }];
@@ -817,7 +843,7 @@ async function startRun(passed, declared2) {
817
843
  kind: cfg.kind ?? "automated",
818
844
  ...externalKey !== null ? { externalKey } : {},
819
845
  ...cfg.meta !== void 0 ? { meta: cfg.meta } : {},
820
- ...configuration !== void 0 ? { configuration } : {},
846
+ ...configuration2 !== void 0 ? { configuration: configuration2 } : {},
821
847
  // Named even when nobody named it — the list has to read without opening a row. Only what
822
848
  // the caller DESCRIBED goes to `warnIfDropped` below: a title this side invented is not one
823
849
  // a person will miss, and a deployment older than the field must not be nagged on every run.
@@ -825,7 +851,7 @@ async function startRun(passed, declared2) {
825
851
  ...described
826
852
  };
827
853
  let start = await client.post("/v1/runs", request);
828
- if (!start.ok && start.status === 413 && configuration !== void 0) {
854
+ if (!start.ok && start.status === 413 && configuration2 !== void 0) {
829
855
  log(
830
856
  `plune: the platform refused the run's list of expected tests as too large (${start.detail || start.kind}) \u2014 starting without it: the results still land, but this run counts no tests that did not run, and claims no full run.`
831
857
  );
@@ -1371,7 +1397,8 @@ async function startRun(passed, declared2) {
1371
1397
  }
1372
1398
  const out = await client.post(
1373
1399
  `/v1/runs/${runId}/results`,
1374
- { results: part }
1400
+ // The job's combination on every batch (plune-ai/plune#1251); a refusal of it is a 422 said below as it came.
1401
+ { results: part, ...configuration !== void 0 ? { configuration } : {} }
1375
1402
  );
1376
1403
  const counts = out.ok ? out.body?.counts : void 0;
1377
1404
  const told = COUNTED.filter((k) => typeof counts?.[k] === "number");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plune-ai/playwright",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Report Playwright results to Plune — a reporter and, later, a test importer.",
5
5
  "keywords": [
6
6
  "playwright",
@@ -38,7 +38,7 @@
38
38
  "tsup": "^8.0.0",
39
39
  "typescript": "^5.4.0",
40
40
  "vitest": "^1.6.0",
41
- "@plune-ai/cli": "0.30.1"
41
+ "@plune-ai/cli": "0.31.0"
42
42
  },
43
43
  "repository": {
44
44
  "type": "git",