Merge pull request #2035 from PR0M3TH3AN/ai/ci-health-20241028-10335292326695405989

chore(ai): CI health fixes (flaky tests)
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-02-01 08:01:04 -05:00
commit 31d1775d90
4 files changed
+31 -10

No files matched your search

+21 -6
View File
@@ -11,8 +11,11 @@ const rootDir = path.dirname(fileURLToPath(new URL("../package.json", import.met
const testsDir = path.join(rootDir, "tests");
const testFiles = [];
const setupImport = new URL("../tests/test-helpers/setup-localstorage.mjs", import.meta.url);
const shardArg = process.argv.find((arg) => arg.startsWith("--shard="));
const args = process.argv.slice(2);
const shardArg = args.find((arg) => arg.startsWith("--shard="));
const shardValue = shardArg ? shardArg.split("=")[1] : process.env.UNIT_TEST_SHARD;
const filters = args.filter((arg) => !arg.startsWith("--"));
const timeoutMs = process.env.UNIT_TEST_TIMEOUT_MS
? Number(process.env.UNIT_TEST_TIMEOUT_MS)
: null;
@@ -89,19 +92,31 @@ async function run() {
return;
}
const shard = parseShard(shardValue);
const selectedTests = shard
? testFiles.filter((_, index) => index % shard.total === shard.index - 1)
: testFiles;
let selectedTests = testFiles;
if (filters.length > 0) {
selectedTests = selectedTests.filter((file) =>
filters.some((f) => file.includes(f)),
);
if (selectedTests.length === 0) {
console.log(`No tests matched filters: ${filters.join(", ")}`);
return;
}
console.log(`Filtered to ${selectedTests.length} test(s).`);
}
const shard = parseShard(shardValue);
if (shard) {
selectedTests = selectedTests.filter(
(_, index) => index % shard.total === shard.index - 1,
);
console.log(
`Using shard ${shard.index}/${shard.total} (${selectedTests.length} of ${testFiles.length} files).`,
);
}
if (selectedTests.length === 0) {
console.log("No unit tests found for this shard.");
console.log("No unit tests found for this shard/filter.");
return;
}