|
| 1 | +import type { Stainless } from "@stainless-api/sdk"; |
1 | 2 | import type { Target } from "@stainless-api/sdk/resources/shared"; |
2 | 3 | import { execFileSync } from "child_process"; |
3 | 4 | import { commentThrottler, printInternalComment } from "./comment"; |
@@ -183,6 +184,8 @@ async function main() { |
183 | 184 |
|
184 | 185 | const projectStates = targetGroups.map((group) => ({ |
185 | 186 | group, |
| 187 | + headBuildId: null as string | null, |
| 188 | + baseBuildId: null as string | null, |
186 | 189 | outcomes: null as Outcomes | null, |
187 | 190 | baseOutcomes: null as Outcomes | null, |
188 | 191 | // Keyed by lang. Populated once on first encounter of merge_conflict so |
@@ -237,6 +240,8 @@ async function main() { |
237 | 240 | for (let i = 0; i < compareResults.length; i++) { |
238 | 241 | const { base, head } = compareResults[i]; |
239 | 242 | const projectName = targetGroups[i].project; |
| 243 | + projectStates[i].headBuildId = head.id; |
| 244 | + projectStates[i].baseBuildId = base.id; |
240 | 245 | pollIterators.push({ |
241 | 246 | iterator: pollBuild({ |
242 | 247 | stainless, |
@@ -311,6 +316,29 @@ async function main() { |
311 | 316 | continue; |
312 | 317 | } |
313 | 318 |
|
| 319 | + // When a build concludes with merge_conflict the API doesn't |
| 320 | + // return checks on the build target. Fetch them from the |
| 321 | + // generated-checks endpoint instead. |
| 322 | + for (const { outcome, buildId } of [ |
| 323 | + { outcome: head, buildId: state.headBuildId }, |
| 324 | + { outcome: base, buildId: state.baseBuildId }, |
| 325 | + ] as const) { |
| 326 | + if ( |
| 327 | + outcome.commit?.conclusion === "merge_conflict" && |
| 328 | + buildId && |
| 329 | + !outcome.build && |
| 330 | + !outcome.lint && |
| 331 | + !outcome.test |
| 332 | + ) { |
| 333 | + const generatedChecks = await stainless.get< |
| 334 | + Record<"lint" | "test" | "build", Stainless.Builds.CheckStep> |
| 335 | + >(`/api/builds/${buildId}/language/${lang}/generated-checks`); |
| 336 | + outcome.build = generatedChecks.build; |
| 337 | + outcome.lint = generatedChecks.lint; |
| 338 | + outcome.test = generatedChecks.test; |
| 339 | + } |
| 340 | + } |
| 341 | + |
314 | 342 | if (head.commit?.conclusion === "merge_conflict") { |
315 | 343 | // Don't determine diff until base has also concluded so its |
316 | 344 | // codegen branch is in its final state before we compare. |
|
0 commit comments