Skip to content

Commit 97d01f9

Browse files
nicohrubecclaude
andauthored
ci: Dedup flaky test issues across esm/cjs variants (#21595)
Our node integration tests all run for both esm and cjs, resulting in duplicate flaky test issues for both variants. This normalizes the test name so these are correctly deduped. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e07a8e3 commit 97d01f9

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

scripts/report-ci-failures.mjs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ function normalizeJobName(name) {
3434
.trim();
3535
}
3636

37+
/**
38+
* Collapse esm/cjs variants of a test name so the same test failing in both module formats dedupes
39+
* to a single issue instead of one per variant:
40+
*
41+
* "... > esm/cjs > esm > should send messages" -> "... > esm/cjs > should send messages"
42+
* "... > esm/cjs > cjs > should send messages" -> "... > esm/cjs > should send messages"
43+
*/
44+
function normalizeTestName(name) {
45+
return name
46+
.replace(/esm\/cjs\s*>\s*(?:esm|cjs)\b/gi, 'esm/cjs')
47+
.replace(/\s+/g, ' ')
48+
.trim();
49+
}
50+
3751
function applyVars(text, vars) {
3852
let result = text;
3953
for (const [key, value] of Object.entries(vars)) {
@@ -108,9 +122,12 @@ export default async function run({ github, context, core }) {
108122

109123
// Create one issue per failing test for proper deduplication
110124
for (const testName of testNames) {
111-
// The title is keyed on the *normalized* job name so the same test failing across matrix
112-
// variants (different node / TS versions) dedupes to a single issue.
113-
const title = applyVars(titleTemplate, { JOB_NAME: normalizedJobName, TEST_NAME: testName });
125+
const normalizedTestName = normalizeTestName(testName);
126+
127+
// The title is keyed on the *normalized* job name + test name so the same test failing across
128+
// matrix variants (different node / TS versions) or module formats (esm / cjs) dedupes to a
129+
// single issue.
130+
const title = applyVars(titleTemplate, { JOB_NAME: normalizedJobName, TEST_NAME: normalizedTestName });
114131
// The body keeps the concrete job name + run link of the variant that actually failed.
115132
const issueBody = applyVars(bodyTemplate, { JOB_NAME: jobName, RUN_LINK: jobUrl, TEST_NAME: testName });
116133

@@ -121,7 +138,7 @@ export default async function run({ github, context, core }) {
121138

122139
const existingIssue = existing.find(i => i.title === title);
123140
if (existingIssue) {
124-
core.info(`Issue already exists for "${testName}" in ${normalizedJobName}: #${existingIssue.number}`);
141+
core.info(`Issue already exists for "${normalizedTestName}" in ${normalizedJobName}: #${existingIssue.number}`);
125142
continue;
126143
}
127144

@@ -132,7 +149,7 @@ export default async function run({ github, context, core }) {
132149
body: issueBody.trim(),
133150
labels: ['Tests', 'Flaky Test'],
134151
});
135-
core.info(`Created issue #${newIssue.data.number} for "${testName}" in ${normalizedJobName}`);
152+
core.info(`Created issue #${newIssue.data.number} for "${normalizedTestName}" in ${normalizedJobName}`);
136153
}
137154
}
138155
}

0 commit comments

Comments
 (0)