Skip to content

Commit 0995e8a

Browse files
author
meorphis
committed
gen fallback
1 parent bf271d9 commit 0995e8a

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

dist/internalPreview.js

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/internalPreview.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Stainless } from "@stainless-api/sdk";
12
import type { Target } from "@stainless-api/sdk/resources/shared";
23
import { execFileSync } from "child_process";
34
import { commentThrottler, printInternalComment } from "./comment";
@@ -183,6 +184,8 @@ async function main() {
183184

184185
const projectStates = targetGroups.map((group) => ({
185186
group,
187+
headBuildId: null as string | null,
188+
baseBuildId: null as string | null,
186189
outcomes: null as Outcomes | null,
187190
baseOutcomes: null as Outcomes | null,
188191
// Keyed by lang. Populated once on first encounter of merge_conflict so
@@ -237,6 +240,8 @@ async function main() {
237240
for (let i = 0; i < compareResults.length; i++) {
238241
const { base, head } = compareResults[i];
239242
const projectName = targetGroups[i].project;
243+
projectStates[i].headBuildId = head.id;
244+
projectStates[i].baseBuildId = base.id;
240245
pollIterators.push({
241246
iterator: pollBuild({
242247
stainless,
@@ -311,6 +316,29 @@ async function main() {
311316
continue;
312317
}
313318

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+
314342
if (head.commit?.conclusion === "merge_conflict") {
315343
// Don't determine diff until base has also concluded so its
316344
// codegen branch is in its final state before we compare.

0 commit comments

Comments
 (0)