Skip to content

Commit 92c5915

Browse files
refactor(ci): polish Loop info logs and dedupe failedTests derivation
Follow-up to ba9ff18. Splits the loopRequest log message from the error prefix so successful uploads log the file name again and the post success log uses a readable verb instead of a lowercased acronym. Extracts a module-private deriveFailedTestNames helper to remove the duplicated Array.from(new Set(...map(test => test.name))) expression in both Ginkgo parsers. JSON shape and markdown output unchanged. Refs: virtualization2-mm4
1 parent ba5801e commit 92c5915

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ function parseLoopApiPayload(responseText, core) {
5353
}
5454

5555
function createLoopClient({ loop, core, fetch: fetchFn = globalThis.fetch }) {
56-
async function loopRequest(url, init, errorPrefix) {
56+
async function loopRequest(url, init, { errorPrefix, successLog }) {
5757
const response = await fetchFn(url, init);
5858
const responseText = await response.text();
5959
if (!response.ok) {
6060
throw new Error(`${errorPrefix} failed with status ${response.status}: ${responseText}`);
6161
}
6262
const payload = parseLoopApiPayload(responseText, core);
63-
core.info(`Loop API accepted ${errorPrefix.toLowerCase()} with status ${response.status}`);
63+
core.info(`Loop API accepted ${successLog} with status ${response.status}`);
6464
return payload;
6565
}
6666

@@ -81,7 +81,7 @@ function createLoopClient({ loop, core, fetch: fetchFn = globalThis.fetch }) {
8181
},
8282
body: JSON.stringify(body),
8383
},
84-
"Loop API request"
84+
{ errorPrefix: "Loop API request", successLog: "post" }
8585
);
8686
}
8787

@@ -98,7 +98,7 @@ function createLoopClient({ loop, core, fetch: fetchFn = globalThis.fetch }) {
9898
},
9999
body: formData,
100100
},
101-
"Loop file upload"
101+
{ errorPrefix: "Loop file upload", successLog: `file ${name}` }
102102
);
103103
const fileId = payload.file_infos && payload.file_infos[0] && payload.file_infos[0].id;
104104
if (!fileId) {

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ function flattenLabels(labelGroups) {
5959
return labels;
6060
}
6161

62+
/**
63+
* Derives a unique list of failed test names from the canonical
64+
* `failedTestDetails` array. Kept module-private because the dedupe
65+
* semantics are an internal detail of both Ginkgo parsers in this file.
66+
*
67+
* @param {Array<{name: string, reason: string}>} failedTestDetails Detailed failures.
68+
* @returns {string[]} Unique failed test names preserving first occurrence order.
69+
*/
70+
function deriveFailedTestNames(failedTestDetails) {
71+
return Array.from(new Set(failedTestDetails.map((test) => test.name)));
72+
}
73+
6274
/**
6375
* Splits a raw Ginkgo SpecReport into stable, normalized parts used by
6476
* both the human-readable test name and per-spec timings.
@@ -231,7 +243,7 @@ function parseGinkgoReport(jsonContent) {
231243

232244
return {
233245
metrics,
234-
failedTests: Array.from(new Set(dedupedDetails.map((test) => test.name))),
246+
failedTests: deriveFailedTestNames(dedupedDetails),
235247
failedTestDetails: dedupedDetails,
236248
specTimings,
237249
suiteTotalMs,
@@ -367,7 +379,7 @@ function parseGinkgoOutput(outputContent) {
367379
const failedTestDetails = [{ name, reason }];
368380
return {
369381
metrics: zeroMetrics(),
370-
failedTests: Array.from(new Set(failedTestDetails.map((test) => test.name))),
382+
failedTests: deriveFailedTestNames(failedTestDetails),
371383
failedTestDetails,
372384
specTimings: [],
373385
suiteTotalMs: 0,

0 commit comments

Comments
 (0)