@flakiness/sdk 0.130.0 → 0.132.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/lib/cli/cli.js +85 -62
- package/lib/cli/cmd-convert.js +32 -21
- package/lib/cli/cmd-link.js +1 -70
- package/lib/cli/cmd-login.js +7 -4
- package/lib/cli/cmd-logout.js +1 -1
- package/lib/cli/cmd-show-report.js +6 -3
- package/lib/cli/cmd-upload.js +21 -19
- package/lib/localGit.js +6 -3
- package/lib/localReportApi.js +6 -3
- package/lib/localReportServer.js +6 -3
- package/lib/playwright-test.js +32 -24
- package/lib/utils.js +24 -0
- package/package.json +4 -4
- package/types/tsconfig.tsbuildinfo +1 -1
package/lib/localReportServer.js
CHANGED
|
@@ -29,8 +29,10 @@ async function listLocalCommits(gitRoot, head, count) {
|
|
|
29
29
|
// %at: Author date as a Unix timestamp (seconds since epoch)
|
|
30
30
|
"%an",
|
|
31
31
|
// %an: Author name
|
|
32
|
-
"%s"
|
|
32
|
+
"%s",
|
|
33
33
|
// %s: Subject (the first line of the commit message)
|
|
34
|
+
"%P"
|
|
35
|
+
// %P: Parent hashes (space-separated)
|
|
34
36
|
].join(FIELD_SEPARATOR);
|
|
35
37
|
const command = `git log ${head} -n ${count} --pretty=format:"${prettyFormat}" -z`;
|
|
36
38
|
try {
|
|
@@ -39,13 +41,14 @@ async function listLocalCommits(gitRoot, head, count) {
|
|
|
39
41
|
return [];
|
|
40
42
|
}
|
|
41
43
|
return stdout.trim().split(RECORD_SEPARATOR).filter((record) => record).map((record) => {
|
|
42
|
-
const [commitId, timestampStr, author, message] = record.split(FIELD_SEPARATOR);
|
|
44
|
+
const [commitId, timestampStr, author, message, parentsStr] = record.split(FIELD_SEPARATOR);
|
|
45
|
+
const parents = parentsStr ? parentsStr.split(" ").filter((p) => p) : [];
|
|
43
46
|
return {
|
|
44
47
|
commitId,
|
|
45
48
|
timestamp: parseInt(timestampStr, 10) * 1e3,
|
|
46
|
-
// Convert timestamp from seconds to milliseconds
|
|
47
49
|
author,
|
|
48
50
|
message,
|
|
51
|
+
parents,
|
|
49
52
|
walkIndex: 0
|
|
50
53
|
};
|
|
51
54
|
});
|
package/lib/playwright-test.js
CHANGED
|
@@ -139,6 +139,29 @@ var ansiRegex = new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:
|
|
|
139
139
|
function stripAnsi(str) {
|
|
140
140
|
return str.replace(ansiRegex, "");
|
|
141
141
|
}
|
|
142
|
+
async function saveReportAndAttachments(report, attachments, outputFolder) {
|
|
143
|
+
const reportPath = path.join(outputFolder, "report.json");
|
|
144
|
+
const attachmentsFolder = path.join(outputFolder, "attachments");
|
|
145
|
+
await fs.promises.rm(outputFolder, { recursive: true, force: true });
|
|
146
|
+
await fs.promises.mkdir(outputFolder, { recursive: true });
|
|
147
|
+
await fs.promises.writeFile(reportPath, JSON.stringify(report), "utf-8");
|
|
148
|
+
if (attachments.length)
|
|
149
|
+
await fs.promises.mkdir(attachmentsFolder);
|
|
150
|
+
const movedAttachments = [];
|
|
151
|
+
for (const attachment of attachments) {
|
|
152
|
+
const attachmentPath = path.join(attachmentsFolder, attachment.id);
|
|
153
|
+
if (attachment.path)
|
|
154
|
+
await fs.promises.cp(attachment.path, attachmentPath);
|
|
155
|
+
else if (attachment.body)
|
|
156
|
+
await fs.promises.writeFile(attachmentPath, attachment.body);
|
|
157
|
+
movedAttachments.push({
|
|
158
|
+
contentType: attachment.contentType,
|
|
159
|
+
id: attachment.id,
|
|
160
|
+
path: attachmentPath
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
return movedAttachments;
|
|
164
|
+
}
|
|
142
165
|
function shell(command, args, options) {
|
|
143
166
|
try {
|
|
144
167
|
const result = spawnSync(command, args, { encoding: "utf-8", ...options });
|
|
@@ -451,8 +474,10 @@ async function listLocalCommits(gitRoot, head, count) {
|
|
|
451
474
|
// %at: Author date as a Unix timestamp (seconds since epoch)
|
|
452
475
|
"%an",
|
|
453
476
|
// %an: Author name
|
|
454
|
-
"%s"
|
|
477
|
+
"%s",
|
|
455
478
|
// %s: Subject (the first line of the commit message)
|
|
479
|
+
"%P"
|
|
480
|
+
// %P: Parent hashes (space-separated)
|
|
456
481
|
].join(FIELD_SEPARATOR);
|
|
457
482
|
const command = `git log ${head} -n ${count} --pretty=format:"${prettyFormat}" -z`;
|
|
458
483
|
try {
|
|
@@ -461,13 +486,14 @@ async function listLocalCommits(gitRoot, head, count) {
|
|
|
461
486
|
return [];
|
|
462
487
|
}
|
|
463
488
|
return stdout.trim().split(RECORD_SEPARATOR).filter((record) => record).map((record) => {
|
|
464
|
-
const [commitId, timestampStr, author, message] = record.split(FIELD_SEPARATOR);
|
|
489
|
+
const [commitId, timestampStr, author, message, parentsStr] = record.split(FIELD_SEPARATOR);
|
|
490
|
+
const parents = parentsStr ? parentsStr.split(" ").filter((p) => p) : [];
|
|
465
491
|
return {
|
|
466
492
|
commitId,
|
|
467
493
|
timestamp: parseInt(timestampStr, 10) * 1e3,
|
|
468
|
-
// Convert timestamp from seconds to milliseconds
|
|
469
494
|
author,
|
|
470
495
|
message,
|
|
496
|
+
parents,
|
|
471
497
|
walkIndex: 0
|
|
472
498
|
};
|
|
473
499
|
});
|
|
@@ -1072,25 +1098,7 @@ var FlakinessReporter = class {
|
|
|
1072
1098
|
for (const unaccessibleAttachment of context.unaccessibleAttachmentPaths)
|
|
1073
1099
|
warn(`cannot access attachment ${unaccessibleAttachment}`);
|
|
1074
1100
|
this._report = report;
|
|
1075
|
-
|
|
1076
|
-
const attachmentsFolder = path6.join(this._outputFolder, "attachments");
|
|
1077
|
-
await fs7.promises.rm(this._outputFolder, { recursive: true, force: true });
|
|
1078
|
-
await fs7.promises.mkdir(this._outputFolder, { recursive: true });
|
|
1079
|
-
await fs7.promises.writeFile(reportPath, JSON.stringify(report), "utf-8");
|
|
1080
|
-
if (context.attachments.size)
|
|
1081
|
-
await fs7.promises.mkdir(attachmentsFolder);
|
|
1082
|
-
for (const attachment of context.attachments.values()) {
|
|
1083
|
-
const attachmentPath = path6.join(attachmentsFolder, attachment.id);
|
|
1084
|
-
if (attachment.path)
|
|
1085
|
-
await fs7.promises.cp(attachment.path, attachmentPath);
|
|
1086
|
-
else if (attachment.body)
|
|
1087
|
-
await fs7.promises.writeFile(attachmentPath, attachment.body);
|
|
1088
|
-
this._attachments.push({
|
|
1089
|
-
contentType: attachment.contentType,
|
|
1090
|
-
id: attachment.id,
|
|
1091
|
-
path: attachmentPath
|
|
1092
|
-
});
|
|
1093
|
-
}
|
|
1101
|
+
this._attachments = await saveReportAndAttachments(report, Array.from(context.attachments.values()), this._outputFolder);
|
|
1094
1102
|
this._result = result;
|
|
1095
1103
|
}
|
|
1096
1104
|
async onExit() {
|
|
@@ -1111,9 +1119,9 @@ var FlakinessReporter = class {
|
|
|
1111
1119
|
const defaultOutputFolder = path6.join(process.cwd(), "flakiness-report");
|
|
1112
1120
|
const folder = defaultOutputFolder === this._outputFolder ? "" : path6.relative(process.cwd(), this._outputFolder);
|
|
1113
1121
|
console.log(`
|
|
1114
|
-
To open last Flakiness report run:
|
|
1122
|
+
To open last Flakiness report, install Flakiness CLI tool and run:
|
|
1115
1123
|
|
|
1116
|
-
${chalk2.cyan(`
|
|
1124
|
+
${chalk2.cyan(`flakiness show ${folder}`)}
|
|
1117
1125
|
`);
|
|
1118
1126
|
}
|
|
1119
1127
|
}
|
package/lib/utils.js
CHANGED
|
@@ -123,6 +123,29 @@ var ansiRegex = new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:
|
|
|
123
123
|
function stripAnsi(str) {
|
|
124
124
|
return str.replace(ansiRegex, "");
|
|
125
125
|
}
|
|
126
|
+
async function saveReportAndAttachments(report, attachments, outputFolder) {
|
|
127
|
+
const reportPath = path.join(outputFolder, "report.json");
|
|
128
|
+
const attachmentsFolder = path.join(outputFolder, "attachments");
|
|
129
|
+
await fs.promises.rm(outputFolder, { recursive: true, force: true });
|
|
130
|
+
await fs.promises.mkdir(outputFolder, { recursive: true });
|
|
131
|
+
await fs.promises.writeFile(reportPath, JSON.stringify(report), "utf-8");
|
|
132
|
+
if (attachments.length)
|
|
133
|
+
await fs.promises.mkdir(attachmentsFolder);
|
|
134
|
+
const movedAttachments = [];
|
|
135
|
+
for (const attachment of attachments) {
|
|
136
|
+
const attachmentPath = path.join(attachmentsFolder, attachment.id);
|
|
137
|
+
if (attachment.path)
|
|
138
|
+
await fs.promises.cp(attachment.path, attachmentPath);
|
|
139
|
+
else if (attachment.body)
|
|
140
|
+
await fs.promises.writeFile(attachmentPath, attachment.body);
|
|
141
|
+
movedAttachments.push({
|
|
142
|
+
contentType: attachment.contentType,
|
|
143
|
+
id: attachment.id,
|
|
144
|
+
path: attachmentPath
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return movedAttachments;
|
|
148
|
+
}
|
|
126
149
|
function shell(command, args, options) {
|
|
127
150
|
try {
|
|
128
151
|
const result = spawnSync(command, args, { encoding: "utf-8", ...options });
|
|
@@ -342,6 +365,7 @@ export {
|
|
|
342
365
|
parseStringDate,
|
|
343
366
|
resolveAttachmentPaths,
|
|
344
367
|
retryWithBackoff,
|
|
368
|
+
saveReportAndAttachments,
|
|
345
369
|
sha1Buffer,
|
|
346
370
|
sha1File,
|
|
347
371
|
shell,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flakiness/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.132.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"bin": {
|
|
6
6
|
"flakiness": "./lib/cli/cli.js"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"author": "Degu Labs, Inc",
|
|
51
51
|
"license": "Fair Source 100",
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@flakiness/server": "0.
|
|
53
|
+
"@flakiness/server": "0.132.0",
|
|
54
54
|
"@playwright/test": "^1.54.0",
|
|
55
55
|
"@types/babel__code-frame": "^7.0.6",
|
|
56
56
|
"@types/compression": "^1.8.1",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@babel/code-frame": "^7.26.2",
|
|
61
|
-
"@flakiness/report": "0.
|
|
62
|
-
"@flakiness/shared": "0.
|
|
61
|
+
"@flakiness/report": "0.132.0",
|
|
62
|
+
"@flakiness/shared": "0.132.0",
|
|
63
63
|
"@rgrove/parse-xml": "^4.2.0",
|
|
64
64
|
"body-parser": "^1.20.3",
|
|
65
65
|
"chalk": "^5.6.2",
|