@plune-ai/playwright 0.3.0 → 0.4.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/dist/index.cjs +42 -2
- package/dist/index.js +43 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -236,6 +236,28 @@ function defaultRunTitle(env = process.env, now = /* @__PURE__ */ new Date(), cw
|
|
|
236
236
|
const where = flag(env, "CI") || flag(env, "GITHUB_ACTIONS") ? "ci" : "local";
|
|
237
237
|
return `${path.basename(cwd)} \xB7 ${stamp} \xB7 ${where}`;
|
|
238
238
|
}
|
|
239
|
+
var PROVIDERS = [
|
|
240
|
+
{ is: "GITHUB_ACTIONS", sha: "GITHUB_SHA", branch: ["GITHUB_HEAD_REF", "GITHUB_REF_NAME"] },
|
|
241
|
+
{ is: "GITLAB_CI", sha: "CI_COMMIT_SHA", branch: ["CI_COMMIT_REF_NAME"] },
|
|
242
|
+
{ is: "JENKINS_URL", sha: "GIT_COMMIT", branch: ["GIT_BRANCH"] }
|
|
243
|
+
];
|
|
244
|
+
function ciCommit(reported, env = process.env) {
|
|
245
|
+
const said = typeof reported === "object" && reported !== null ? reported : {};
|
|
246
|
+
const text = (raw) => typeof raw === "string" && raw.trim() !== "" ? raw.trim() : void 0;
|
|
247
|
+
const provider = PROVIDERS.find((p) => value(env, p.is) !== void 0);
|
|
248
|
+
const job = {
|
|
249
|
+
sha: provider === void 0 ? void 0 : value(env, provider.sha),
|
|
250
|
+
branch: provider?.branch.map((name) => value(env, name)).find((v) => v !== void 0)
|
|
251
|
+
};
|
|
252
|
+
const sha = text(said["commitHash"]);
|
|
253
|
+
const sameCommit = sha === void 0 || sha === job.sha;
|
|
254
|
+
const commit = sha ?? job.sha;
|
|
255
|
+
const branch = text(said["branch"]) ?? (sameCommit ? job.branch : void 0);
|
|
256
|
+
return {
|
|
257
|
+
...commit !== void 0 ? { sha: commit } : {},
|
|
258
|
+
...branch !== void 0 ? { branch } : {}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
239
261
|
var DEFAULT_FALLBACK_PATH = path2.join(".plune", "pending-results.jsonl");
|
|
240
262
|
function appendBatch(file, batch) {
|
|
241
263
|
fs.mkdirSync(path2.dirname(file), { recursive: true });
|
|
@@ -243,6 +265,8 @@ function appendBatch(file, batch) {
|
|
|
243
265
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
244
266
|
runId: batch.runId,
|
|
245
267
|
externalKey: batch.externalKey,
|
|
268
|
+
...batch.session !== void 0 ? { session: batch.session } : {},
|
|
269
|
+
...batch.meta !== void 0 ? { meta: batch.meta } : {},
|
|
246
270
|
results: batch.results
|
|
247
271
|
};
|
|
248
272
|
fs.appendFileSync(file, `${JSON.stringify(line)}
|
|
@@ -294,6 +318,12 @@ function boundKey(key) {
|
|
|
294
318
|
if (/[\uD800-\uDBFF]$/.test(head)) head = head.slice(0, -1);
|
|
295
319
|
return { ...key, value: `${head}#${digest}` };
|
|
296
320
|
}
|
|
321
|
+
function whyUnoffered(out) {
|
|
322
|
+
if (out.ok || out.status !== 429) return "other";
|
|
323
|
+
if (/review queue quota reached/i.test(out.detail)) return "queue";
|
|
324
|
+
if (/test case quota reached/i.test(out.detail)) return "cases";
|
|
325
|
+
return "other";
|
|
326
|
+
}
|
|
297
327
|
function boundTitle(title) {
|
|
298
328
|
return title.length <= TITLE_MAX ? title : `${title.slice(0, TITLE_MAX - 1)}\u2026`;
|
|
299
329
|
}
|
|
@@ -337,6 +367,7 @@ async function startRun(passed, declared2) {
|
|
|
337
367
|
`));
|
|
338
368
|
const fallbackPath = cfg.fallbackPath ?? DEFAULT_FALLBACK_PATH;
|
|
339
369
|
const externalKey = cfg.externalKey ?? null;
|
|
370
|
+
const sessionMarker = (0, import_crypto.randomUUID)();
|
|
340
371
|
const batchSize = Math.min(cfg.batchSize ?? BATCH_DEFAULT, BATCH_MAX);
|
|
341
372
|
const offerDiscovered = cfg.offerDiscovered ?? false;
|
|
342
373
|
const token = cfg.token ?? loadToken() ?? "";
|
|
@@ -388,7 +419,13 @@ async function startRun(passed, declared2) {
|
|
|
388
419
|
log(`plune: ignoring ${env.ignored.join(", ")} \u2014 a run has nowhere to store them yet.`);
|
|
389
420
|
}
|
|
390
421
|
function defer(results) {
|
|
391
|
-
appendBatch(fallbackPath, {
|
|
422
|
+
appendBatch(fallbackPath, {
|
|
423
|
+
runId,
|
|
424
|
+
externalKey,
|
|
425
|
+
session: sessionMarker,
|
|
426
|
+
...cfg.meta !== void 0 ? { meta: cfg.meta } : {},
|
|
427
|
+
results
|
|
428
|
+
});
|
|
392
429
|
stats.deferred += results.length;
|
|
393
430
|
}
|
|
394
431
|
async function resolveKeys(values) {
|
|
@@ -485,6 +522,7 @@ async function startRun(passed, declared2) {
|
|
|
485
522
|
});
|
|
486
523
|
if (!out.ok || !Array.isArray(out.body?.results)) {
|
|
487
524
|
stats.unoffered = batches.slice(index).reduce((n, rest) => n + rest.length, 0);
|
|
525
|
+
stats.unofferedWhy = whyUnoffered(out);
|
|
488
526
|
log(
|
|
489
527
|
`plune: could not offer ${stats.unoffered} unknown test(s) for review (${out.ok ? "the answer had no results" : out.detail || out.kind}).`
|
|
490
528
|
);
|
|
@@ -974,7 +1012,9 @@ var PluneReporter = class {
|
|
|
974
1012
|
...this.options.externalKey !== void 0 ? { externalKey: this.options.externalKey } : {},
|
|
975
1013
|
...this.options.batchSize !== void 0 ? { batchSize: this.options.batchSize } : {},
|
|
976
1014
|
...this.options.fallbackPath !== void 0 ? { fallbackPath: this.options.fallbackPath } : {},
|
|
977
|
-
|
|
1015
|
+
// Where it ran (plune#927): the commit Playwright wrote into `metadata.ci`, and its branch —
|
|
1016
|
+
// which Playwright gives on GitLab and Jenkins, and the core reads from the job on GitHub.
|
|
1017
|
+
meta: { runner: SOURCE, ...ciUrl !== void 0 ? { ciUrl } : {}, ...ciCommit(ci) }
|
|
978
1018
|
},
|
|
979
1019
|
this.declared
|
|
980
1020
|
);
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { readFileSync as readFileSync2 } from "fs";
|
|
|
3
3
|
import { stripVTControlCharacters as stripVTControlCharacters2 } from "util";
|
|
4
4
|
|
|
5
5
|
// ../../dist/reporter-core.js
|
|
6
|
-
import { createHash } from "crypto";
|
|
6
|
+
import { createHash, randomUUID } from "crypto";
|
|
7
7
|
import { promises as disk } from "fs";
|
|
8
8
|
import { basename as basename2, extname } from "path";
|
|
9
9
|
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
@@ -202,6 +202,28 @@ function defaultRunTitle(env = process.env, now = /* @__PURE__ */ new Date(), cw
|
|
|
202
202
|
const where = flag(env, "CI") || flag(env, "GITHUB_ACTIONS") ? "ci" : "local";
|
|
203
203
|
return `${path.basename(cwd)} \xB7 ${stamp} \xB7 ${where}`;
|
|
204
204
|
}
|
|
205
|
+
var PROVIDERS = [
|
|
206
|
+
{ is: "GITHUB_ACTIONS", sha: "GITHUB_SHA", branch: ["GITHUB_HEAD_REF", "GITHUB_REF_NAME"] },
|
|
207
|
+
{ is: "GITLAB_CI", sha: "CI_COMMIT_SHA", branch: ["CI_COMMIT_REF_NAME"] },
|
|
208
|
+
{ is: "JENKINS_URL", sha: "GIT_COMMIT", branch: ["GIT_BRANCH"] }
|
|
209
|
+
];
|
|
210
|
+
function ciCommit(reported, env = process.env) {
|
|
211
|
+
const said = typeof reported === "object" && reported !== null ? reported : {};
|
|
212
|
+
const text = (raw) => typeof raw === "string" && raw.trim() !== "" ? raw.trim() : void 0;
|
|
213
|
+
const provider = PROVIDERS.find((p) => value(env, p.is) !== void 0);
|
|
214
|
+
const job = {
|
|
215
|
+
sha: provider === void 0 ? void 0 : value(env, provider.sha),
|
|
216
|
+
branch: provider?.branch.map((name) => value(env, name)).find((v) => v !== void 0)
|
|
217
|
+
};
|
|
218
|
+
const sha = text(said["commitHash"]);
|
|
219
|
+
const sameCommit = sha === void 0 || sha === job.sha;
|
|
220
|
+
const commit = sha ?? job.sha;
|
|
221
|
+
const branch = text(said["branch"]) ?? (sameCommit ? job.branch : void 0);
|
|
222
|
+
return {
|
|
223
|
+
...commit !== void 0 ? { sha: commit } : {},
|
|
224
|
+
...branch !== void 0 ? { branch } : {}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
205
227
|
var DEFAULT_FALLBACK_PATH = path2.join(".plune", "pending-results.jsonl");
|
|
206
228
|
function appendBatch(file, batch) {
|
|
207
229
|
fs.mkdirSync(path2.dirname(file), { recursive: true });
|
|
@@ -209,6 +231,8 @@ function appendBatch(file, batch) {
|
|
|
209
231
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
210
232
|
runId: batch.runId,
|
|
211
233
|
externalKey: batch.externalKey,
|
|
234
|
+
...batch.session !== void 0 ? { session: batch.session } : {},
|
|
235
|
+
...batch.meta !== void 0 ? { meta: batch.meta } : {},
|
|
212
236
|
results: batch.results
|
|
213
237
|
};
|
|
214
238
|
fs.appendFileSync(file, `${JSON.stringify(line)}
|
|
@@ -260,6 +284,12 @@ function boundKey(key) {
|
|
|
260
284
|
if (/[\uD800-\uDBFF]$/.test(head)) head = head.slice(0, -1);
|
|
261
285
|
return { ...key, value: `${head}#${digest}` };
|
|
262
286
|
}
|
|
287
|
+
function whyUnoffered(out) {
|
|
288
|
+
if (out.ok || out.status !== 429) return "other";
|
|
289
|
+
if (/review queue quota reached/i.test(out.detail)) return "queue";
|
|
290
|
+
if (/test case quota reached/i.test(out.detail)) return "cases";
|
|
291
|
+
return "other";
|
|
292
|
+
}
|
|
263
293
|
function boundTitle(title) {
|
|
264
294
|
return title.length <= TITLE_MAX ? title : `${title.slice(0, TITLE_MAX - 1)}\u2026`;
|
|
265
295
|
}
|
|
@@ -303,6 +333,7 @@ async function startRun(passed, declared2) {
|
|
|
303
333
|
`));
|
|
304
334
|
const fallbackPath = cfg.fallbackPath ?? DEFAULT_FALLBACK_PATH;
|
|
305
335
|
const externalKey = cfg.externalKey ?? null;
|
|
336
|
+
const sessionMarker = randomUUID();
|
|
306
337
|
const batchSize = Math.min(cfg.batchSize ?? BATCH_DEFAULT, BATCH_MAX);
|
|
307
338
|
const offerDiscovered = cfg.offerDiscovered ?? false;
|
|
308
339
|
const token = cfg.token ?? loadToken() ?? "";
|
|
@@ -354,7 +385,13 @@ async function startRun(passed, declared2) {
|
|
|
354
385
|
log(`plune: ignoring ${env.ignored.join(", ")} \u2014 a run has nowhere to store them yet.`);
|
|
355
386
|
}
|
|
356
387
|
function defer(results) {
|
|
357
|
-
appendBatch(fallbackPath, {
|
|
388
|
+
appendBatch(fallbackPath, {
|
|
389
|
+
runId,
|
|
390
|
+
externalKey,
|
|
391
|
+
session: sessionMarker,
|
|
392
|
+
...cfg.meta !== void 0 ? { meta: cfg.meta } : {},
|
|
393
|
+
results
|
|
394
|
+
});
|
|
358
395
|
stats.deferred += results.length;
|
|
359
396
|
}
|
|
360
397
|
async function resolveKeys(values) {
|
|
@@ -451,6 +488,7 @@ async function startRun(passed, declared2) {
|
|
|
451
488
|
});
|
|
452
489
|
if (!out.ok || !Array.isArray(out.body?.results)) {
|
|
453
490
|
stats.unoffered = batches.slice(index).reduce((n, rest) => n + rest.length, 0);
|
|
491
|
+
stats.unofferedWhy = whyUnoffered(out);
|
|
454
492
|
log(
|
|
455
493
|
`plune: could not offer ${stats.unoffered} unknown test(s) for review (${out.ok ? "the answer had no results" : out.detail || out.kind}).`
|
|
456
494
|
);
|
|
@@ -940,7 +978,9 @@ var PluneReporter = class {
|
|
|
940
978
|
...this.options.externalKey !== void 0 ? { externalKey: this.options.externalKey } : {},
|
|
941
979
|
...this.options.batchSize !== void 0 ? { batchSize: this.options.batchSize } : {},
|
|
942
980
|
...this.options.fallbackPath !== void 0 ? { fallbackPath: this.options.fallbackPath } : {},
|
|
943
|
-
|
|
981
|
+
// Where it ran (plune#927): the commit Playwright wrote into `metadata.ci`, and its branch —
|
|
982
|
+
// which Playwright gives on GitLab and Jenkins, and the core reads from the job on GitHub.
|
|
983
|
+
meta: { runner: SOURCE, ...ciUrl !== void 0 ? { ciUrl } : {}, ...ciCommit(ci) }
|
|
944
984
|
},
|
|
945
985
|
this.declared
|
|
946
986
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plune-ai/playwright",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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.
|
|
41
|
+
"@plune-ai/cli": "0.16.0"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|