also looking at this
feat(events): one notification story — fire every declared event, trim setup to its real job
#1449
14 files
+308
-81
| @@ -18,6 +18,7 @@ import { | ||
| 18 | 18 | parseDashboardActions, |
| 19 | 19 | uncheckDashboardActions, |
| 20 | 20 | } from '../src/dashboard/dashboard-actions' |
| 21 | import { emitEvent } from '../src/events' | |
| 21 | 22 | import { manifestUpdates, parseManifest } from '../src/pr/pr-manifest' |
| 22 | 23 | import { |
| 23 | 24 | analyzeProject, |
| @@ -404,7 +405,12 @@ cli | ||
| 404 | 405 | } |
| 405 | 406 | } |
| 406 | 407 | else if (availablePlugins.length > 0 && options.nonInteractive) { |
| 407 | console.log(`\n🔌 Found ${availablePlugins.length} integration(s), skipping in non-interactive mode`) | |
| 408 | // The docs promise setup-completion notifications; silently skipping | |
| 409 | // them made that a lie in exactly the mode CI uses. | |
| 410 | console.log(`\n🔌 Found ${availablePlugins.length} integration(s) — enabled for setup notifications`) | |
| 411 | for (const plugin of availablePlugins) { | |
| 412 | await pluginManager.loadPlugin(plugin) | |
| 413 | } | |
| 408 | 414 | } |
| 409 | 415 | |
| 410 | 416 | // Pre-flight checks |
| @@ -780,6 +786,7 @@ cli | ||
| 780 | 786 | } |
| 781 | 787 | catch (error) { |
| 782 | 788 | logger.error('Scan failed:', error) |
| 789 | await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'run.failed', { command: 'scan', error: error instanceof Error ? error.message : String(error) }) | |
| 783 | 790 | process.exit(1) |
| 784 | 791 | } |
| 785 | 792 | }) |
| @@ -840,6 +847,7 @@ cli | ||
| 840 | 847 | } |
| 841 | 848 | catch (error) { |
| 842 | 849 | logger.error('Dashboard creation failed:', error) |
| 850 | await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'run.failed', { command: 'dashboard', error: error instanceof Error ? error.message : String(error) }) | |
| 843 | 851 | process.exit(1) |
| 844 | 852 | } |
| 845 | 853 | }) |
| @@ -924,6 +932,7 @@ cli | ||
| 924 | 932 | } |
| 925 | 933 | catch (error) { |
| 926 | 934 | logger.error('Update failed:', error) |
| 935 | await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'run.failed', { command: 'update', error: error instanceof Error ? error.message : String(error) }) | |
| 927 | 936 | process.exit(1) |
| 928 | 937 | } |
| 929 | 938 | }) |
| @@ -1329,6 +1338,7 @@ cli | ||
| 1329 | 1338 | } |
| 1330 | 1339 | catch (error) { |
| 1331 | 1340 | logger.error('update-check failed:', error) |
| 1341 | await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'run.failed', { command: 'update-check', error: error instanceof Error ? error.message : String(error) }) | |
| 1332 | 1342 | process.exit(1) |
| 1333 | 1343 | } |
| 1334 | 1344 | }) |
| @@ -1400,6 +1410,7 @@ cli | ||
| 1400 | 1410 | } |
| 1401 | 1411 | catch (error) { |
| 1402 | 1412 | logger.error('fix-ci failed:', error) |
| 1413 | await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'run.failed', { command: 'fix-ci', error: error instanceof Error ? error.message : String(error) }) | |
| 1403 | 1414 | process.exit(1) |
| 1404 | 1415 | } |
| 1405 | 1416 | }) |
| @@ -1656,6 +1667,10 @@ cli | ||
| 1656 | 1667 | }) |
| 1657 | 1668 | |
| 1658 | 1669 | logger.success(`✅ ${status}`) |
| 1670 | await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'review.completed', { | |
| 1671 | number: Number.parseInt(prNumber, 10), | |
| 1672 | findings: result?.findings.length ?? 0, | |
| 1673 | }) | |
| 1659 | 1674 | |
| 1660 | 1675 | // `--format` and `--fail-on` were accepted on this path and applied |
| 1661 | 1676 | // only on the local one, so a pull request review could not be |
| @@ -1759,6 +1774,7 @@ cli | ||
| 1759 | 1774 | } |
| 1760 | 1775 | catch (error) { |
| 1761 | 1776 | logger.error('Review failed:', error) |
| 1777 | await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'run.failed', { command: 'review', error: error instanceof Error ? error.message : String(error) }) | |
| 1762 | 1778 | process.exit(1) |
| 1763 | 1779 | } |
| 1764 | 1780 | }) |
| @@ -3164,6 +3180,12 @@ cli | ||
| 3164 | 3180 | logger.info(`${gateIcon(result)} ${result.name}: ${result.summary}`) |
| 3165 | 3181 | |
| 3166 | 3182 | const blocking = summary.conclusion === 'failure' |
| 3183 | if (blocking) { | |
| 3184 | await emitEvent(config.notifications as Parameters<typeof emitEvent>[0], 'gate.failed', { | |
| 3185 | number, | |
| 3186 | checks: results.filter(result => !result.passed).map(result => result.name), | |
| 3187 | }) | |
| 3188 | } | |
| 3167 | 3189 | |
| 3168 | 3190 | if (options.dryRun || !supports(provider, 'checkRuns', 'createCheckRun')) { |
| 3169 | 3191 | logger.info(summary.summary) |