also looking at this
fix: report skipped gates as skipped, and honour ai.majorUpgrades.maxAttempts
#1433
9 files
+257
-8
| @@ -9,6 +9,7 @@ import { | ||
| 9 | 9 | isMergeEvent, |
| 10 | 10 | runAiGates, |
| 11 | 11 | runPostMerge, |
| 12 | summarizeGates, | |
| 12 | 13 | } from '../src/gates' |
| 13 | 14 | import { |
| 14 | 15 | clearQuickSelection, |
| @@ -486,3 +487,50 @@ describe('EOL feeds the dependency gate', () => { | ||
| 486 | 487 | expect(checkDependencies([{ name: 'node', version: '22' }], { mode: 'error' }).passed).toBe(true) |
| 487 | 488 | }) |
| 488 | 489 | }) |
| 490 | ||
| 491 | /** | |
| 492 | * `neutral()` in the assertion gates returned `passed: true`, and `GateResult` | |
| 493 | * had no other state — so a gate that could not run was rendered with the same | |
| 494 | * green tick as one that ran and found nothing, and a check run made of | |
| 495 | * nothing but skipped gates was titled "All checks passed". | |
| 496 | */ | |
| 497 | describe('neutral gate results', () => { | |
| 498 | const passed = { name: 'deps', mode: 'error' as const, passed: true, summary: 'fine' } | |
| 499 | const skipped = { name: 'linked-issue', mode: 'warning' as const, passed: true, neutral: true, summary: 'No AI provider configured' } | |
| 500 | const failed = { name: 'size', mode: 'error' as const, passed: false, summary: 'too big' } | |
| 501 | ||
| 502 | it('failure case - all gates skipped is not "all checks passed"', () => { | |
| 503 | const summary = summarizeGates([skipped]) | |
| 504 | ||
| 505 | expect(summary.conclusion).toBe('neutral') | |
| 506 | expect(summary.title).toContain('did not run') | |
| 507 | expect(summary.title).not.toContain('passed') | |
| 508 | }) | |
| 509 | ||
| 510 | it('success case - a skipped gate beside a real pass is counted apart', () => { | |
| 511 | const summary = summarizeGates([passed, skipped]) | |
| 512 | ||
| 513 | expect(summary.conclusion).toBe('success') | |
| 514 | expect(summary.title).toBe('1 check(s) passed, 1 did not run') | |
| 515 | }) | |
| 516 | ||
| 517 | it('success case - a skipped gate renders as skipped, not as a tick', () => { | |
| 518 | const { summary } = summarizeGates([passed, skipped]) | |
| 519 | ||
| 520 | expect(summary).toContain('⏭️ **linked-issue**') | |
| 521 | expect(summary).toContain('✅ **deps**') | |
| 522 | }) | |
| 523 | ||
| 524 | it('failure case - a skipped gate never blocks', () => { | |
| 525 | expect(summarizeGates([skipped, failed]).conclusion).toBe('failure') | |
| 526 | expect(summarizeGates([skipped, passed]).conclusion).toBe('success') | |
| 527 | }) | |
| 528 | ||
| 529 | it('success case - a gate that could not run is flagged neutral', async () => { | |
| 530 | // No AI is the commonest reason. It says so rather than passing. | |
| 531 | const result = await checkLinkedIssue(null, { diff: 'x', linkedIssues: [{ number: 1, title: 't', body: 'b' }] } as never, 'error') | |
| 532 | ||
| 533 | expect(result.neutral).toBe(true) | |
| 534 | expect(result.passed).toBe(true) | |
| 535 | }) | |
| 536 | }) | |