mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-16 13:03:31 +08:00
The repository now has a measurable PR quality path instead of a loose set of manual checks. Coverage, quarantine governance, provider smoke, desktop smoke, and workflow wiring all produce durable reports that contributors and maintainers can inspect without reconstructing terminal output. This also fixes the desktop smoke current-runtime path so browser-driven smoke runs use the desktop default active provider instead of forcing the official current model, and records that runtime decision as an artifact. Constraint: Default PR gates must remain non-live and contributor-safe while live model checks stay explicit. Constraint: Release packaging is still GitHub Actions based, so release preflight must run before the build matrix. Rejected: Make live provider or desktop smoke mandatory on every PR | secrets, quotas, and model availability are maintainer-controlled. Rejected: Let PRs lower coverage baselines in the same change | base-branch ratchet comparison must remain authoritative. Confidence: high Scope-risk: moderate Directive: Do not relax coverage or quarantine policy without a maintainer approval label and a fresh quality report. Tested: ALLOW_CLI_CORE_CHANGE=1 ALLOW_COVERAGE_BASELINE_CHANGE=1 bun run quality:gate --mode pr Tested: bun run quality:gate --mode baseline --allow-live --only provider-smoke:* --provider-model nvidia-custom:main:nvidia-custom-main --artifacts-dir /tmp/quality-gate-live-smoke Tested: bun run quality:gate --mode baseline --allow-live --only desktop-smoke:* --provider-model current:current:current-runtime --artifacts-dir /tmp/quality-gate-desktop-smoke-fixed Tested: git diff --check Not-tested: Full live release mode with multiple providers in hosted CI; provider credentials and quota remain maintainer-controlled.
40 lines
1.6 KiB
TypeScript
40 lines
1.6 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
const DOSU_PROMPT = '@dosubot review this PR for changed-area risk, missing tests, docs impact, desktop startup risk, and CLI core impact.'
|
|
|
|
function extractCommentBodyEntries(workflow: string) {
|
|
const match = workflow.match(/const body = \[([\s\S]*?)\n\s*\]\.join\('\\n'\)/)
|
|
if (!match) {
|
|
throw new Error('Could not find PR triage comment body array')
|
|
}
|
|
|
|
return match[1]
|
|
.split('\n')
|
|
.map((line) => line.trim())
|
|
.filter((line) => line.startsWith("'") || line.startsWith('`'))
|
|
}
|
|
|
|
describe('PR triage workflow comment', () => {
|
|
test('ends with a plain-text Dosu mention so the bot is triggered', () => {
|
|
const workflow = readFileSync('.github/workflows/pr-triage.yml', 'utf8')
|
|
const entries = extractCommentBodyEntries(workflow)
|
|
const nonEmptyEntries = entries.filter((entry) => !/^['`]['`],?$/.test(entry))
|
|
const lastEntry = nonEmptyEntries.at(-1)
|
|
|
|
expect(lastEntry).toBe(`'${DOSU_PROMPT}',`)
|
|
expect(workflow).not.toContain(`\`${DOSU_PROMPT}\``)
|
|
})
|
|
|
|
test('surfaces missing-test, coverage-check, and coverage-baseline policy branches', () => {
|
|
const workflow = readFileSync('.github/workflows/pr-triage.yml', 'utf8')
|
|
|
|
expect(workflow).toContain("'allow-missing-tests': 'c2e0c6'")
|
|
expect(workflow).toContain("'allow-coverage-baseline-change': 'c2e0c6'")
|
|
expect(workflow).toContain("requiredChecks.push('coverage-checks')")
|
|
expect(workflow).toContain('Coverage baseline policy')
|
|
expect(workflow).toContain('coveragePolicyFiles')
|
|
expect(workflow).toContain('BLOCKING unless \\`allow-missing-tests\\` is applied')
|
|
})
|
|
})
|