Split TypeScript tests into three chunks per Node.js version on Linux and five on Windows, balanced by recorded Jest durations, and start the Windows chunks while their pnpr fixtures build. Skip Jest coverage in CI, which nothing reads. Keep Rust sources from widening the TypeScript test scope. Cache Rust compiler output with sccache on Linux and macOS, because rust-cache prunes every dependency of this workspace, and run Rust coverage on 8 vCPUs with its own compiler cache. Save at most one cache entry per scope and day. Build the pnpr fixtures without fat LTO, at opt-level 1, on every push to main and on 16 vCPUs for Windows. Avoid obsolete PR work, full-history benchmark build checkouts and test-only network backoff. Keep all platforms, Node.js versions, merge-queue validation, production retry defaults, and the release and benchmark build profiles.
33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
import { readFileSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
|
|
// Measured TS test durations for this platform, refreshed with
|
|
// update-ts-test-durations.mjs, or undefined when none were recorded.
|
|
export function readTestDurations (platform = process.platform) {
|
|
const durations = JSON.parse(readFileSync(path.join(import.meta.dirname, 'ts-test-durations.json'), 'utf8'))
|
|
return durations[platform === 'win32' ? 'windows' : 'linux']
|
|
}
|
|
|
|
// Expected seconds for one task. Without measurements every task falls back
|
|
// to its file size, so the weights stay comparable within one run.
|
|
export function taskWeight ({ id, size }, durations) {
|
|
if (durations == null) return Math.max(1, size ?? 1)
|
|
return durations.files[id] ?? durations.fallbackSeconds
|
|
}
|
|
|
|
export function selectChunk (tasks, { chunk, chunks }) {
|
|
const groups = Array.from({ length: chunks }, () => ({ tasks: [], weight: 0 }))
|
|
for (const task of [...tasks].sort(compareTasksByWeight)) {
|
|
const group = groups.reduce((best, candidate) => (
|
|
candidate.weight < best.weight ? candidate : best
|
|
))
|
|
group.tasks.push(task)
|
|
group.weight += task.weight
|
|
}
|
|
return groups[chunk - 1].tasks.sort((a, b) => a.id.localeCompare(b.id))
|
|
}
|
|
|
|
function compareTasksByWeight (a, b) {
|
|
return b.weight - a.weight || a.id.localeCompare(b.id)
|
|
}
|