@flakiness/sdk 0.96.0 → 0.97.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 +39 -15
- package/lib/cli/cmd-convert.js +1 -3
- package/lib/cli/cmd-link.js +1 -3
- package/lib/cli/cmd-login.js +8 -2
- package/lib/cli/{cmd-serve.js → cmd-show-report.js} +13 -10
- package/lib/cli/cmd-status.js +1 -3
- package/lib/cli/cmd-unlink.js +1 -3
- package/lib/cli/cmd-upload-playwright-json.js +3 -4
- package/lib/cli/cmd-upload.js +2 -1
- package/lib/flakinessConfig.js +1 -3
- package/lib/localReportServer.js +1 -1
- package/lib/playwright-test.js +41 -24
- package/lib/playwrightJSONReport.js +1 -3
- package/lib/reportUploader.js +2 -1
- package/lib/utils.js +1 -3
- package/package.json +5 -4
- package/types/tsconfig.tsbuildinfo +1 -1
package/lib/cli/cli.js
CHANGED
|
@@ -873,13 +873,11 @@ function shell(command, args, options) {
|
|
|
873
873
|
try {
|
|
874
874
|
const result = spawnSync(command, args, { encoding: "utf-8", ...options });
|
|
875
875
|
if (result.status !== 0) {
|
|
876
|
-
console.log(result);
|
|
877
|
-
console.log(options);
|
|
878
876
|
return void 0;
|
|
879
877
|
}
|
|
880
878
|
return result.stdout.trim();
|
|
881
879
|
} catch (e) {
|
|
882
|
-
console.
|
|
880
|
+
console.error(e);
|
|
883
881
|
return void 0;
|
|
884
882
|
}
|
|
885
883
|
}
|
|
@@ -1524,8 +1522,14 @@ async function cmdLogin(endpoint) {
|
|
|
1524
1522
|
endpoint,
|
|
1525
1523
|
token
|
|
1526
1524
|
});
|
|
1527
|
-
|
|
1528
|
-
|
|
1525
|
+
try {
|
|
1526
|
+
const user = await session2.api.user.whoami.GET();
|
|
1527
|
+
await session2.save();
|
|
1528
|
+
console.log(`\u2713 Logged in as ${user.userName} (${user.userLogin})`);
|
|
1529
|
+
} catch (e) {
|
|
1530
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
1531
|
+
console.error(`x Failed to login:`, message);
|
|
1532
|
+
}
|
|
1529
1533
|
}
|
|
1530
1534
|
|
|
1531
1535
|
// src/cli/cmd-logout.ts
|
|
@@ -1539,7 +1543,8 @@ async function cmdLogout() {
|
|
|
1539
1543
|
await FlakinessSession.remove();
|
|
1540
1544
|
}
|
|
1541
1545
|
|
|
1542
|
-
// src/cli/cmd-
|
|
1546
|
+
// src/cli/cmd-show-report.ts
|
|
1547
|
+
import chalk from "chalk";
|
|
1543
1548
|
import open2 from "open";
|
|
1544
1549
|
import path7 from "path";
|
|
1545
1550
|
|
|
@@ -1643,7 +1648,7 @@ var LocalReportServer = class _LocalReportServer {
|
|
|
1643
1648
|
static async create(options) {
|
|
1644
1649
|
const app = express();
|
|
1645
1650
|
app.set("etag", false);
|
|
1646
|
-
const authToken =
|
|
1651
|
+
const authToken = randomUUIDBase62();
|
|
1647
1652
|
app.use(compression());
|
|
1648
1653
|
app.use(bodyParser.json({ limit: 256 * 1024 }));
|
|
1649
1654
|
app.use((req, res, next) => {
|
|
@@ -1714,8 +1719,8 @@ var LocalReportServer = class _LocalReportServer {
|
|
|
1714
1719
|
}
|
|
1715
1720
|
};
|
|
1716
1721
|
|
|
1717
|
-
// src/cli/cmd-
|
|
1718
|
-
async function
|
|
1722
|
+
// src/cli/cmd-show-report.ts
|
|
1723
|
+
async function cmdShowReport(reportFolder) {
|
|
1719
1724
|
const reportPath = path7.join(reportFolder, "report.json");
|
|
1720
1725
|
const session2 = await FlakinessSession.load();
|
|
1721
1726
|
const config = await FlakinessConfig.load();
|
|
@@ -1729,8 +1734,12 @@ async function cmdServe(reportFolder) {
|
|
|
1729
1734
|
attachmentsFolder: reportFolder
|
|
1730
1735
|
});
|
|
1731
1736
|
const reportEndpoint = project ? `${endpoint}/localreport/${project.org.orgSlug}/${project.projectSlug}?port=${server.port()}&token=${server.authToken()}` : `${endpoint}/localreport?port=${server.port()}&token=${server.authToken()}`;
|
|
1732
|
-
console.log(`
|
|
1737
|
+
console.log(chalk.cyan(`
|
|
1738
|
+
Serving Flakiness report at ${reportEndpoint}
|
|
1739
|
+
Press Ctrl+C to quit.`));
|
|
1733
1740
|
await open2(reportEndpoint);
|
|
1741
|
+
await new Promise(() => {
|
|
1742
|
+
});
|
|
1734
1743
|
}
|
|
1735
1744
|
|
|
1736
1745
|
// src/cli/cmd-status.ts
|
|
@@ -1956,7 +1965,8 @@ var ReportUploader = class _ReportUploader {
|
|
|
1956
1965
|
static async upload(options) {
|
|
1957
1966
|
const uploaderOptions = _ReportUploader.optionsFromEnv(options);
|
|
1958
1967
|
if (!uploaderOptions) {
|
|
1959
|
-
|
|
1968
|
+
if (process.env.CI)
|
|
1969
|
+
options.log?.(`[flakiness.io] Uploading skipped since no FLAKINESS_ACCESS_TOKEN is specified`);
|
|
1960
1970
|
return void 0;
|
|
1961
1971
|
}
|
|
1962
1972
|
const uploader = new _ReportUploader(uploaderOptions);
|
|
@@ -2219,7 +2229,14 @@ var optSince = new Option("--since <date>", "Start date for filtering").argParse
|
|
|
2219
2229
|
}
|
|
2220
2230
|
return parsed;
|
|
2221
2231
|
});
|
|
2222
|
-
|
|
2232
|
+
var optParallel = new Option("-j, --parallel <date>", "Parallel jobs to run").argParser((value) => {
|
|
2233
|
+
const parsed = parseInt(value, 10);
|
|
2234
|
+
if (isNaN(parsed) || parsed < 1) {
|
|
2235
|
+
throw new Error("parallel must be a number >= 1");
|
|
2236
|
+
}
|
|
2237
|
+
return parsed;
|
|
2238
|
+
});
|
|
2239
|
+
program.command("download").description("Download run").addOption(optSince).addOption(optRunId).addOption(optParallel).action(async (options) => runCommand(async () => {
|
|
2223
2240
|
const session2 = await FlakinessSession.loadOrDie();
|
|
2224
2241
|
const project = await FlakinessConfig.projectOrDie(session2);
|
|
2225
2242
|
let runIds = [];
|
|
@@ -2233,8 +2250,15 @@ program.command("download").description("Download run").addOption(optSince).addO
|
|
|
2233
2250
|
});
|
|
2234
2251
|
console.log(`Found ${Ranges.cardinality(runIds)} reports uploaded since ${options.since}`);
|
|
2235
2252
|
}
|
|
2236
|
-
|
|
2237
|
-
|
|
2253
|
+
const it = Ranges.iterate(runIds);
|
|
2254
|
+
const downloaders = [];
|
|
2255
|
+
for (let i = 0; i < (options.parallel ?? 1); ++i) {
|
|
2256
|
+
downloaders.push((async () => {
|
|
2257
|
+
for (let result = it.next(); !result.done; result = it.next())
|
|
2258
|
+
await cmdDownload(session2, project, result.value);
|
|
2259
|
+
})());
|
|
2260
|
+
}
|
|
2261
|
+
await Promise.all(downloaders);
|
|
2238
2262
|
}));
|
|
2239
2263
|
program.command("upload").description("Upload Flakiness report to the flakiness.io service").argument("<relative-path>", "Path to the Flakiness report file").addOption(optAccessToken).addOption(optEndpoint).addOption(optAttachmentsDir).addOption(optIgnoreMissingAttachments).action(async (relativePath, options) => {
|
|
2240
2264
|
await runCommand(async () => {
|
|
@@ -2243,7 +2267,7 @@ program.command("upload").description("Upload Flakiness report to the flakiness.
|
|
|
2243
2267
|
});
|
|
2244
2268
|
program.command("show-report [report]").description("Show flakiness report").argument("[relative-path]", "Path to the Flakiness report file or folder that contains `report.json`.").action(async (arg) => runCommand(async () => {
|
|
2245
2269
|
const dir = path10.join(process.cwd(), arg ?? "flakiness-report");
|
|
2246
|
-
await
|
|
2270
|
+
await cmdShowReport(dir);
|
|
2247
2271
|
}));
|
|
2248
2272
|
program.command("convert-junit").description("Convert JUnit XML report(s) to Flakiness report format").argument("<junit-root-dir-path>", "Path to JUnit XML file or directory containing XML files").option("--env-name <name>", "Environment name for the report", "default").option("--commit-id <id>", "Git commit ID (auto-detected if not provided)").action(async (junitPath, options) => {
|
|
2249
2273
|
await runCommand(async () => {
|
package/lib/cli/cmd-convert.js
CHANGED
|
@@ -126,13 +126,11 @@ function shell(command, args, options) {
|
|
|
126
126
|
try {
|
|
127
127
|
const result = spawnSync(command, args, { encoding: "utf-8", ...options });
|
|
128
128
|
if (result.status !== 0) {
|
|
129
|
-
console.log(result);
|
|
130
|
-
console.log(options);
|
|
131
129
|
return void 0;
|
|
132
130
|
}
|
|
133
131
|
return result.stdout.trim();
|
|
134
132
|
} catch (e) {
|
|
135
|
-
console.
|
|
133
|
+
console.error(e);
|
|
136
134
|
return void 0;
|
|
137
135
|
}
|
|
138
136
|
}
|
package/lib/cli/cmd-link.js
CHANGED
|
@@ -96,13 +96,11 @@ function shell(command, args, options) {
|
|
|
96
96
|
try {
|
|
97
97
|
const result = spawnSync(command, args, { encoding: "utf-8", ...options });
|
|
98
98
|
if (result.status !== 0) {
|
|
99
|
-
console.log(result);
|
|
100
|
-
console.log(options);
|
|
101
99
|
return void 0;
|
|
102
100
|
}
|
|
103
101
|
return result.stdout.trim();
|
|
104
102
|
} catch (e) {
|
|
105
|
-
console.
|
|
103
|
+
console.error(e);
|
|
106
104
|
return void 0;
|
|
107
105
|
}
|
|
108
106
|
}
|
package/lib/cli/cmd-login.js
CHANGED
|
@@ -193,8 +193,14 @@ async function cmdLogin(endpoint) {
|
|
|
193
193
|
endpoint,
|
|
194
194
|
token
|
|
195
195
|
});
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
try {
|
|
197
|
+
const user = await session.api.user.whoami.GET();
|
|
198
|
+
await session.save();
|
|
199
|
+
console.log(`\u2713 Logged in as ${user.userName} (${user.userLogin})`);
|
|
200
|
+
} catch (e) {
|
|
201
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
202
|
+
console.error(`x Failed to login:`, message);
|
|
203
|
+
}
|
|
198
204
|
}
|
|
199
205
|
export {
|
|
200
206
|
cmdLogin
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// src/cli/cmd-
|
|
1
|
+
// src/cli/cmd-show-report.ts
|
|
2
|
+
import chalk from "chalk";
|
|
2
3
|
import open from "open";
|
|
3
4
|
import path4 from "path";
|
|
4
5
|
|
|
@@ -101,13 +102,11 @@ function shell(command, args, options) {
|
|
|
101
102
|
try {
|
|
102
103
|
const result = spawnSync(command, args, { encoding: "utf-8", ...options });
|
|
103
104
|
if (result.status !== 0) {
|
|
104
|
-
console.log(result);
|
|
105
|
-
console.log(options);
|
|
106
105
|
return void 0;
|
|
107
106
|
}
|
|
108
107
|
return result.stdout.trim();
|
|
109
108
|
} catch (e) {
|
|
110
|
-
console.
|
|
109
|
+
console.error(e);
|
|
111
110
|
return void 0;
|
|
112
111
|
}
|
|
113
112
|
}
|
|
@@ -390,7 +389,7 @@ var LocalReportServer = class _LocalReportServer {
|
|
|
390
389
|
static async create(options) {
|
|
391
390
|
const app = express();
|
|
392
391
|
app.set("etag", false);
|
|
393
|
-
const authToken =
|
|
392
|
+
const authToken = randomUUIDBase62();
|
|
394
393
|
app.use(compression());
|
|
395
394
|
app.use(bodyParser.json({ limit: 256 * 1024 }));
|
|
396
395
|
app.use((req, res, next) => {
|
|
@@ -461,8 +460,8 @@ var LocalReportServer = class _LocalReportServer {
|
|
|
461
460
|
}
|
|
462
461
|
};
|
|
463
462
|
|
|
464
|
-
// src/cli/cmd-
|
|
465
|
-
async function
|
|
463
|
+
// src/cli/cmd-show-report.ts
|
|
464
|
+
async function cmdShowReport(reportFolder) {
|
|
466
465
|
const reportPath = path4.join(reportFolder, "report.json");
|
|
467
466
|
const session = await FlakinessSession.load();
|
|
468
467
|
const config = await FlakinessConfig.load();
|
|
@@ -476,10 +475,14 @@ async function cmdServe(reportFolder) {
|
|
|
476
475
|
attachmentsFolder: reportFolder
|
|
477
476
|
});
|
|
478
477
|
const reportEndpoint = project ? `${endpoint}/localreport/${project.org.orgSlug}/${project.projectSlug}?port=${server.port()}&token=${server.authToken()}` : `${endpoint}/localreport?port=${server.port()}&token=${server.authToken()}`;
|
|
479
|
-
console.log(`
|
|
478
|
+
console.log(chalk.cyan(`
|
|
479
|
+
Serving Flakiness report at ${reportEndpoint}
|
|
480
|
+
Press Ctrl+C to quit.`));
|
|
480
481
|
await open(reportEndpoint);
|
|
482
|
+
await new Promise(() => {
|
|
483
|
+
});
|
|
481
484
|
}
|
|
482
485
|
export {
|
|
483
|
-
|
|
486
|
+
cmdShowReport
|
|
484
487
|
};
|
|
485
|
-
//# sourceMappingURL=cmd-
|
|
488
|
+
//# sourceMappingURL=cmd-show-report.js.map
|
package/lib/cli/cmd-status.js
CHANGED
|
@@ -96,13 +96,11 @@ function shell(command, args, options) {
|
|
|
96
96
|
try {
|
|
97
97
|
const result = spawnSync(command, args, { encoding: "utf-8", ...options });
|
|
98
98
|
if (result.status !== 0) {
|
|
99
|
-
console.log(result);
|
|
100
|
-
console.log(options);
|
|
101
99
|
return void 0;
|
|
102
100
|
}
|
|
103
101
|
return result.stdout.trim();
|
|
104
102
|
} catch (e) {
|
|
105
|
-
console.
|
|
103
|
+
console.error(e);
|
|
106
104
|
return void 0;
|
|
107
105
|
}
|
|
108
106
|
}
|
package/lib/cli/cmd-unlink.js
CHANGED
|
@@ -96,13 +96,11 @@ function shell(command, args, options) {
|
|
|
96
96
|
try {
|
|
97
97
|
const result = spawnSync(command, args, { encoding: "utf-8", ...options });
|
|
98
98
|
if (result.status !== 0) {
|
|
99
|
-
console.log(result);
|
|
100
|
-
console.log(options);
|
|
101
99
|
return void 0;
|
|
102
100
|
}
|
|
103
101
|
return result.stdout.trim();
|
|
104
102
|
} catch (e) {
|
|
105
|
-
console.
|
|
103
|
+
console.error(e);
|
|
106
104
|
return void 0;
|
|
107
105
|
}
|
|
108
106
|
}
|
|
@@ -138,13 +138,11 @@ function shell(command, args, options) {
|
|
|
138
138
|
try {
|
|
139
139
|
const result = spawnSync(command, args, { encoding: "utf-8", ...options });
|
|
140
140
|
if (result.status !== 0) {
|
|
141
|
-
console.log(result);
|
|
142
|
-
console.log(options);
|
|
143
141
|
return void 0;
|
|
144
142
|
}
|
|
145
143
|
return result.stdout.trim();
|
|
146
144
|
} catch (e) {
|
|
147
|
-
console.
|
|
145
|
+
console.error(e);
|
|
148
146
|
return void 0;
|
|
149
147
|
}
|
|
150
148
|
}
|
|
@@ -466,7 +464,8 @@ var ReportUploader = class _ReportUploader {
|
|
|
466
464
|
static async upload(options) {
|
|
467
465
|
const uploaderOptions = _ReportUploader.optionsFromEnv(options);
|
|
468
466
|
if (!uploaderOptions) {
|
|
469
|
-
|
|
467
|
+
if (process.env.CI)
|
|
468
|
+
options.log?.(`[flakiness.io] Uploading skipped since no FLAKINESS_ACCESS_TOKEN is specified`);
|
|
470
469
|
return void 0;
|
|
471
470
|
}
|
|
472
471
|
const uploader = new _ReportUploader(uploaderOptions);
|
package/lib/cli/cmd-upload.js
CHANGED
|
@@ -166,7 +166,8 @@ var ReportUploader = class _ReportUploader {
|
|
|
166
166
|
static async upload(options) {
|
|
167
167
|
const uploaderOptions = _ReportUploader.optionsFromEnv(options);
|
|
168
168
|
if (!uploaderOptions) {
|
|
169
|
-
|
|
169
|
+
if (process.env.CI)
|
|
170
|
+
options.log?.(`[flakiness.io] Uploading skipped since no FLAKINESS_ACCESS_TOKEN is specified`);
|
|
170
171
|
return void 0;
|
|
171
172
|
}
|
|
172
173
|
const uploader = new _ReportUploader(uploaderOptions);
|
package/lib/flakinessConfig.js
CHANGED
|
@@ -96,13 +96,11 @@ function shell(command, args, options) {
|
|
|
96
96
|
try {
|
|
97
97
|
const result = spawnSync(command, args, { encoding: "utf-8", ...options });
|
|
98
98
|
if (result.status !== 0) {
|
|
99
|
-
console.log(result);
|
|
100
|
-
console.log(options);
|
|
101
99
|
return void 0;
|
|
102
100
|
}
|
|
103
101
|
return result.stdout.trim();
|
|
104
102
|
} catch (e) {
|
|
105
|
-
console.
|
|
103
|
+
console.error(e);
|
|
106
104
|
return void 0;
|
|
107
105
|
}
|
|
108
106
|
}
|
package/lib/localReportServer.js
CHANGED
|
@@ -224,7 +224,7 @@ var LocalReportServer = class _LocalReportServer {
|
|
|
224
224
|
static async create(options) {
|
|
225
225
|
const app = express();
|
|
226
226
|
app.set("etag", false);
|
|
227
|
-
const authToken =
|
|
227
|
+
const authToken = randomUUIDBase62();
|
|
228
228
|
app.use(compression());
|
|
229
229
|
app.use(bodyParser.json({ limit: 256 * 1024 }));
|
|
230
230
|
app.use((req, res, next) => {
|
package/lib/playwright-test.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// src/playwright-test.ts
|
|
2
2
|
import { FlakinessReport as FK } from "@flakiness/report";
|
|
3
3
|
import { Multimap } from "@flakiness/shared/common/multimap.js";
|
|
4
|
+
import chalk2 from "chalk";
|
|
4
5
|
import fs8 from "fs";
|
|
5
6
|
import path5 from "path";
|
|
6
7
|
|
|
7
|
-
// src/cli/cmd-
|
|
8
|
+
// src/cli/cmd-show-report.ts
|
|
9
|
+
import chalk from "chalk";
|
|
8
10
|
import open from "open";
|
|
9
11
|
import path4 from "path";
|
|
10
12
|
|
|
@@ -41,8 +43,8 @@ function sha1File(filePath) {
|
|
|
41
43
|
stream.on("end", () => {
|
|
42
44
|
resolve(hash.digest("hex"));
|
|
43
45
|
});
|
|
44
|
-
stream.on("error", (
|
|
45
|
-
reject(
|
|
46
|
+
stream.on("error", (err2) => {
|
|
47
|
+
reject(err2);
|
|
46
48
|
});
|
|
47
49
|
});
|
|
48
50
|
}
|
|
@@ -141,13 +143,11 @@ function shell(command, args, options) {
|
|
|
141
143
|
try {
|
|
142
144
|
const result = spawnSync(command, args, { encoding: "utf-8", ...options });
|
|
143
145
|
if (result.status !== 0) {
|
|
144
|
-
console.log(result);
|
|
145
|
-
console.log(options);
|
|
146
146
|
return void 0;
|
|
147
147
|
}
|
|
148
148
|
return result.stdout.trim();
|
|
149
149
|
} catch (e) {
|
|
150
|
-
console.
|
|
150
|
+
console.error(e);
|
|
151
151
|
return void 0;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
@@ -520,7 +520,7 @@ var LocalReportServer = class _LocalReportServer {
|
|
|
520
520
|
static async create(options) {
|
|
521
521
|
const app = express();
|
|
522
522
|
app.set("etag", false);
|
|
523
|
-
const authToken =
|
|
523
|
+
const authToken = randomUUIDBase62();
|
|
524
524
|
app.use(compression());
|
|
525
525
|
app.use(bodyParser.json({ limit: 256 * 1024 }));
|
|
526
526
|
app.use((req, res, next) => {
|
|
@@ -561,19 +561,19 @@ var LocalReportServer = class _LocalReportServer {
|
|
|
561
561
|
};
|
|
562
562
|
}
|
|
563
563
|
}));
|
|
564
|
-
app.use((
|
|
565
|
-
if (
|
|
566
|
-
return res.status(
|
|
567
|
-
logHTTPServer(
|
|
564
|
+
app.use((err2, req, res, next) => {
|
|
565
|
+
if (err2 instanceof TypedHTTP3.HttpError)
|
|
566
|
+
return res.status(err2.status).send({ error: err2.message });
|
|
567
|
+
logHTTPServer(err2);
|
|
568
568
|
res.status(500).send({ error: "Internal Server Error" });
|
|
569
569
|
});
|
|
570
570
|
const server = http2.createServer(app);
|
|
571
|
-
server.on("error", (
|
|
572
|
-
if (
|
|
571
|
+
server.on("error", (err2) => {
|
|
572
|
+
if (err2.code === "ECONNRESET") {
|
|
573
573
|
logHTTPServer("Client connection reset. Ignoring.");
|
|
574
574
|
return;
|
|
575
575
|
}
|
|
576
|
-
throw
|
|
576
|
+
throw err2;
|
|
577
577
|
});
|
|
578
578
|
const port = await new Promise((resolve) => server.listen(options.port, () => {
|
|
579
579
|
resolve(server.address().port);
|
|
@@ -591,8 +591,8 @@ var LocalReportServer = class _LocalReportServer {
|
|
|
591
591
|
}
|
|
592
592
|
};
|
|
593
593
|
|
|
594
|
-
// src/cli/cmd-
|
|
595
|
-
async function
|
|
594
|
+
// src/cli/cmd-show-report.ts
|
|
595
|
+
async function cmdShowReport(reportFolder) {
|
|
596
596
|
const reportPath = path4.join(reportFolder, "report.json");
|
|
597
597
|
const session = await FlakinessSession.load();
|
|
598
598
|
const config = await FlakinessConfig.load();
|
|
@@ -606,8 +606,12 @@ async function cmdServe(reportFolder) {
|
|
|
606
606
|
attachmentsFolder: reportFolder
|
|
607
607
|
});
|
|
608
608
|
const reportEndpoint = project ? `${endpoint}/localreport/${project.org.orgSlug}/${project.projectSlug}?port=${server.port()}&token=${server.authToken()}` : `${endpoint}/localreport?port=${server.port()}&token=${server.authToken()}`;
|
|
609
|
-
console.log(`
|
|
609
|
+
console.log(chalk.cyan(`
|
|
610
|
+
Serving Flakiness report at ${reportEndpoint}
|
|
611
|
+
Press Ctrl+C to quit.`));
|
|
610
612
|
await open(reportEndpoint);
|
|
613
|
+
await new Promise(() => {
|
|
614
|
+
});
|
|
611
615
|
}
|
|
612
616
|
|
|
613
617
|
// src/createTestStepSnippets.ts
|
|
@@ -655,7 +659,8 @@ var ReportUploader = class _ReportUploader {
|
|
|
655
659
|
static async upload(options) {
|
|
656
660
|
const uploaderOptions = _ReportUploader.optionsFromEnv(options);
|
|
657
661
|
if (!uploaderOptions) {
|
|
658
|
-
|
|
662
|
+
if (process.env.CI)
|
|
663
|
+
options.log?.(`[flakiness.io] Uploading skipped since no FLAKINESS_ACCESS_TOKEN is specified`);
|
|
659
664
|
return void 0;
|
|
660
665
|
}
|
|
661
666
|
const uploader = new _ReportUploader(uploaderOptions);
|
|
@@ -840,6 +845,8 @@ var SystemUtilizationSampler = class {
|
|
|
840
845
|
};
|
|
841
846
|
|
|
842
847
|
// src/playwright-test.ts
|
|
848
|
+
var warn = (txt) => console.warn(chalk2.yellow(`[flakiness.io] ${txt}`));
|
|
849
|
+
var err = (txt) => console.error(chalk2.red(`[flakiness.io] ${txt}`));
|
|
843
850
|
var FlakinessReporter = class {
|
|
844
851
|
constructor(_options = {}) {
|
|
845
852
|
this._options = _options;
|
|
@@ -979,7 +986,8 @@ var FlakinessReporter = class {
|
|
|
979
986
|
try {
|
|
980
987
|
commitId = gitCommitInfo(this._config.rootDir);
|
|
981
988
|
} catch (e) {
|
|
982
|
-
|
|
989
|
+
warn(`Failed to fetch commit info - is this a git repo?`);
|
|
990
|
+
err(`Report is NOT generated.`);
|
|
983
991
|
return;
|
|
984
992
|
}
|
|
985
993
|
const gitRoot = normalizePath(computeGitRoot(this._config.rootDir));
|
|
@@ -1021,7 +1029,7 @@ var FlakinessReporter = class {
|
|
|
1021
1029
|
env.userSuppliedData["browser"] = (channel ?? browserName).toLowerCase().trim() + " " + version;
|
|
1022
1030
|
}
|
|
1023
1031
|
} catch (e) {
|
|
1024
|
-
|
|
1032
|
+
err(`Failed to resolve browser version: ${e}`);
|
|
1025
1033
|
}
|
|
1026
1034
|
}
|
|
1027
1035
|
const environments = [...environmentsMap.values()];
|
|
@@ -1044,7 +1052,7 @@ var FlakinessReporter = class {
|
|
|
1044
1052
|
});
|
|
1045
1053
|
createTestStepSnippets(this._filepathToSteps);
|
|
1046
1054
|
for (const unaccessibleAttachment of context.unaccessibleAttachmentPaths)
|
|
1047
|
-
|
|
1055
|
+
warn(`cannot access attachment ${unaccessibleAttachment}`);
|
|
1048
1056
|
this._report = report;
|
|
1049
1057
|
const reportPath = path5.join(this._outputFolder, "report.json");
|
|
1050
1058
|
const attachmentsFolder = path5.join(this._outputFolder, "attachments");
|
|
@@ -1077,10 +1085,19 @@ var FlakinessReporter = class {
|
|
|
1077
1085
|
flakinessEndpoint: this._options.endpoint,
|
|
1078
1086
|
log: console.log
|
|
1079
1087
|
});
|
|
1080
|
-
const openMode = this._options.open ?? "
|
|
1088
|
+
const openMode = this._options.open ?? "on-failure";
|
|
1081
1089
|
const shouldOpen = openMode === "always" || openMode === "on-failure" && this._result?.status === "failed";
|
|
1082
|
-
if (shouldOpen)
|
|
1083
|
-
await
|
|
1090
|
+
if (shouldOpen) {
|
|
1091
|
+
await cmdShowReport(this._outputFolder);
|
|
1092
|
+
} else {
|
|
1093
|
+
const defaultOutputFolder = path5.join(process.cwd(), "flakiness-report");
|
|
1094
|
+
const folder = defaultOutputFolder === this._outputFolder ? "" : path5.relative(process.cwd(), this._outputFolder);
|
|
1095
|
+
console.log(`
|
|
1096
|
+
To open last Flakiness report run:
|
|
1097
|
+
|
|
1098
|
+
${chalk2.cyan(`npx flakiness show-report ${folder}`)}
|
|
1099
|
+
`);
|
|
1100
|
+
}
|
|
1084
1101
|
}
|
|
1085
1102
|
};
|
|
1086
1103
|
function toSTDIOEntry(data) {
|
|
@@ -132,13 +132,11 @@ function shell(command, args, options) {
|
|
|
132
132
|
try {
|
|
133
133
|
const result = spawnSync(command, args, { encoding: "utf-8", ...options });
|
|
134
134
|
if (result.status !== 0) {
|
|
135
|
-
console.log(result);
|
|
136
|
-
console.log(options);
|
|
137
135
|
return void 0;
|
|
138
136
|
}
|
|
139
137
|
return result.stdout.trim();
|
|
140
138
|
} catch (e) {
|
|
141
|
-
console.
|
|
139
|
+
console.error(e);
|
|
142
140
|
return void 0;
|
|
143
141
|
}
|
|
144
142
|
}
|
package/lib/reportUploader.js
CHANGED
|
@@ -124,7 +124,8 @@ var ReportUploader = class _ReportUploader {
|
|
|
124
124
|
static async upload(options) {
|
|
125
125
|
const uploaderOptions = _ReportUploader.optionsFromEnv(options);
|
|
126
126
|
if (!uploaderOptions) {
|
|
127
|
-
|
|
127
|
+
if (process.env.CI)
|
|
128
|
+
options.log?.(`[flakiness.io] Uploading skipped since no FLAKINESS_ACCESS_TOKEN is specified`);
|
|
128
129
|
return void 0;
|
|
129
130
|
}
|
|
130
131
|
const uploader = new _ReportUploader(uploaderOptions);
|
package/lib/utils.js
CHANGED
|
@@ -127,13 +127,11 @@ function shell(command, args, options) {
|
|
|
127
127
|
try {
|
|
128
128
|
const result = spawnSync(command, args, { encoding: "utf-8", ...options });
|
|
129
129
|
if (result.status !== 0) {
|
|
130
|
-
console.log(result);
|
|
131
|
-
console.log(options);
|
|
132
130
|
return void 0;
|
|
133
131
|
}
|
|
134
132
|
return result.stdout.trim();
|
|
135
133
|
} catch (e) {
|
|
136
|
-
console.
|
|
134
|
+
console.error(e);
|
|
137
135
|
return void 0;
|
|
138
136
|
}
|
|
139
137
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flakiness/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.97.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"bin": {
|
|
6
6
|
"flakiness": "./lib/cli/cli.js"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"author": "Degu Labs, Inc",
|
|
46
46
|
"license": "Fair Source 100",
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@flakiness/server": "0.
|
|
48
|
+
"@flakiness/server": "0.97.0",
|
|
49
49
|
"@playwright/test": "^1.54.0",
|
|
50
50
|
"@types/babel__code-frame": "^7.0.6",
|
|
51
51
|
"@types/compression": "^1.8.1",
|
|
@@ -53,10 +53,11 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/code-frame": "^7.26.2",
|
|
56
|
-
"@flakiness/report": "0.
|
|
57
|
-
"@flakiness/shared": "0.
|
|
56
|
+
"@flakiness/report": "0.97.0",
|
|
57
|
+
"@flakiness/shared": "0.97.0",
|
|
58
58
|
"@rgrove/parse-xml": "^4.2.0",
|
|
59
59
|
"body-parser": "^1.20.3",
|
|
60
|
+
"chalk": "^5.6.2",
|
|
60
61
|
"commander": "^13.1.0",
|
|
61
62
|
"compression": "^1.8.1",
|
|
62
63
|
"debug": "^4.3.7",
|