From b7ec589a265d6dfff7202fddd9744e7bdfcb42f5 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Fri, 15 Aug 2025 09:40:55 -0800 Subject: [PATCH] ci: show in annotations if a failing or flaky file is new (#21882) from https://buildkite.com/bun/bun/builds/23050 image --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- scripts/runner.node.mjs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/scripts/runner.node.mjs b/scripts/runner.node.mjs index b37bc9f2d4..cd016a7420 100755 --- a/scripts/runner.node.mjs +++ b/scripts/runner.node.mjs @@ -182,6 +182,35 @@ if (options["quiet"]) { isQuiet = true; } +let newFiles = []; +let prFileCount = 0; +if (isBuildkite) { + try { + console.log("on buildkite: collecting new files from PR"); + for (let i = 1; i <= 5; i++) { + const res = await fetch( + `https://api.github.com/repos/oven-sh/bun/pulls/${process.env.BUILDKITE_PULL_REQUEST}/files?per_page=50&page=${i}`, + { + headers: { + Authorization: `Bearer ${getSecret("GITHUB_TOKEN")}`, + }, + }, + ); + const doc = await res.json(); + console.log(`-> page ${i}, found ${doc.length} items`); + if (doc.length === 0) break; + for (const { filename, status } of doc) { + prFileCount += 1; + if (status !== "added") continue; + newFiles.push(filename); + } + } + console.log(`- PR ${process.env.BUILDKITE_PULL_REQUEST}, ${prFileCount} files, ${newFiles.length} new files`); + } catch (e) { + console.error(e); + } +} + let coresDir; if (options["coredump-upload"]) { @@ -1986,6 +2015,9 @@ function formatTestToMarkdown(result, concise, retries) { if (retries > 0) { markdown += ` (${retries} ${retries === 1 ? "retry" : "retries"})`; } + if (newFiles.includes(testTitle)) { + markdown += ` (new)`; + } if (concise) { markdown += "\n";