ReviewOS

also looking at this

stacks/buddy

fix(gates): actually refresh the dashboard instead of reporting that it did

#1425
Merged glennmichael123 wants to merge fix/post-merge-gates into main
3 files +86 -3
src/gates/post-merge.tsmodified+31-3
Changes to src/gates/post-merge.ts
@@ -82,7 +82,19 @@ export async function runPostMerge(
8282 provider: GitProvider,
8383 pr: PullRequest,
8484 config: PostMergeConfig = {},
85 options: { baseBranch?: string, logger?: Logger } = {},
85 options: {
86 baseBranch?: string
87 logger?: Logger
88 /**
89 * Refresh the dependency dashboard.
90 *
91 * A hook rather than something this module does, because refreshing means
92 * a full scan and this file only knows about a provider. Absent means the
93 * caller cannot refresh, which is reported as a skip rather than passed
94 * off as done.
95 */
96 refreshDashboard?: () => Promise<void>
97 } = {},
8698): Promise<PostMergeOutcome> {
8799 const logger = options.logger ?? getDefaultLogger()
88100 const baseBranch = options.baseBranch ?? pr.base ?? 'main'
@@ -138,8 +150,24 @@ export async function runPostMerge(
138150 }
139151 }
140152
141 if (config.refreshDashboard)
142 performed.push('refresh-dashboard')
153 if (config.refreshDashboard) {
154 // This branch used to push `refresh-dashboard` onto `performed` and do
155 // nothing at all — the one action here that reported success without
156 // having any work behind it.
157 if (!options.refreshDashboard) {
158 skipped.push({ action: 'refresh-dashboard', reason: 'no dashboard refresher was supplied' })
159 }
160 else {
161 try {
162 await options.refreshDashboard()
163 performed.push('refresh-dashboard')
164 }
165 catch (error) {
166 logger.warn(`⚠️ Could not refresh the dashboard: ${error}`)
167 skipped.push({ action: 'refresh-dashboard', reason: 'refresh failed' })
168 }
169 }
170 }
143171
144172 return { performed, skipped }
145173}