GitNexus/gitnexus/scripts/shard-timings.ts
Gergő Magyar 13d06d41c4
feat(ci): rebalance test shards from recorded timings (#3748)
* feat(ci): rebalance test shards from recorded timings

* fix(ci): preserve artifact retries for shard timings

Find shard-plan generation by its stable step ID and clarify the native runner cohort count (#3748).

Note: pre-existing reference-oracle parser type failures in two test_oracle_assets cases remain outside this change.

* fix(ci): keep retry timing snapshots immutable

Require the existing snapshot on reruns so a failed download cannot refresh history and change shard assignments. Cover the workflow contract and document recovery when the artifact is unavailable.

* docs(ci): document shard timing profile selection

* fix(ci): balance cold shard estimates consistently

---------

Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
2026-10-28 11:58:29 +00:00

16 lines
725 B
TypeScript

import path from 'node:path';
/** Separate native costs from coverage and from the other operating system. */
export function shardTimingsFile(): string {
const profile = process.env.GITNEXUS_SHARD_PROFILE ?? 'coverage';
if (!['coverage', 'windows-latest', 'macos-latest'].includes(profile)) {
throw new Error(`Unknown shard timing profile: ${profile}`);
}
return `.vitest/timings/${profile}.json`;
}
/** Matches vitest-shard-balancer's project-qualified timing identity. */
export function shardTimingKey(root: string, moduleId: string, projectName: string): string {
const relative = path.relative(root, moduleId).split(path.sep).join('/');
return projectName ? `${projectName}:${relative}` : relative;
}