mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-08-29 04:26:38 +00:00
fix(ci): preserve oxlint diagnostic locations
This commit is contained in:
@@ -16,6 +16,18 @@ describe('Oxlint invocation', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('uses location-preserving diagnostics in CI', () => {
|
||||
expect(resolveOxlintInvocation(['.'], { CI: 'true', DSH_OXLINT_THREADS: '4' })).toEqual({
|
||||
args: ['.', '--format=unix', '--threads=4'],
|
||||
env: { CI: 'true', DSH_OXLINT_THREADS: '4', GOMAXPROCS: '4' },
|
||||
})
|
||||
})
|
||||
|
||||
it('preserves an explicitly selected CI formatter', () => {
|
||||
expect(resolveOxlintInvocation(['.', '--format', 'github'], { CI: 'true' }).args)
|
||||
.toEqual(['.', '--format', 'github'])
|
||||
})
|
||||
|
||||
it.each(['0', '-1', '1.5', 'auto'])('rejects invalid worker bound %s', (value) => {
|
||||
expect(() => resolveOxlintInvocation(['.'], { DSH_OXLINT_THREADS: value }))
|
||||
.toThrow('DSH_OXLINT_THREADS must be a positive integer')
|
||||
|
||||
+12
-2
@@ -10,6 +10,14 @@ function isFixInvocation(args: readonly string[]): boolean {
|
||||
return args.some(arg => FIX_FLAGS.has(arg))
|
||||
}
|
||||
|
||||
function hasOutputFormat(args: readonly string[]): boolean {
|
||||
return args.some(arg =>
|
||||
arg === '-f'
|
||||
|| arg.startsWith('-f=')
|
||||
|| arg === '--format'
|
||||
|| arg.startsWith('--format='))
|
||||
}
|
||||
|
||||
/** Complete Oxlint child-process arguments and environment. */
|
||||
export interface OxlintInvocation {
|
||||
readonly args: readonly string[]
|
||||
@@ -23,8 +31,10 @@ export interface OxlintInvocation {
|
||||
* @returns the complete CLI arguments and child environment.
|
||||
*/
|
||||
export function resolveOxlintInvocation(args: readonly string[], env: NodeJS.ProcessEnv): OxlintInvocation {
|
||||
const resolvedArgs = [...args]
|
||||
if (env.CI === 'true' && !hasOutputFormat(args)) resolvedArgs.push('--format=unix')
|
||||
const raw = env.DSH_OXLINT_THREADS
|
||||
if (raw === undefined || raw === '') return { args: [...args], env: { ...env } }
|
||||
if (raw === undefined || raw === '') return { args: resolvedArgs, env: { ...env } }
|
||||
const parsed = Number.parseInt(raw, 10)
|
||||
if (!Number.isSafeInteger(parsed) || parsed < 1 || String(parsed) !== raw) {
|
||||
throw new Error(`run-oxlint: DSH_OXLINT_THREADS must be a positive integer, got ${JSON.stringify(raw)}.`)
|
||||
@@ -33,7 +43,7 @@ export function resolveOxlintInvocation(args: readonly string[], env: NodeJS.Pro
|
||||
throw new Error('run-oxlint: use DSH_OXLINT_THREADS instead of passing --threads directly.')
|
||||
}
|
||||
return {
|
||||
args: [...args, `--threads=${raw}`],
|
||||
args: [...resolvedArgs, `--threads=${raw}`],
|
||||
env: { ...env, GOMAXPROCS: raw },
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user