From 46395bd2490b7f34875681aed0b78b038bcbee13 Mon Sep 17 00:00:00 2001 From: Nicolas Hrubec Date: Wed, 17 Jun 2026 09:52:03 +0200 Subject: [PATCH 1/2] fix(ci): Dedup flaky test issues across esm/cjs variants Suites that run under both module formats nest the variant as an `esm/cjs > esm` / `esm/cjs > cjs` describe pair, producing two separate flaky-test issues for the same underlying test. Normalize the test name to drop the format leaf so both variants dedupe to a single issue. Co-Authored-By: Claude Opus 4.8 (1M context) --- scripts/report-ci-failures.mjs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/report-ci-failures.mjs b/scripts/report-ci-failures.mjs index a6fa00fee44f..34486ecde2c3 100644 --- a/scripts/report-ci-failures.mjs +++ b/scripts/report-ci-failures.mjs @@ -34,6 +34,22 @@ function normalizeJobName(name) { .trim(); } +/** + * Collapse esm/cjs variants of a test name so the same test failing in both module formats dedupes + * to a single issue instead of one per format. Suites that run under both formats nest the variant + * as a `esm/cjs > esm` / `esm/cjs > cjs` describe pair — we drop the format leaf, keeping the + * `esm/cjs` parent so the test path stays readable: + * + * "... > esm/cjs > esm > should send messages" -> "... > esm/cjs > should send messages" + * "... > esm/cjs > cjs > should send messages" -> "... > esm/cjs > should send messages" + */ +function normalizeTestName(name) { + return name + .replace(/esm\/cjs\s*>\s*(?:esm|cjs)\b/gi, 'esm/cjs') + .replace(/\s+/g, ' ') + .trim(); +} + function applyVars(text, vars) { let result = text; for (const [key, value] of Object.entries(vars)) { @@ -108,9 +124,10 @@ export default async function run({ github, context, core }) { // Create one issue per failing test for proper deduplication for (const testName of testNames) { - // The title is keyed on the *normalized* job name so the same test failing across matrix - // variants (different node / TS versions) dedupes to a single issue. - const title = applyVars(titleTemplate, { JOB_NAME: normalizedJobName, TEST_NAME: testName }); + // The title is keyed on the *normalized* job name + test name so the same test failing across + // matrix variants (different node / TS versions) or module formats (esm / cjs) dedupes to a + // single issue. + const title = applyVars(titleTemplate, { JOB_NAME: normalizedJobName, TEST_NAME: normalizeTestName(testName) }); // The body keeps the concrete job name + run link of the variant that actually failed. const issueBody = applyVars(bodyTemplate, { JOB_NAME: jobName, RUN_LINK: jobUrl, TEST_NAME: testName }); From 582573b3bcf4b9bac07cf34afe7b8d7edbdbcb32 Mon Sep 17 00:00:00 2001 From: Nicolas Hrubec Date: Wed, 17 Jun 2026 10:23:56 +0200 Subject: [PATCH 2/2] fix(ci): Key issue title and logs on the normalized test name Use the normalized test name for the issue title and log lines so esm/cjs variants dedupe, while the body keeps the concrete variant that failed. Co-Authored-By: Claude Opus 4.8 (1M context) --- scripts/report-ci-failures.mjs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/report-ci-failures.mjs b/scripts/report-ci-failures.mjs index 34486ecde2c3..02b118dc780d 100644 --- a/scripts/report-ci-failures.mjs +++ b/scripts/report-ci-failures.mjs @@ -36,9 +36,7 @@ function normalizeJobName(name) { /** * Collapse esm/cjs variants of a test name so the same test failing in both module formats dedupes - * to a single issue instead of one per format. Suites that run under both formats nest the variant - * as a `esm/cjs > esm` / `esm/cjs > cjs` describe pair — we drop the format leaf, keeping the - * `esm/cjs` parent so the test path stays readable: + * to a single issue instead of one per variant: * * "... > esm/cjs > esm > should send messages" -> "... > esm/cjs > should send messages" * "... > esm/cjs > cjs > should send messages" -> "... > esm/cjs > should send messages" @@ -124,10 +122,12 @@ export default async function run({ github, context, core }) { // Create one issue per failing test for proper deduplication for (const testName of testNames) { + const normalizedTestName = normalizeTestName(testName); + // The title is keyed on the *normalized* job name + test name so the same test failing across // matrix variants (different node / TS versions) or module formats (esm / cjs) dedupes to a // single issue. - const title = applyVars(titleTemplate, { JOB_NAME: normalizedJobName, TEST_NAME: normalizeTestName(testName) }); + const title = applyVars(titleTemplate, { JOB_NAME: normalizedJobName, TEST_NAME: normalizedTestName }); // The body keeps the concrete job name + run link of the variant that actually failed. const issueBody = applyVars(bodyTemplate, { JOB_NAME: jobName, RUN_LINK: jobUrl, TEST_NAME: testName }); @@ -138,7 +138,7 @@ export default async function run({ github, context, core }) { const existingIssue = existing.find(i => i.title === title); if (existingIssue) { - core.info(`Issue already exists for "${testName}" in ${normalizedJobName}: #${existingIssue.number}`); + core.info(`Issue already exists for "${normalizedTestName}" in ${normalizedJobName}: #${existingIssue.number}`); continue; } @@ -149,7 +149,7 @@ export default async function run({ github, context, core }) { body: issueBody.trim(), labels: ['Tests', 'Bug', 'Flaky Test'], }); - core.info(`Created issue #${newIssue.data.number} for "${testName}" in ${normalizedJobName}`); + core.info(`Created issue #${newIssue.data.number} for "${normalizedTestName}" in ${normalizedJobName}`); } } }