coverage-shards.ts 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /** Coverage shard definitions for the GitHub Actions source-test lanes. */
  2. /** A coverage lane that owns complete package roots and optional cross-package tests. */
  3. export interface CoverageShard {
  4. /** Stable lane identifier passed through `DSH_COVERAGE_SHARD`. */
  5. name: string
  6. /** Group or package paths below `packages/` whose tests and source coverage belong to the lane. */
  7. packageRoots: readonly string[]
  8. /** Additional test roots needed for cross-package behavior or repository scripts. */
  9. extraTestRoots?: readonly string[]
  10. }
  11. /** Exhaustive, non-overlapping ownership of workspace packages in coverage CI. */
  12. export const coverageShards = [
  13. {
  14. name: 'core',
  15. packageRoots: ['core', 'context'],
  16. extraTestRoots: ['packages/examples/cli-demo/tests'],
  17. },
  18. { name: 'models-protocol', packageRoots: ['llm', 'compact', 'hooks/hook-protocol'] },
  19. { name: 'sdk-codex', packageRoots: ['sdk', 'hooks/hooks-codex'] },
  20. {
  21. name: 'interfaces',
  22. packageRoots: ['ui', 'examples', 'goal'],
  23. extraTestRoots: ['examples'],
  24. },
  25. { name: 'execution', packageRoots: ['fs', 'bash', 'sandbox', 'code-runtime'] },
  26. {
  27. name: 'workflow',
  28. packageRoots: ['workflow/workflow', 'workflow/tool-workflow', 'workflow/tool-ralph'],
  29. },
  30. { name: 'workflow-worker', packageRoots: ['workflow/workflow-workerthread'] },
  31. { name: 'delegation', packageRoots: ['subagent', 'tasks'] },
  32. {
  33. name: 'repository',
  34. packageRoots: [
  35. 'cordis',
  36. 'support/acp-snapshot',
  37. 'support/agent-loop-testkit',
  38. 'support/llm-replay',
  39. 'support/loader-smoke',
  40. ],
  41. },
  42. {
  43. name: 'session-scripts',
  44. packageRoots: ['session-persistence', 'session-query', 'support/invariants'],
  45. extraTestRoots: ['scripts'],
  46. },
  47. { name: 'integrations-claude', packageRoots: ['lsp', 'mcp', 'hooks/hooks-claude'] },
  48. {
  49. name: 'capabilities',
  50. packageRoots: ['web', 'skill', 'spill', 'util', 'guard', 'todo', 'timeout'],
  51. },
  52. ] as const satisfies readonly CoverageShard[]
  53. /**
  54. * Build Vitest filters and coverage include globs for one source-test lane.
  55. *
  56. * @param name Stable shard name from {@link coverageShards}.
  57. * @returns Positional test roots followed by per-group coverage include flags.
  58. */
  59. export function coverageArgs(name: string): string[] {
  60. const shard = coverageShards.find(candidate => candidate.name === name)
  61. if (shard === undefined) {
  62. throw new Error(`run-gates: unknown DSH_COVERAGE_SHARD ${JSON.stringify(name)}.`)
  63. }
  64. const testRoots = new Set([
  65. ...shard.packageRoots.map(packageRoot => `packages/${packageRoot}`),
  66. ...('extraTestRoots' in shard ? shard.extraTestRoots : []),
  67. 'scripts/test-invariants.spec.ts',
  68. ])
  69. return [
  70. ...testRoots,
  71. ...shard.packageRoots.map(packageRoot => packageRoot.includes('/')
  72. ? `--coverage.include=packages/${packageRoot}/src/**/*.ts`
  73. : `--coverage.include=packages/${packageRoot}/*/src/**/*.ts`),
  74. ]
  75. }