ci: show in annotations if a failing or flaky file is new (#21882)

from https://buildkite.com/bun/bun/builds/23050

<img width="917" height="278" alt="image"
src="https://github.com/user-attachments/assets/d2ee9362-603d-4a48-aa98-c0a498a8846d"
/>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Meghan Denny
2025-08-15 09:40:55 -08:00
committed by GitHub
parent 9fd5b20aa3
commit b7ec589a26

View File

@@ -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 += "</li>\n";