ci: skip running tests when a PR only changes docs (#24459)

fixes https://linear.app/oven/issue/ENG-21489
This commit is contained in:
Meghan Denny
2025-11-07 15:52:37 -08:00
committed by GitHub
parent 1896c75d78
commit d0a1984a20
2 changed files with 58 additions and 10 deletions

View File

@@ -185,32 +185,33 @@ if (options["quiet"]) {
isQuiet = true;
}
/** @type {string[]} */
let allFiles = [];
/** @type {string[]} */
let newFiles = [];
let prFileCount = 0;
if (isBuildkite) {
try {
console.log("on buildkite: collecting new files from PR");
const per_page = 50;
for (let i = 1; i <= 5; i++) {
const { BUILDKITE_PULL_REQUEST } = process.env;
for (let i = 1; i <= 10; i++) {
const res = await fetch(
`https://api.github.com/repos/oven-sh/bun/pulls/${process.env.BUILDKITE_PULL_REQUEST}/files?per_page=${per_page}&page=${i}`,
{
headers: {
Authorization: `Bearer ${getSecret("GITHUB_TOKEN")}`,
},
},
`https://api.github.com/repos/oven-sh/bun/pulls/${BUILDKITE_PULL_REQUEST}/files?per_page=${per_page}&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;
allFiles.push(filename);
if (status !== "added") continue;
newFiles.push(filename);
}
if (doc.length < per_page) break;
}
console.log(`- PR ${process.env.BUILDKITE_PULL_REQUEST}, ${prFileCount} files, ${newFiles.length} new files`);
console.log(`- PR ${BUILDKITE_PULL_REQUEST}, ${prFileCount} files, ${newFiles.length} new files`);
} catch (e) {
console.error(e);
}
@@ -2615,8 +2616,18 @@ export async function main() {
]);
}
const results = await runTests();
const ok = results.every(({ ok }) => ok);
let doRunTests = true;
if (isCI) {
if (allFiles.every(filename => filename.startsWith("docs/"))) {
doRunTests = false;
}
}
let ok = true;
if (doRunTests) {
const results = await runTests();
ok = results.every(({ ok }) => ok);
}
let waitForUser = false;
while (isCI) {