mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-16 13:03:31 +08:00
Pull requests need a deterministic way to show changed areas, required checks, missing-test signals, and CLI-core risk before review. This adds a path-based policy gate, local impact reporting, PR triage labels/comments, and reusable check scripts so reviewers can evaluate blast radius without trusting contributor claims. Constraint: CLI core should remain effectively frozen unless a maintainer explicitly overrides it. Constraint: Default PR checks must be safe for external forks and avoid live model/provider calls. Rejected: Run live provider tests on every PR | secrets, cost, network, and vendor instability would make the gate noisy and unsafe. Rejected: Use Dosu as the merge gate | AI review is useful for risk explanation, but deterministic Actions must own blocking checks. Confidence: high Scope-risk: moderate Directive: Keep real model/provider smoke tests in maintainer-controlled workflows; do not make them required for untrusted PRs. Tested: bun run check:impact Tested: bun run check:policy Tested: ruby YAML parse for PR workflows Tested: git diff --check Tested: bun run check:native Tested: npm run docs:build Tested: bun run scripts/pr/run-server-tests.ts Tested: bun run check:adapters Tested: bun run check:desktop Not-tested: GitHub-hosted pull_request_target label/comment execution before opening this PR
63 lines
2.0 KiB
TypeScript
63 lines
2.0 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
import { evaluateChangePolicy } from './change-policy'
|
|
|
|
describe('evaluateChangePolicy', () => {
|
|
test('blocks CLI core changes without an override label', () => {
|
|
const result = evaluateChangePolicy([
|
|
'src/commands/help.ts',
|
|
'desktop/src/pages/Settings.tsx',
|
|
])
|
|
|
|
expect(result.blocked).toBe(true)
|
|
expect(result.areas).toContain('cli-core')
|
|
expect(result.areas).toContain('desktop')
|
|
expect(result.areaLabels).toContain('area:cli-core')
|
|
expect(result.areaLabels).toContain('area:desktop')
|
|
expect(result.cliCoreFiles).toEqual(['src/commands/help.ts'])
|
|
})
|
|
|
|
test('allows CLI core changes with a maintainer override label', () => {
|
|
const result = evaluateChangePolicy(
|
|
['src/tools/WebSearchTool/backend.ts'],
|
|
['allow-cli-core-change'],
|
|
)
|
|
|
|
expect(result.blocked).toBe(false)
|
|
expect(result.areas).toEqual(['cli-core'])
|
|
expect(result.checks.server).toBe(true)
|
|
})
|
|
|
|
test('keeps docs-only changes on the docs lane', () => {
|
|
const result = evaluateChangePolicy([
|
|
'docs/index.md',
|
|
'README.md',
|
|
])
|
|
|
|
expect(result.blocked).toBe(false)
|
|
expect(result.areas).toEqual(['docs'])
|
|
expect(result.checks.docs).toBe(true)
|
|
expect(result.checks.desktop).toBe(false)
|
|
expect(result.checks.desktopNative).toBe(false)
|
|
})
|
|
|
|
test('routes desktop and server changes to desktop and native checks', () => {
|
|
const result = evaluateChangePolicy([
|
|
'desktop/src/pages/Settings.tsx',
|
|
'src/server/ws/handler.ts',
|
|
])
|
|
|
|
expect(result.areas).toEqual(['desktop', 'server'])
|
|
expect(result.checks.desktop).toBe(true)
|
|
expect(result.checks.server).toBe(true)
|
|
expect(result.checks.desktopNative).toBe(true)
|
|
})
|
|
|
|
test('routes adapter changes to adapter and native checks', () => {
|
|
const result = evaluateChangePolicy(['adapters/telegram/index.ts'])
|
|
|
|
expect(result.areas).toEqual(['adapters'])
|
|
expect(result.checks.adapters).toBe(true)
|
|
expect(result.checks.desktopNative).toBe(true)
|
|
})
|
|
})
|