Skip to content

fix: exclude PR-modified tests from the flaky count - #1171

Open
zeexzeex wants to merge 1 commit into
nodejs:mainfrom
zeexzeex:fix/exclude-pr-modified-tests
Open

zeexzeex wants to merge 1 commit into
nodejs:mainfrom
zeexzeex:fix/exclude-pr-modified-tests

Conversation

@zeexzeex

Copy link
Copy Markdown

What

A failure in a test that the pull request itself modified is counted as an independent flaky occurrence, which overstates the number of affected pull requests.

Taking the example from the issue, ffi/test-ffi-fast-buffer is listed with two failed PRs in the 2026-08-15 report:

PR Files changed
#65233 src/ffi/fast.cc, test/ffi/test-ffi-fast-buffer.js
#65113 lib/fs.js, unrelated fs tests

Only #65113 is a genuine occurrence.

How

Compare the failing test against the files the pull request touched, and drop the occurrence when they match. formatAsMarkdown already skips entries with fewer than two PRs, so such an entry leaves the report on its own.

When the file list cannot be fetched the occurrence is kept, following lib/benchmark.js: incomplete information should never remove a genuine failure.

This makes aggregate() async. Both call sites in bin/ncu-ci.js were already async methods. The lazy fallbacks inside formatAsMarkdown() and display() now throw instead, since a pending promise there would fail silently.

Tests

Four tests cover the exclusion, the untouched case, the fetch failure, and non-test failures. Removing the exclusion makes only the first fail, while the other three keep passing.

Fixes: #1164

A failure in a test that the pull request itself modified is likely
caused by that change, so counting it as an independent flaky occurrence
overstates the number of affected pull requests.

Compare the failing test against the files the pull request touched and
drop the occurrence when they match. When the file list cannot be
fetched the occurrence is kept, so incomplete information never removes
a genuine failure.

Fixes: nodejs#1164
Signed-off-by: Avocado <ujubongbong@gmail.com>
@zeexzeex
zeexzeex force-pushed the fix/exclude-pr-modified-tests branch from 00626ea to 1a93536 Compare September 8, 2026 07:13
const selfInflicted = await Promise.all(
candidates.map(failure => this.isSelfInflicted(failure)));
const prs = candidates
.filter((_, index) => !selfInflicted[index])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can leave prs empty, but display() still reads prs[prs.length - 1].upstream.

return false;
}

const path = `test/${file}.js`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node's test runner strips both .js and .mjs extensions from the reported name. For example, test/parallel/test-cli-print-promise.mjs is reported as parallel/test-cli-print-promise, so this always looks for the wrong file and keeps the occurrence in the flaky count.


const path = `test/${file}.js`;
try {
for await (const changed of this.request.getPullRequestFiles(pr)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fetches the current PR's changed files, which may differ from the revision CI tested. If a contributor pushes a fix to the failing test after the run, the earlier failure gets excluded even though the tested revision never touched that file. That can reduce the count from two PRs to one and remove the reliability entry. Compare against the tested revision, or keep the occurrence when we cannot verify that the current PR head matches it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ncu-ci walk: exclude PR-modified tests from the flaky count

2 participants