also looking at this
fix(ci): give the repair loop the guard it already had
#1407
10 files
+229
-34
| @@ -1,9 +1,7 @@ | ||
| 1 | 1 | import type { GitProvider } from '../git/provider' |
| 2 | 2 | import type { BuddyConfig } from '../types' |
| 3 | 3 | import type { CommandContext, CommandHandler, CommandOutcome } from './dispatcher' |
| 4 | import process from 'node:process' | |
| 5 | 4 | import { createAiClient } from '../ai' |
| 6 | import { attemptFix } from '../ci/fix' | |
| 7 | 5 | |
| 8 | 6 | /** Everything the built-in handlers need to act. */ |
| 9 | 7 | export interface HandlerDeps { |
| @@ -90,16 +88,17 @@ export function createHandlers(deps: HandlerDeps): Record<string, CommandHandler | ||
| 90 | 88 | }, |
| 91 | 89 | |
| 92 | 90 | async 'fix-ci'(context): Promise<CommandOutcome> { |
| 93 | const ai = createAiClient(deps.config, context.logger) | |
| 94 | const outcome = await attemptFix({ | |
| 95 | log: '', | |
| 96 | workspace: process.cwd(), | |
| 97 | baseBranch: deps.config.repository?.baseBranch ?? 'main', | |
| 98 | ai, | |
| 99 | logger: context.logger, | |
| 100 | }) | |
| 101 | ||
| 102 | return { handled: true, reply: outcome.report } | |
| 91 | // This handler has no run to read. Diagnosis is entirely a function of | |
| 92 | // the failing job's log, so calling attemptFix with an empty one only | |
| 93 | // ever produced a confident-looking `unknown` classification with no | |
| 94 | // evidence behind it. Saying so is more useful than that. | |
| 95 | return { | |
| 96 | handled: false, | |
| 97 | reply: 'I diagnose a failure from its job log, and a comment does not tell me which run failed. ' | |
| 98 | + 'Buddy repairs failing checks automatically when the `fix-ci` job is enabled in your workflow — ' | |
| 99 | + 'it runs on the failed run itself and reports back here. ' | |
| 100 | + 'See https://buddy.sh/features/ci-repair', | |
| 101 | } | |
| 103 | 102 | }, |
| 104 | 103 | |
| 105 | 104 | async remember(context): Promise<CommandOutcome> { |