also looking at this
fix: report skipped gates as skipped, and honour ai.majorUpgrades.maxAttempts
#1433
9 files
+257
-8
| @@ -9,6 +9,14 @@ export interface GateResult { | ||
| 9 | 9 | /** `error` blocks the merge under branch protection; `warning` does not */ |
| 10 | 10 | mode: GateMode |
| 11 | 11 | passed: boolean |
| 12 | /** | |
| 13 | * The gate did not run — no AI configured, nothing to check against, the | |
| 14 | * assessment failed. Distinct from `passed`, which it used to be folded | |
| 15 | * into: a gate that could not run was rendered with the same green tick as | |
| 16 | * one that ran and found nothing, and a check run made of nothing but | |
| 17 | * skipped gates reported "All checks passed". | |
| 18 | */ | |
| 19 | neutral?: boolean | |
| 12 | 20 | /** What failed, or what passed */ |
| 13 | 21 | summary: string |
| 14 | 22 | /** Extra explanation shown under the summary */ |
| @@ -199,17 +207,31 @@ export function summarizeGates(results: GateResult[]): { | ||
| 199 | 207 | |
| 200 | 208 | const blocking = results.filter(result => !result.passed && result.mode === 'error') |
| 201 | 209 | const warnings = results.filter(result => !result.passed && result.mode === 'warning') |
| 210 | const skipped = results.filter(result => result.neutral) | |
| 202 | 211 | |
| 203 | 212 | const lines = results.map((result) => { |
| 204 | const icon = result.passed ? '✅' : result.mode === 'error' ? '❌' : '⚠️' | |
| 213 | const icon = gateIcon(result) | |
| 205 | 214 | return `${icon} **${result.name}** — ${result.summary}${result.detail ? `\n\n${result.detail}\n` : ''}` |
| 206 | 215 | }) |
| 207 | 216 | |
| 217 | // Every gate skipped is not a pass. It is the "no checks configured" case | |
| 218 | // arrived at a different way, and gets the same conclusion. | |
| 219 | if (skipped.length === results.length) { | |
| 220 | return { | |
| 221 | conclusion: 'neutral', | |
| 222 | title: `${skipped.length} check(s) did not run`, | |
| 223 | summary: lines.join('\n\n'), | |
| 224 | } | |
| 225 | } | |
| 226 | ||
| 227 | const ran = results.length - skipped.length | |
| 208 | 228 | const title = blocking.length > 0 |
| 209 | 229 | ? `${blocking.length} check(s) failed` |
| 210 | 230 | : warnings.length > 0 |
| 211 | 231 | ? `${warnings.length} warning(s)` |
| 212 | : 'All checks passed' | |
| 232 | : skipped.length > 0 | |
| 233 | ? `${ran} check(s) passed, ${skipped.length} did not run` | |
| 234 | : 'All checks passed' | |
| 213 | 235 | |
| 214 | 236 | return { |
| 215 | 237 | conclusion: blocking.length > 0 ? 'failure' : 'success', |
| @@ -218,6 +240,20 @@ export function summarizeGates(results: GateResult[]): { | ||
| 218 | 240 | } |
| 219 | 241 | } |
| 220 | 242 | |
| 243 | /** | |
| 244 | * The icon a gate result renders with. | |
| 245 | * | |
| 246 | * Shared with the CLI so a skipped gate looks the same in a terminal as in | |
| 247 | * the check run. | |
| 248 | * | |
| 249 | * @param result - A gate result | |
| 250 | */ | |
| 251 | export function gateIcon(result: GateResult): string { | |
| 252 | if (result.neutral) | |
| 253 | return '⏭️' | |
| 254 | return result.passed ? '✅' : result.mode === 'error' ? '❌' : '⚠️' | |
| 255 | } | |
| 256 | ||
| 221 | 257 | function escapeRegExp(value: string): string { |
| 222 | 258 | return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') |
| 223 | 259 | } |