Skip to content

Commit e39247a

Browse files
TonybynMp4claude
andcommitted
fix(gitlab): keep a failed stage whole when its jobs span more than one page
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 0b8109d commit e39247a

2 files changed

Lines changed: 49 additions & 19 deletions

File tree

‎packages/source-control-gitlab/src/server/gitLabMergeRequestJson.test.ts‎

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -349,22 +349,39 @@ describe("decodePipelineStageChecksJson", () => {
349349
]);
350350
});
351351

352-
it("keeps a failed stage whose failed jobs were not listed", () => {
353-
const checks = expectSuccess(
354-
decodePipelineStageChecksJson(
355-
stagesJson([{ name: "test", status: "failed", jobs: { nodes: [] } }]),
356-
"https://gitlab.com",
352+
it("keeps a failed stage whose failed jobs were not all listed", () => {
353+
const stage = {
354+
name: "test",
355+
status: "failure",
356+
description: null,
357+
url: "https://gitlab.com/fork/web/-/pipelines/9",
358+
};
359+
expect(
360+
expectSuccess(
361+
decodePipelineStageChecksJson(
362+
stagesJson([{ name: "test", status: "failed", jobs: { nodes: [] } }]),
363+
"https://gitlab.com",
364+
),
357365
),
358-
);
359-
360-
expect(checks).toEqual([
361-
{
362-
name: "test",
363-
status: "failure",
364-
description: null,
365-
url: "https://gitlab.com/fork/web/-/pipelines/9",
366-
},
367-
]);
366+
).toEqual([stage]);
367+
// More failed jobs could sit past the first page.
368+
expect(
369+
expectSuccess(
370+
decodePipelineStageChecksJson(
371+
stagesJson([
372+
{
373+
name: "test",
374+
status: "failed",
375+
jobs: {
376+
nodes: [{ name: "unit", status: "FAILED", allowFailure: false }],
377+
pageInfo: { hasNextPage: true },
378+
},
379+
},
380+
]),
381+
"https://gitlab.com",
382+
),
383+
),
384+
).toEqual([stage]);
368385
});
369386

370387
it("answers nothing where there are no stages to show", () => {

‎packages/source-control-gitlab/src/server/gitLabMergeRequestJson.ts‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,10 @@ export const PIPELINE_STAGES_GRAPHQL_QUERY = `query($fullPath: ID!, $iid: String
299299
name
300300
status
301301
detailedStatus { label detailsPath }
302-
jobs(first: 100) { nodes { name status allowFailure webPath } }
302+
jobs(first: 100) {
303+
nodes { name status allowFailure webPath }
304+
pageInfo { hasNextPage }
305+
}
303306
}
304307
pageInfo { hasNextPage }
305308
}
@@ -324,7 +327,16 @@ const RawStageSchema = Schema.Struct({
324327
Schema.NullOr(Schema.Struct({ label: OptionalString, detailsPath: OptionalString })),
325328
),
326329
jobs: Schema.optional(
327-
Schema.NullOr(Schema.Struct({ nodes: Schema.Array(Schema.NullOr(RawStageJobSchema)) })),
330+
Schema.NullOr(
331+
Schema.Struct({
332+
nodes: Schema.Array(Schema.NullOr(RawStageJobSchema)),
333+
pageInfo: Schema.optional(
334+
Schema.NullOr(
335+
Schema.Struct({ hasNextPage: Schema.optional(Schema.NullOr(Schema.Boolean)) }),
336+
),
337+
),
338+
}),
339+
),
328340
),
329341
});
330342

@@ -395,9 +407,10 @@ export function decodePipelineStageChecksJson(
395407
const name = trimmed(stage?.name);
396408
if (stage === null || name === null) continue;
397409
const status = toPipelineStatus(stage.status);
398-
// A job allowed to fail leaves its stage passed with warnings, so it never fails one.
410+
// A job allowed to fail leaves its stage passed with warnings, so it never fails one. A
411+
// stage with more jobs than one page stays whole, since its other failures went unread.
399412
const failedJobs =
400-
status === "failure"
413+
status === "failure" && stage.jobs?.pageInfo?.hasNextPage !== true
401414
? (stage.jobs?.nodes ?? []).flatMap((job) => {
402415
const jobName = trimmed(job?.name);
403416
return job === null ||

0 commit comments

Comments
 (0)