refactor: centralize Oxlint worker bounds

This commit is contained in:
Tianyi Cui
2026-07-29 23:39:49 +08:00
parent f7ee0bf0fd
commit e673524976
6 changed files with 83 additions and 30 deletions

View File

@@ -377,24 +377,10 @@ function ciWindowsObservationalGates(): Gate[] {
}
function lintGate(): Gate {
const threadBound = oxlintThreadBound()
if (threadBound !== undefined) {
return pnpmExec('lint', ['oxlint', '.', `--threads=${threadBound}`], {
label: 'lint',
env: { GOMAXPROCS: threadBound },
})
}
return pnpmScript('lint', 'lint')
}
function oxlintThreadBound(): string | undefined {
const raw = process.env.DSH_OXLINT_THREADS
if (raw === undefined || raw === '') return undefined
const parsed = Number.parseInt(raw, 10)
if (!Number.isSafeInteger(parsed) || parsed < 1 || String(parsed) !== raw) {
throw new Error(`run-gates: DSH_OXLINT_THREADS must be a positive integer, got ${JSON.stringify(raw)}.`)
}
return raw
return pnpmScript('lint', 'lint', raw === undefined || raw === ''
? {}
: { displayCommand: `DSH_OXLINT_THREADS=${raw} pnpm run lint` })
}
function coverageGate(): Gate {