ci: split remaining one-minute lanes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { defineAcpSnapshotSuite, type Scenario, type SnapshotSuiteOptions } from '@deepseek-ai/dsh-acp-snapshot'
|
||||
import { snapshotScenarioShardFromEnv } from './snapshot-scenario-shard.ts'
|
||||
|
||||
/**
|
||||
* The acp-agent example's snapshot suite: the scenario table for
|
||||
@@ -191,9 +192,12 @@ const SCENARIOS: Scenario[] = [
|
||||
{ name: 'fs-escalation-approved', hasModelTurn: true, recorded: true, headerClass: 'sandbox' },
|
||||
]
|
||||
|
||||
const scenarioShard = snapshotScenarioShardFromEnv(process.env.DSH_SNAPSHOT_SCENARIO_SHARD)
|
||||
|
||||
defineAcpSnapshotSuite({
|
||||
agent: AGENT,
|
||||
snapshotsDir: join(dirname(fileURLToPath(import.meta.url)), 'snapshots'),
|
||||
scenarios: SCENARIOS,
|
||||
mode: snapshotModeFromEnv(process.env.DSH_SNAPSHOT),
|
||||
...scenarioShard === undefined ? {} : { scenarioShard },
|
||||
})
|
||||
|
||||
20
examples/acp-agent/tests/snapshot-scenario-shard.spec.ts
Normal file
20
examples/acp-agent/tests/snapshot-scenario-shard.spec.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { snapshotScenarioShardFromEnv } from './snapshot-scenario-shard.ts'
|
||||
|
||||
describe('ACP snapshot scenario shard environment', () => {
|
||||
it('keeps ordinary snapshot runs complete', () => {
|
||||
expect(snapshotScenarioShardFromEnv()).toBeUndefined()
|
||||
expect(snapshotScenarioShardFromEnv('')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('parses a valid one-based shard', () => {
|
||||
expect(snapshotScenarioShardFromEnv('2/4')).toEqual({ index: 2, total: 4 })
|
||||
})
|
||||
|
||||
it.each(['0/1', '1/0', '2/1', '1.5/2', 'missing', '999999999999999999999/999999999999999999999'])(
|
||||
'rejects %s',
|
||||
(value) => {
|
||||
expect(() => snapshotScenarioShardFromEnv(value)).toThrow('DSH_SNAPSHOT_SCENARIO_SHARD')
|
||||
},
|
||||
)
|
||||
})
|
||||
18
examples/acp-agent/tests/snapshot-scenario-shard.ts
Normal file
18
examples/acp-agent/tests/snapshot-scenario-shard.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { SnapshotScenarioShard } from '@deepseek-ai/dsh-acp-snapshot'
|
||||
|
||||
/**
|
||||
* Parse the optional CI scenario shard passed to this snapshot suite.
|
||||
*
|
||||
* @param value An `INDEX/TOTAL` string or an unset value.
|
||||
* @returns A validated one-based shard, or undefined for the complete suite.
|
||||
*/
|
||||
export function snapshotScenarioShardFromEnv(value?: string): SnapshotScenarioShard | undefined {
|
||||
if (value === undefined || value === '') return undefined
|
||||
const match = /^([1-9]\d*)\/([1-9]\d*)$/.exec(value)
|
||||
if (match === null) throw new Error(`DSH_SNAPSHOT_SCENARIO_SHARD must be INDEX/TOTAL, got ${JSON.stringify(value)}`)
|
||||
const shard = { index: Number(match[1]), total: Number(match[2]) }
|
||||
if (!Number.isSafeInteger(shard.index) || !Number.isSafeInteger(shard.total) || shard.index > shard.total) {
|
||||
throw new Error(`DSH_SNAPSHOT_SCENARIO_SHARD is out of range: ${JSON.stringify(value)}`)
|
||||
}
|
||||
return shard
|
||||
}
|
||||
Reference in New Issue
Block a user