@flakiness/sdk 2.3.1 → 2.5.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 +3 -2
- package/lib/browser.js +4 -157
- package/lib/index.js +12 -157
- package/package.json +2 -2
- package/types/src/ciUtils.d.ts +21 -0
- package/types/src/ciUtils.d.ts.map +1 -1
- package/types/src/stripAnsi.d.ts +1 -3
- package/types/src/stripAnsi.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ The Flakiness SDK provides a comprehensive set of tools for creating and managin
|
|
|
10
10
|
npm i @flakiness/sdk @flakiness/flakiness-report
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Requires Node.js 22
|
|
13
|
+
Requires Node.js ^20.17.0 or >=22.9.0.
|
|
14
14
|
|
|
15
15
|
## Quick Start
|
|
16
16
|
|
|
@@ -34,6 +34,7 @@ const env = ReportUtils.createEnvironment({ name: 'CI' });
|
|
|
34
34
|
const report: FlakinessReport.Report = {
|
|
35
35
|
category: 'testreport',
|
|
36
36
|
commitId: worktree.headCommitId(),
|
|
37
|
+
title: CIUtils.runTitle(),
|
|
37
38
|
url: CIUtils.runUrl(),
|
|
38
39
|
environments: [env],
|
|
39
40
|
suites: [{
|
|
@@ -82,7 +83,7 @@ Use this entry point when you need to process or manipulate reports in browser-b
|
|
|
82
83
|
## Top-Level Exports
|
|
83
84
|
|
|
84
85
|
### Building Reports
|
|
85
|
-
- **`CIUtils`** - Utilities to extract CI/CD information (run URLs, environment detection)
|
|
86
|
+
- **`CIUtils`** - Utilities to extract CI/CD information (run URLs, run titles, environment detection)
|
|
86
87
|
- **`GithubOIDC`** - GitHub Actions OIDC integration for passwordless Flakiness.io authentication
|
|
87
88
|
- **`GitWorktree`** - Git repository utilities for path conversion and commit information
|
|
88
89
|
- **`ReportUtils`** - Namespace with utilities for report creation and manipulation:
|
package/lib/browser.js
CHANGED
|
@@ -13,162 +13,8 @@ __export(reportUtilsBrowser_exports, {
|
|
|
13
13
|
visitTests: () => visitTests
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
// node_modules/.pnpm/@flakiness+flakiness-report@0.28.0_zod@4.3.5/node_modules/@flakiness/flakiness-report/lib/flakinessReport.js
|
|
17
|
-
var FlakinessReport;
|
|
18
|
-
((FlakinessReport22) => {
|
|
19
|
-
FlakinessReport22.CATEGORY_PLAYWRIGHT = "playwright";
|
|
20
|
-
FlakinessReport22.CATEGORY_PYTEST = "pytest";
|
|
21
|
-
FlakinessReport22.CATEGORY_JUNIT = "junit";
|
|
22
|
-
FlakinessReport22.STREAM_STDOUT = 1;
|
|
23
|
-
FlakinessReport22.STREAM_STDERR = 2;
|
|
24
|
-
})(FlakinessReport || (FlakinessReport = {}));
|
|
25
|
-
|
|
26
|
-
// node_modules/.pnpm/@flakiness+flakiness-report@0.28.0_zod@4.3.5/node_modules/@flakiness/flakiness-report/lib/schema.js
|
|
27
|
-
import z from "zod/v4";
|
|
28
|
-
var Schema;
|
|
29
|
-
((Schema2) => {
|
|
30
|
-
Schema2.CommitId = z.string().min(40).max(40);
|
|
31
|
-
Schema2.AttachmentId = z.string().min(1).max(1024);
|
|
32
|
-
Schema2.UnixTimestampMS = z.number().min(0);
|
|
33
|
-
Schema2.DurationMS = z.number().min(0);
|
|
34
|
-
Schema2.Number1Based = z.number();
|
|
35
|
-
Schema2.GitFilePath = z.string().min(0);
|
|
36
|
-
Schema2.Location = z.object({
|
|
37
|
-
file: Schema2.GitFilePath,
|
|
38
|
-
line: Schema2.Number1Based,
|
|
39
|
-
// Note: Locations for file suites are (0, 0).
|
|
40
|
-
column: Schema2.Number1Based
|
|
41
|
-
});
|
|
42
|
-
Schema2.TestStatus = z.enum(["passed", "failed", "timedOut", "skipped", "interrupted"]);
|
|
43
|
-
Schema2.Environment = z.object({
|
|
44
|
-
name: z.string().min(1).max(512),
|
|
45
|
-
systemData: z.object({
|
|
46
|
-
osName: z.string().optional(),
|
|
47
|
-
osVersion: z.string().optional(),
|
|
48
|
-
osArch: z.string().optional()
|
|
49
|
-
}).optional(),
|
|
50
|
-
metadata: z.any().optional(),
|
|
51
|
-
userSuppliedData: z.any().optional()
|
|
52
|
-
});
|
|
53
|
-
Schema2.STDIOEntry = z.union([
|
|
54
|
-
z.object({ text: z.string() }),
|
|
55
|
-
z.object({ buffer: z.string() })
|
|
56
|
-
]);
|
|
57
|
-
Schema2.STREAM_STDOUT = z.literal(FlakinessReport.STREAM_STDOUT);
|
|
58
|
-
Schema2.STREAM_STDERR = z.literal(FlakinessReport.STREAM_STDERR);
|
|
59
|
-
Schema2.TimedSTDIOEntry = z.object({
|
|
60
|
-
stream: z.union([Schema2.STREAM_STDOUT, Schema2.STREAM_STDERR]).optional(),
|
|
61
|
-
dts: Schema2.DurationMS
|
|
62
|
-
}).and(z.union([
|
|
63
|
-
z.object({ text: z.string() }),
|
|
64
|
-
z.object({ buffer: z.string() })
|
|
65
|
-
]));
|
|
66
|
-
Schema2.ReportError = z.object({
|
|
67
|
-
location: Schema2.Location.optional(),
|
|
68
|
-
message: z.string().optional(),
|
|
69
|
-
stack: z.string().optional(),
|
|
70
|
-
snippet: z.string().optional(),
|
|
71
|
-
value: z.string().optional()
|
|
72
|
-
});
|
|
73
|
-
Schema2.SuiteType = z.enum(["file", "anonymous suite", "suite"]);
|
|
74
|
-
Schema2.TestStep = z.object({
|
|
75
|
-
title: z.string(),
|
|
76
|
-
duration: Schema2.DurationMS.optional(),
|
|
77
|
-
location: Schema2.Location.optional(),
|
|
78
|
-
snippet: z.string().optional(),
|
|
79
|
-
error: Schema2.ReportError.optional(),
|
|
80
|
-
get steps() {
|
|
81
|
-
return z.array(Schema2.TestStep).optional();
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
Schema2.Attachment = z.object({
|
|
85
|
-
name: z.string(),
|
|
86
|
-
contentType: z.string(),
|
|
87
|
-
id: Schema2.AttachmentId
|
|
88
|
-
});
|
|
89
|
-
Schema2.Annotation = z.object({
|
|
90
|
-
type: z.string(),
|
|
91
|
-
description: z.string().optional(),
|
|
92
|
-
location: Schema2.Location.optional()
|
|
93
|
-
});
|
|
94
|
-
Schema2.RunAttempt = z.object({
|
|
95
|
-
// Index of the environment in the environments array (must be >= 0).
|
|
96
|
-
environmentIdx: z.number().min(0).optional(),
|
|
97
|
-
expectedStatus: Schema2.TestStatus.optional(),
|
|
98
|
-
status: Schema2.TestStatus.optional(),
|
|
99
|
-
startTimestamp: Schema2.UnixTimestampMS,
|
|
100
|
-
duration: Schema2.DurationMS.optional(),
|
|
101
|
-
timeout: Schema2.DurationMS.optional(),
|
|
102
|
-
annotations: z.array(Schema2.Annotation).optional(),
|
|
103
|
-
errors: z.array(Schema2.ReportError).optional(),
|
|
104
|
-
parallelIndex: z.number().optional(),
|
|
105
|
-
steps: z.array(Schema2.TestStep).optional(),
|
|
106
|
-
stdio: z.array(Schema2.TimedSTDIOEntry).optional(),
|
|
107
|
-
stdout: z.array(Schema2.STDIOEntry).optional(),
|
|
108
|
-
stderr: z.array(Schema2.STDIOEntry).optional(),
|
|
109
|
-
attachments: z.array(Schema2.Attachment).optional()
|
|
110
|
-
});
|
|
111
|
-
Schema2.Suite = z.object({
|
|
112
|
-
type: Schema2.SuiteType,
|
|
113
|
-
title: z.string(),
|
|
114
|
-
location: Schema2.Location.optional(),
|
|
115
|
-
get suites() {
|
|
116
|
-
return z.array(Schema2.Suite).optional();
|
|
117
|
-
},
|
|
118
|
-
get tests() {
|
|
119
|
-
return z.array(Schema2.Test).optional();
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
Schema2.Test = z.object({
|
|
123
|
-
title: z.string(),
|
|
124
|
-
location: Schema2.Location.optional(),
|
|
125
|
-
tags: z.array(z.string()).optional(),
|
|
126
|
-
attempts: z.array(Schema2.RunAttempt)
|
|
127
|
-
});
|
|
128
|
-
Schema2.SystemUtilizationSample = z.object({
|
|
129
|
-
dts: Schema2.DurationMS,
|
|
130
|
-
// Must be between 0 and 100 (inclusive). Can be a rational number.
|
|
131
|
-
cpuUtilization: z.number().min(0).max(100),
|
|
132
|
-
// Must be between 0 and 100 (inclusive). Can be a rational number.
|
|
133
|
-
memoryUtilization: z.number().min(0).max(100)
|
|
134
|
-
});
|
|
135
|
-
Schema2.SystemUtilization = z.object({
|
|
136
|
-
totalMemoryBytes: z.number().min(0),
|
|
137
|
-
startTimestamp: Schema2.UnixTimestampMS,
|
|
138
|
-
samples: z.array(Schema2.SystemUtilizationSample)
|
|
139
|
-
});
|
|
140
|
-
Schema2.UtilizationTelemetry = z.tuple([Schema2.DurationMS, z.number().min(0).max(100)]);
|
|
141
|
-
Schema2.Source = z.object({
|
|
142
|
-
filePath: Schema2.GitFilePath,
|
|
143
|
-
text: z.string(),
|
|
144
|
-
lineOffset: z.number().optional(),
|
|
145
|
-
contentType: z.string().optional()
|
|
146
|
-
});
|
|
147
|
-
Schema2.FlakinessProject = z.string();
|
|
148
|
-
Schema2.Report = z.object({
|
|
149
|
-
sources: z.array(Schema2.Source).optional(),
|
|
150
|
-
flakinessProject: Schema2.FlakinessProject.optional(),
|
|
151
|
-
category: z.string().min(1).max(100),
|
|
152
|
-
commitId: Schema2.CommitId,
|
|
153
|
-
relatedCommitIds: z.array(Schema2.CommitId).optional(),
|
|
154
|
-
configPath: Schema2.GitFilePath.optional(),
|
|
155
|
-
url: z.string().optional(),
|
|
156
|
-
environments: z.array(Schema2.Environment).min(1),
|
|
157
|
-
suites: z.array(Schema2.Suite).optional(),
|
|
158
|
-
tests: z.array(Schema2.Test).optional(),
|
|
159
|
-
unattributedErrors: z.array(Schema2.ReportError).optional(),
|
|
160
|
-
startTimestamp: Schema2.UnixTimestampMS,
|
|
161
|
-
duration: Schema2.DurationMS,
|
|
162
|
-
systemUtilization: z.optional(Schema2.SystemUtilization),
|
|
163
|
-
cpuCount: z.number().min(0).optional(),
|
|
164
|
-
cpuAvg: z.array(Schema2.UtilizationTelemetry).optional(),
|
|
165
|
-
cpuMax: z.array(Schema2.UtilizationTelemetry).optional(),
|
|
166
|
-
ram: z.array(Schema2.UtilizationTelemetry).optional(),
|
|
167
|
-
ramBytes: z.number().min(0).optional()
|
|
168
|
-
});
|
|
169
|
-
})(Schema || (Schema = {}));
|
|
170
|
-
|
|
171
16
|
// src/normalizeReport.ts
|
|
17
|
+
import { FlakinessReport } from "@flakiness/flakiness-report";
|
|
172
18
|
import stableObjectHash from "stable-hash";
|
|
173
19
|
var Multimap = class {
|
|
174
20
|
_map = /* @__PURE__ */ new Map();
|
|
@@ -327,7 +173,8 @@ function computeTestId(test, suiteId) {
|
|
|
327
173
|
}
|
|
328
174
|
|
|
329
175
|
// src/validateReport.ts
|
|
330
|
-
import
|
|
176
|
+
import { Schema } from "@flakiness/flakiness-report";
|
|
177
|
+
import z from "zod/v4";
|
|
331
178
|
function validateReport(report) {
|
|
332
179
|
const validation = Schema.Report.safeParse(report);
|
|
333
180
|
if (!validation.success) {
|
|
@@ -335,7 +182,7 @@ function validateReport(report) {
|
|
|
335
182
|
const allIssues = validation.error.issues;
|
|
336
183
|
const shownIssues = allIssues.slice(0, MAX_ISSUES);
|
|
337
184
|
const remaining = allIssues.length - shownIssues.length;
|
|
338
|
-
const base = [
|
|
185
|
+
const base = [z.prettifyError(new z.ZodError(shownIssues))];
|
|
339
186
|
if (remaining > 0)
|
|
340
187
|
base.push(`... and ${remaining} more issue${remaining === 1 ? "" : "s"} ...`);
|
|
341
188
|
return base.join("\n");
|
package/lib/index.js
CHANGED
|
@@ -7,11 +7,19 @@ var __export = (target, all) => {
|
|
|
7
7
|
// src/ciUtils.ts
|
|
8
8
|
var CIUtils;
|
|
9
9
|
((CIUtils2) => {
|
|
10
|
+
function runTitle() {
|
|
11
|
+
return githubActionsTitle();
|
|
12
|
+
}
|
|
13
|
+
CIUtils2.runTitle = runTitle;
|
|
10
14
|
function runUrl() {
|
|
11
15
|
return githubActions() ?? azure() ?? process.env.CI_JOB_URL ?? process.env.BUILD_URL;
|
|
12
16
|
}
|
|
13
17
|
CIUtils2.runUrl = runUrl;
|
|
14
18
|
})(CIUtils || (CIUtils = {}));
|
|
19
|
+
function githubActionsTitle() {
|
|
20
|
+
const title = process.env.GITHUB_WORKFLOW?.trim();
|
|
21
|
+
return title || void 0;
|
|
22
|
+
}
|
|
15
23
|
function githubActions() {
|
|
16
24
|
const serverUrl = process.env.GITHUB_SERVER_URL || "https://github.com";
|
|
17
25
|
const repo = process.env.GITHUB_REPOSITORY;
|
|
@@ -679,162 +687,8 @@ function createEnvironment(options) {
|
|
|
679
687
|
};
|
|
680
688
|
}
|
|
681
689
|
|
|
682
|
-
// node_modules/.pnpm/@flakiness+flakiness-report@0.28.0_zod@4.3.5/node_modules/@flakiness/flakiness-report/lib/flakinessReport.js
|
|
683
|
-
var FlakinessReport;
|
|
684
|
-
((FlakinessReport22) => {
|
|
685
|
-
FlakinessReport22.CATEGORY_PLAYWRIGHT = "playwright";
|
|
686
|
-
FlakinessReport22.CATEGORY_PYTEST = "pytest";
|
|
687
|
-
FlakinessReport22.CATEGORY_JUNIT = "junit";
|
|
688
|
-
FlakinessReport22.STREAM_STDOUT = 1;
|
|
689
|
-
FlakinessReport22.STREAM_STDERR = 2;
|
|
690
|
-
})(FlakinessReport || (FlakinessReport = {}));
|
|
691
|
-
|
|
692
|
-
// node_modules/.pnpm/@flakiness+flakiness-report@0.28.0_zod@4.3.5/node_modules/@flakiness/flakiness-report/lib/schema.js
|
|
693
|
-
import z from "zod/v4";
|
|
694
|
-
var Schema;
|
|
695
|
-
((Schema2) => {
|
|
696
|
-
Schema2.CommitId = z.string().min(40).max(40);
|
|
697
|
-
Schema2.AttachmentId = z.string().min(1).max(1024);
|
|
698
|
-
Schema2.UnixTimestampMS = z.number().min(0);
|
|
699
|
-
Schema2.DurationMS = z.number().min(0);
|
|
700
|
-
Schema2.Number1Based = z.number();
|
|
701
|
-
Schema2.GitFilePath = z.string().min(0);
|
|
702
|
-
Schema2.Location = z.object({
|
|
703
|
-
file: Schema2.GitFilePath,
|
|
704
|
-
line: Schema2.Number1Based,
|
|
705
|
-
// Note: Locations for file suites are (0, 0).
|
|
706
|
-
column: Schema2.Number1Based
|
|
707
|
-
});
|
|
708
|
-
Schema2.TestStatus = z.enum(["passed", "failed", "timedOut", "skipped", "interrupted"]);
|
|
709
|
-
Schema2.Environment = z.object({
|
|
710
|
-
name: z.string().min(1).max(512),
|
|
711
|
-
systemData: z.object({
|
|
712
|
-
osName: z.string().optional(),
|
|
713
|
-
osVersion: z.string().optional(),
|
|
714
|
-
osArch: z.string().optional()
|
|
715
|
-
}).optional(),
|
|
716
|
-
metadata: z.any().optional(),
|
|
717
|
-
userSuppliedData: z.any().optional()
|
|
718
|
-
});
|
|
719
|
-
Schema2.STDIOEntry = z.union([
|
|
720
|
-
z.object({ text: z.string() }),
|
|
721
|
-
z.object({ buffer: z.string() })
|
|
722
|
-
]);
|
|
723
|
-
Schema2.STREAM_STDOUT = z.literal(FlakinessReport.STREAM_STDOUT);
|
|
724
|
-
Schema2.STREAM_STDERR = z.literal(FlakinessReport.STREAM_STDERR);
|
|
725
|
-
Schema2.TimedSTDIOEntry = z.object({
|
|
726
|
-
stream: z.union([Schema2.STREAM_STDOUT, Schema2.STREAM_STDERR]).optional(),
|
|
727
|
-
dts: Schema2.DurationMS
|
|
728
|
-
}).and(z.union([
|
|
729
|
-
z.object({ text: z.string() }),
|
|
730
|
-
z.object({ buffer: z.string() })
|
|
731
|
-
]));
|
|
732
|
-
Schema2.ReportError = z.object({
|
|
733
|
-
location: Schema2.Location.optional(),
|
|
734
|
-
message: z.string().optional(),
|
|
735
|
-
stack: z.string().optional(),
|
|
736
|
-
snippet: z.string().optional(),
|
|
737
|
-
value: z.string().optional()
|
|
738
|
-
});
|
|
739
|
-
Schema2.SuiteType = z.enum(["file", "anonymous suite", "suite"]);
|
|
740
|
-
Schema2.TestStep = z.object({
|
|
741
|
-
title: z.string(),
|
|
742
|
-
duration: Schema2.DurationMS.optional(),
|
|
743
|
-
location: Schema2.Location.optional(),
|
|
744
|
-
snippet: z.string().optional(),
|
|
745
|
-
error: Schema2.ReportError.optional(),
|
|
746
|
-
get steps() {
|
|
747
|
-
return z.array(Schema2.TestStep).optional();
|
|
748
|
-
}
|
|
749
|
-
});
|
|
750
|
-
Schema2.Attachment = z.object({
|
|
751
|
-
name: z.string(),
|
|
752
|
-
contentType: z.string(),
|
|
753
|
-
id: Schema2.AttachmentId
|
|
754
|
-
});
|
|
755
|
-
Schema2.Annotation = z.object({
|
|
756
|
-
type: z.string(),
|
|
757
|
-
description: z.string().optional(),
|
|
758
|
-
location: Schema2.Location.optional()
|
|
759
|
-
});
|
|
760
|
-
Schema2.RunAttempt = z.object({
|
|
761
|
-
// Index of the environment in the environments array (must be >= 0).
|
|
762
|
-
environmentIdx: z.number().min(0).optional(),
|
|
763
|
-
expectedStatus: Schema2.TestStatus.optional(),
|
|
764
|
-
status: Schema2.TestStatus.optional(),
|
|
765
|
-
startTimestamp: Schema2.UnixTimestampMS,
|
|
766
|
-
duration: Schema2.DurationMS.optional(),
|
|
767
|
-
timeout: Schema2.DurationMS.optional(),
|
|
768
|
-
annotations: z.array(Schema2.Annotation).optional(),
|
|
769
|
-
errors: z.array(Schema2.ReportError).optional(),
|
|
770
|
-
parallelIndex: z.number().optional(),
|
|
771
|
-
steps: z.array(Schema2.TestStep).optional(),
|
|
772
|
-
stdio: z.array(Schema2.TimedSTDIOEntry).optional(),
|
|
773
|
-
stdout: z.array(Schema2.STDIOEntry).optional(),
|
|
774
|
-
stderr: z.array(Schema2.STDIOEntry).optional(),
|
|
775
|
-
attachments: z.array(Schema2.Attachment).optional()
|
|
776
|
-
});
|
|
777
|
-
Schema2.Suite = z.object({
|
|
778
|
-
type: Schema2.SuiteType,
|
|
779
|
-
title: z.string(),
|
|
780
|
-
location: Schema2.Location.optional(),
|
|
781
|
-
get suites() {
|
|
782
|
-
return z.array(Schema2.Suite).optional();
|
|
783
|
-
},
|
|
784
|
-
get tests() {
|
|
785
|
-
return z.array(Schema2.Test).optional();
|
|
786
|
-
}
|
|
787
|
-
});
|
|
788
|
-
Schema2.Test = z.object({
|
|
789
|
-
title: z.string(),
|
|
790
|
-
location: Schema2.Location.optional(),
|
|
791
|
-
tags: z.array(z.string()).optional(),
|
|
792
|
-
attempts: z.array(Schema2.RunAttempt)
|
|
793
|
-
});
|
|
794
|
-
Schema2.SystemUtilizationSample = z.object({
|
|
795
|
-
dts: Schema2.DurationMS,
|
|
796
|
-
// Must be between 0 and 100 (inclusive). Can be a rational number.
|
|
797
|
-
cpuUtilization: z.number().min(0).max(100),
|
|
798
|
-
// Must be between 0 and 100 (inclusive). Can be a rational number.
|
|
799
|
-
memoryUtilization: z.number().min(0).max(100)
|
|
800
|
-
});
|
|
801
|
-
Schema2.SystemUtilization = z.object({
|
|
802
|
-
totalMemoryBytes: z.number().min(0),
|
|
803
|
-
startTimestamp: Schema2.UnixTimestampMS,
|
|
804
|
-
samples: z.array(Schema2.SystemUtilizationSample)
|
|
805
|
-
});
|
|
806
|
-
Schema2.UtilizationTelemetry = z.tuple([Schema2.DurationMS, z.number().min(0).max(100)]);
|
|
807
|
-
Schema2.Source = z.object({
|
|
808
|
-
filePath: Schema2.GitFilePath,
|
|
809
|
-
text: z.string(),
|
|
810
|
-
lineOffset: z.number().optional(),
|
|
811
|
-
contentType: z.string().optional()
|
|
812
|
-
});
|
|
813
|
-
Schema2.FlakinessProject = z.string();
|
|
814
|
-
Schema2.Report = z.object({
|
|
815
|
-
sources: z.array(Schema2.Source).optional(),
|
|
816
|
-
flakinessProject: Schema2.FlakinessProject.optional(),
|
|
817
|
-
category: z.string().min(1).max(100),
|
|
818
|
-
commitId: Schema2.CommitId,
|
|
819
|
-
relatedCommitIds: z.array(Schema2.CommitId).optional(),
|
|
820
|
-
configPath: Schema2.GitFilePath.optional(),
|
|
821
|
-
url: z.string().optional(),
|
|
822
|
-
environments: z.array(Schema2.Environment).min(1),
|
|
823
|
-
suites: z.array(Schema2.Suite).optional(),
|
|
824
|
-
tests: z.array(Schema2.Test).optional(),
|
|
825
|
-
unattributedErrors: z.array(Schema2.ReportError).optional(),
|
|
826
|
-
startTimestamp: Schema2.UnixTimestampMS,
|
|
827
|
-
duration: Schema2.DurationMS,
|
|
828
|
-
systemUtilization: z.optional(Schema2.SystemUtilization),
|
|
829
|
-
cpuCount: z.number().min(0).optional(),
|
|
830
|
-
cpuAvg: z.array(Schema2.UtilizationTelemetry).optional(),
|
|
831
|
-
cpuMax: z.array(Schema2.UtilizationTelemetry).optional(),
|
|
832
|
-
ram: z.array(Schema2.UtilizationTelemetry).optional(),
|
|
833
|
-
ramBytes: z.number().min(0).optional()
|
|
834
|
-
});
|
|
835
|
-
})(Schema || (Schema = {}));
|
|
836
|
-
|
|
837
690
|
// src/normalizeReport.ts
|
|
691
|
+
import { FlakinessReport } from "@flakiness/flakiness-report";
|
|
838
692
|
import stableObjectHash from "stable-hash";
|
|
839
693
|
var Multimap = class {
|
|
840
694
|
_map = /* @__PURE__ */ new Map();
|
|
@@ -993,7 +847,8 @@ function computeTestId(test, suiteId) {
|
|
|
993
847
|
}
|
|
994
848
|
|
|
995
849
|
// src/validateReport.ts
|
|
996
|
-
import
|
|
850
|
+
import { Schema } from "@flakiness/flakiness-report";
|
|
851
|
+
import z from "zod/v4";
|
|
997
852
|
function validateReport(report) {
|
|
998
853
|
const validation = Schema.Report.safeParse(report);
|
|
999
854
|
if (!validation.success) {
|
|
@@ -1001,7 +856,7 @@ function validateReport(report) {
|
|
|
1001
856
|
const allIssues = validation.error.issues;
|
|
1002
857
|
const shownIssues = allIssues.slice(0, MAX_ISSUES);
|
|
1003
858
|
const remaining = allIssues.length - shownIssues.length;
|
|
1004
|
-
const base = [
|
|
859
|
+
const base = [z.prettifyError(new z.ZodError(shownIssues))];
|
|
1005
860
|
if (remaining > 0)
|
|
1006
861
|
base.push(`... and ${remaining} more issue${remaining === 1 ? "" : "s"} ...`);
|
|
1007
862
|
return base.join("\n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flakiness/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"author": "Degu Labs, Inc",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"engines": {
|
|
28
|
-
"node": ">=22"
|
|
28
|
+
"node": "^20.17.0 || >=22.9.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@flakiness/flakiness-report": "^0.28.0",
|
package/types/src/ciUtils.d.ts
CHANGED
|
@@ -5,6 +5,27 @@
|
|
|
5
5
|
* from various CI/CD environments, including GitHub Actions, Azure DevOps, Jenkins, and others.
|
|
6
6
|
*/
|
|
7
7
|
export declare namespace CIUtils {
|
|
8
|
+
/**
|
|
9
|
+
* Automatically extracts a human-readable CI run title when available.
|
|
10
|
+
*
|
|
11
|
+
* This function attempts to detect the current CI environment and return a
|
|
12
|
+
* stable title that identifies the workflow or pipeline generating the report.
|
|
13
|
+
*
|
|
14
|
+
* Supported CI providers (checked in order):
|
|
15
|
+
* - GitHub Actions (via `GITHUB_WORKFLOW`)
|
|
16
|
+
*
|
|
17
|
+
* @returns {string | undefined} The CI run title, or `undefined` if no supported
|
|
18
|
+
* CI environment exposes a stable human-readable title.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const report: FlakinessReport.Report = {
|
|
23
|
+
* // ... other report properties
|
|
24
|
+
* title: CIUtils.runTitle(),
|
|
25
|
+
* };
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function runTitle(): string | undefined;
|
|
8
29
|
/**
|
|
9
30
|
* Automatically extracts the run URL for common continuous integration providers.
|
|
10
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ciUtils.d.ts","sourceRoot":"","sources":["../../src/ciUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,yBAAiB,OAAO,CAAC;IACvB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,SAAgB,MAAM,IAAI,MAAM,GAAG,SAAS,CAE3C;CACF"}
|
|
1
|
+
{"version":3,"file":"ciUtils.d.ts","sourceRoot":"","sources":["../../src/ciUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,yBAAiB,OAAO,CAAC;IACvB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,SAAgB,QAAQ,IAAI,MAAM,GAAG,SAAS,CAE7C;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,SAAgB,MAAM,IAAI,MAAM,GAAG,SAAS,CAE3C;CACF"}
|
package/types/src/stripAnsi.d.ts
CHANGED
|
@@ -11,9 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* const clean = stripAnsi(styleText('red', 'Error: test failed'));
|
|
14
|
+
* const clean = stripAnsi('\u001B[31mError: test failed\u001B[39m');
|
|
17
15
|
* // Returns: 'Error: test failed' (without color codes)
|
|
18
16
|
* ```
|
|
19
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripAnsi.d.ts","sourceRoot":"","sources":["../../src/stripAnsi.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"stripAnsi.d.ts","sourceRoot":"","sources":["../../src/stripAnsi.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C"}
|