Skip to content

Commit 25ac64c

Browse files
fix formatting
Signed-off-by: Nikita Korolev <nikita.korolev@flant.com>
1 parent 3b9a115 commit 25ac64c

4 files changed

Lines changed: 107 additions & 54 deletions

File tree

.github/scripts/js/e2e/report/cluster-report.js

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -66,27 +66,11 @@ const {
6666
*/
6767

6868
const workflowStages = [
69-
{
70-
name: "bootstrap",
71-
displayName: "Bootstrap cluster",
72-
needsJobId: "bootstrap",
73-
},
74-
{
75-
name: "configure-sdn",
76-
displayName: "Configure SDN",
77-
needsJobId: "configure-sdn",
78-
},
79-
{
80-
name: "storage-setup",
81-
displayName: "Configure storage",
82-
needsJobId: "configure-storage",
83-
},
84-
{
85-
name: "virtualization-setup",
86-
displayName: "Configure Virtualization",
87-
needsJobId: "configure-virtualization",
88-
},
89-
{ name: "e2e-test", displayName: "E2E test", needsJobId: "e2e-test" },
69+
{ name: "bootstrap", displayName: "Bootstrap cluster", needsJobId: "bootstrap" },
70+
{ name: "configure-sdn", displayName: "Configure SDN", needsJobId: "configure-sdn" },
71+
{ name: "storage-setup", displayName: "Configure storage", needsJobId: "configure-storage" },
72+
{ name: "virtualization-setup", displayName: "Configure Virtualization", needsJobId: "configure-virtualization" },
73+
{ name: "e2e-test", displayName: "E2E test", needsJobId: "e2e-test" },
9074
];
9175

9276
function readClusterReportConfigFromEnv(env = process.env) {
@@ -251,7 +235,11 @@ const ginkgoOutputSource = {
251235
* @returns {string|null} Path to the source file, or null when none exists.
252236
*/
253237
function findGinkgoSource(config, source) {
254-
return findSingleMatchingFile(config.reportsDir, source.pattern(config.storageType), source.label);
238+
return findSingleMatchingFile(
239+
config.reportsDir,
240+
source.pattern(config.storageType),
241+
source.label
242+
);
255243
}
256244

257245
/**
@@ -285,21 +273,38 @@ function parseGinkgoFile(filePath, core, source) {
285273
source: source.okSource,
286274
};
287275
} catch (error) {
288-
core.warning(`Unable to parse ${source.label} ${filePath}: ${error.message}`);
276+
core.warning(
277+
`Unable to parse ${source.label} ${filePath}: ${error.message}`
278+
);
289279
return emptyParsedReport(source.invalidSource);
290280
}
291281
}
292282

293-
function buildReportPayload({ config, context, fallbackWorkflowRunUrl, branchName, parsedReport, sourcePath }) {
283+
function buildReportPayload({
284+
config,
285+
context,
286+
fallbackWorkflowRunUrl,
287+
branchName,
288+
parsedReport,
289+
sourcePath,
290+
}) {
294291
const clusterStatus = buildClusterStatus(config.stageResults);
295292
const testStatus = buildTestStatus(
296293
config.stageResults["e2e-test"],
297294
parsedReport.source,
298295
clusterStatus,
299296
parsedReport.metrics
300297
);
301-
const reportSummary = buildReportSummary(config.storageType, clusterStatus, testStatus);
302-
const workflowRunUrl = getReportJobUrl(reportSummary, config.stageJobUrls, fallbackWorkflowRunUrl);
298+
const reportSummary = buildReportSummary(
299+
config.storageType,
300+
clusterStatus,
301+
testStatus
302+
);
303+
const workflowRunUrl = getReportJobUrl(
304+
reportSummary,
305+
config.stageJobUrls,
306+
fallbackWorkflowRunUrl
307+
);
303308

304309
return {
305310
schemaVersion: 1,
@@ -327,7 +332,11 @@ function buildReportPayload({ config, context, fallbackWorkflowRunUrl, branchNam
327332
};
328333
}
329334

330-
function getReportJobUrl(reportSummary, stageJobUrls = {}, fallbackWorkflowRunUrl) {
335+
function getReportJobUrl(
336+
reportSummary,
337+
stageJobUrls = {},
338+
fallbackWorkflowRunUrl
339+
) {
331340
if (reportSummary.failedStage && stageJobUrls[reportSummary.failedStage]) {
332341
return stageJobUrls[reportSummary.failedStage];
333342
}

.github/scripts/js/e2e/report/messenger/loop-client.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,9 @@ async function uploadFileToLoop(loop, fileName, buffer, core, mimeType, { fetch:
140140
* @param {{fetch?: typeof fetch}} [options] Optional HTTP client dependencies.
141141
* @returns {Promise<void>}
142142
*/
143-
async function makeThreadedReportInLoop(
144-
{ message, threadMessages, loop },
145-
core,
146-
{ fetch: fetchFn = globalThis.fetch } = {}
147-
) {
148-
const rootPost = await postToLoopApi(loop, message, undefined, core, [], {
149-
fetch: fetchFn,
150-
});
143+
async function makeThreadedReportInLoop({ message, threadMessages, loop }, core, {
144+
fetch: fetchFn = globalThis.fetch } = {}) {
145+
const rootPost = await postToLoopApi(loop, message, undefined, core, [], { fetch: fetchFn });
151146

152147
if (!rootPost.id) {
153148
throw new Error("Loop API did not return a post id; thread replies cannot be attached");

.github/scripts/js/e2e/report/shared/ginkgo-report-utils.js

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,18 @@ function formatSpecName(specReport) {
7272
.map((part) => String(part || "").trim())
7373
.filter(Boolean);
7474
const leafText = String(specReport.LeafNodeText || "").trim();
75-
const labels = [
76-
...new Set([...flattenLabels(specReport.ContainerHierarchyLabels), ...flattenLabels(specReport.LeafNodeLabels)]),
77-
];
75+
const labels = [...new Set([
76+
...flattenLabels(specReport.ContainerHierarchyLabels),
77+
...flattenLabels(specReport.LeafNodeLabels),
78+
])];
7879
const labelSuffix = labels.map((label) => `[${label}]`).join(" ");
7980
const body = [...hierarchyParts, leafText].filter(Boolean).join(" ");
8081

81-
return [`[${nodeType}]`, body, labelSuffix].filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
82+
rreturn [`[${nodeType}]`, body, labelSuffix]
83+
.filter(Boolean)
84+
.join(" ")
85+
.replace(/\s+/g, " ")
86+
.trim();
8287
}
8388

8489
function runtimeMs(value) {
@@ -115,7 +120,10 @@ function getMetricKeyForState(state) {
115120

116121
function formatFailureReason(specReport) {
117122
const failure = (specReport && specReport.Failure) || {};
118-
return String(failure.Message || failure.ForwardedPanic || "").trim() || String(specReport.State || "failed").trim();
123+
return (
124+
String(failure.Message || failure.ForwardedPanic || "").trim() ||
125+
String(specReport.State || "failed").trim()
126+
);
119127
}
120128

121129
const failureStates = new Set(["failed", "errors"]);
@@ -211,21 +219,34 @@ function parseGinkgoReport(jsonContent) {
211219
}
212220

213221
const completedSpecs = metrics.passed + metrics.failed + metrics.errors;
214-
metrics.successRate = completedSpecs > 0 ? Number(((metrics.passed / completedSpecs) * 100).toFixed(2)) : 0;
222+
metrics.successRate =
223+
completedSpecs > 0
224+
? Number(((metrics.passed / completedSpecs) * 100).toFixed(2))
225+
: 0;
215226

216227
return {
217228
metrics,
218229
failedTests: Array.from(new Set(failedTests)),
219230
failedTestDetails: Array.from(
220-
new Map(failedTestDetails.map((test) => [`${test.name}\u0000${test.reason}`, test])).values()
231+
new Map(
232+
failedTestDetails.map((test) => [
233+
`${test.name}\u0000${test.reason}`,
234+
test,
235+
])
236+
).values()
221237
),
222238
specTimings,
223239
suiteTotalMs,
224240
startedAt,
225241
};
226242
}
227243

228-
const suiteNodeTypes = ["SynchronizedBeforeSuite", "BeforeSuite", "SynchronizedAfterSuite", "AfterSuite"];
244+
const suiteNodeTypes = [
245+
"SynchronizedBeforeSuite",
246+
"BeforeSuite",
247+
"SynchronizedAfterSuite",
248+
"AfterSuite",
249+
];
229250

230251
// Match Ginkgo failure markers for suite-level nodes in two forms:
231252
// 1. "[<SuiteNode>] [FAILED]" — main failure line in the stdout body.
@@ -272,7 +293,11 @@ function isReasonStopLine(line) {
272293
}
273294

274295
function isReasonNoiseLine(line, suiteHeader, failedMarker) {
275-
return line === suiteHeader || line.startsWith(failedMarker) || line.startsWith("/");
296+
return (
297+
line === suiteHeader ||
298+
line.startsWith(failedMarker) ||
299+
line.startsWith("/")
300+
);
276301
}
277302

278303
/**

.github/scripts/js/e2e/report/shared/report-model.js

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,21 @@ function ginkgoOutputPattern(storageType) {
5454
}
5555

5656
const stageMessage = {
57-
bootstrap: "BOOTSTRAP CLUSTER",
57+
"bootstrap": "BOOTSTRAP CLUSTER",
5858
"configure-sdn": "CONFIGURE SDN",
5959
"storage-setup": "STORAGE SETUP",
6060
"virtualization-setup": "VIRTUALIZATION SETUP",
6161
"e2e-test": "E2E TEST",
62-
ready: "CLUSTER READY",
62+
"ready": "CLUSTER READY",
6363
"artifact-missing": "TEST REPORTS NOT FOUND",
6464
};
6565

66-
const clusterSetupStages = ["bootstrap", "configure-sdn", "storage-setup", "virtualization-setup"];
66+
const clusterSetupStages = [
67+
"bootstrap",
68+
"configure-sdn",
69+
"storage-setup",
70+
"virtualization-setup",
71+
];
6772

6873
function zeroMetrics() {
6974
return {
@@ -129,7 +134,12 @@ function buildClusterStatus(stageResults) {
129134
};
130135
}
131136

132-
function buildTestStatus(testResult, reportSource, clusterStatus, metrics = {}) {
137+
function buildTestStatus(
138+
testResult,
139+
reportSource,
140+
clusterStatus,
141+
metrics = {}
142+
) {
133143
const stageLabel = stageMessage["e2e-test"];
134144

135145
if (clusterStatus.status !== "success") {
@@ -143,13 +153,20 @@ function buildTestStatus(testResult, reportSource, clusterStatus, metrics = {})
143153
const normalizedResult = normalizeJobResult(testResult);
144154

145155
if (reportSource === "ginkgo-json" || reportSource === "ginkgo-output") {
146-
const hasReportedFailures = Number(metrics.failed || 0) > 0 || Number(metrics.errors || 0) > 0;
147-
const status = normalizedResult === "success" && hasReportedFailures ? "failure" : normalizedResult;
156+
const hasReportedFailures =
157+
Number(metrics.failed || 0) > 0 || Number(metrics.errors || 0) > 0;
158+
const status =
159+
normalizedResult === "success" && hasReportedFailures
160+
? "failure"
161+
: normalizedResult;
148162

149163
return {
150164
status,
151165
reason: status === "success" ? "" : "ginkgo-failed",
152-
message: status === "success" ? "✅ E2E TESTS PASSED" : buildStatusMessage(status, stageLabel),
166+
message:
167+
status === "success"
168+
? "✅ E2E TESTS PASSED"
169+
: buildStatusMessage(status, stageLabel),
153170
};
154171
}
155172

@@ -218,7 +235,8 @@ function buildReportSummary(storageType, clusterStatus, testStatus) {
218235

219236
return {
220237
failedStage: testStatus.status === "success" ? "success" : "e2e-test",
221-
failedStageLabel: testStatus.status === "success" ? "SUCCESS" : stageMessage["e2e-test"],
238+
failedStageLabel:
239+
testStatus.status === "success" ? "SUCCESS" : stageMessage["e2e-test"],
222240
failedJobName: `E2E test (${storageType})`,
223241
reportKind: "tests",
224242
status: testStatus.status,
@@ -238,7 +256,10 @@ function isMissingReport(report) {
238256

239257
function isClusterFailureReport(report) {
240258
if (report.clusterStatus) {
241-
return report.clusterStatus.status !== "success" && report.clusterStatus.status !== "missing";
259+
return (
260+
report.clusterStatus.status !== "success" &&
261+
report.clusterStatus.status !== "missing"
262+
);
242263
}
243264

244265
return report.reportKind !== "tests" && !isMissingReport(report);
@@ -250,7 +271,10 @@ function isTestResultReport(report) {
250271
}
251272

252273
if (report.testStatus) {
253-
return report.testStatus.status !== "not-run" && report.testStatus.status !== "missing";
274+
return (
275+
report.testStatus.status !== "not-run" &&
276+
report.testStatus.status !== "missing"
277+
);
254278
}
255279

256280
return report.reportKind === "tests";

0 commit comments

Comments
 (0)