Files
orca/config/scripts/test-runtime/execution-policy/vitest-runtime-sequencer.mjs
Neil 9bd6272fdf refactor(tooling): organize build, CI, and test owners (#38130)
* refactor(tooling): organize test runtime and maintenance owners

* test(tooling): preserve relocated runtime fixture dependency edges

* refactor(tooling): preserve xterm routing owner checks

* ci(tooling): include routing owner in sparse checkout

* test(tooling): preserve copied workflow dependency closures

* fix(tooling): normalize hashed JSON assets in release parity

* fix(tooling): distinguish asset aliases from literal references

* fix(tooling): frame normalized asset reference payloads

* fix(tooling): normalize decoded JSON asset references

* refactor(tooling): organize build, CI and release owners

* fix(tooling): align moved generator and workflow path contracts

* fix(tooling): update generated plugin bundle owner banners

* test(tooling): create relocated mobile verifier fixture directories

* test(tooling): copy headless detector dependency closure

* test(tooling): align native batch policy fixtures with owner path

* fix(tooling): link moved reliability command to historical evidence

* fix(tooling): preserve nested sandbox owners and canonical guide source

* fix(tooling): target release version owners in checkout fixture
2026-11-04 21:08:19 -08:00

32 lines
1.3 KiB
JavaScript

import { relative } from 'node:path'
import { BaseSequencer } from 'vitest/node'
import { rankFilesByDuration, readTimingBaseline } from '../../ci/sharding/ci-shard-assignment.mjs'
export default class RuntimeSequencer extends BaseSequencer {
constructor(ctx, timingBaseline = undefined) {
super(ctx)
this.timingBaseline = timingBaseline
}
async sort(specifications) {
const inherited = await super.sort(specifications)
if (new Set(inherited.map((spec) => spec.project.name)).size < 2) {
return inherited
}
// Start long contracts across both runtimes instead of leaving Node until the end.
const baseline = this.timingBaseline ?? readTimingBaseline('unit')
const key = (spec) => relative(this.ctx.config.root, spec.moduleId).replaceAll('\\', '/')
const { weighted } = rankFilesByDuration(
[...new Set(inherited.map(key))],
baseline.timings,
baseline.overheadMs
)
const ranks = new Map(weighted.map(({ file }, index) => [file, index]))
return inherited.sort((a, b) => {
const groupOrder = a.project.config.sequence.groupOrder - b.project.config.sequence.groupOrder
const isolationOrder = Number(b.project.config.isolate) - Number(a.project.config.isolate)
return groupOrder || isolationOrder || ranks.get(key(a)) - ranks.get(key(b))
})
}
}