Skip to content

Commit 34bb1d0

Browse files
committed
fix(gitlab): wake watchers when the parent pipeline passes
1 parent 01a93e7 commit 34bb1d0

3 files changed

Lines changed: 57 additions & 44 deletions

File tree

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

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,55 +1015,64 @@ layer("GitLabPullRequestCli.layer", (it) => {
10151015
}),
10161016
);
10171017

1018-
it.effect("shows a failed child pipeline that left the head pipeline green", () =>
1019-
Effect.gen(function* () {
1020-
mockedExecute
1021-
.mockReturnValueOnce(
1022-
Effect.succeed(
1023-
output(
1024-
mergeRequestJson({
1025-
// A fork's pipeline runs in the source project, so its id is not the target's.
1026-
head_pipeline: {
1027-
id: 31,
1028-
project_id: 12,
1029-
status: "success",
1030-
web_url: "https://gitlab.com/bilal/web/-/pipelines/31",
1031-
},
1032-
}),
1018+
it.effect.each(["running", "failed"] as const)(
1019+
"keeps a %s child pipeline advisory when the head pipeline is green",
1020+
(childStatus) =>
1021+
Effect.gen(function* () {
1022+
mockedExecute
1023+
.mockReturnValueOnce(
1024+
Effect.succeed(
1025+
output(
1026+
mergeRequestJson({
1027+
// A fork's pipeline runs in the source project, so its id is not the target's.
1028+
head_pipeline: {
1029+
id: 31,
1030+
project_id: 12,
1031+
status: "success",
1032+
web_url: "https://gitlab.com/bilal/web/-/pipelines/31",
1033+
},
1034+
}),
1035+
),
10331036
),
1034-
),
1035-
)
1036-
.mockReturnValueOnce(
1037-
Effect.succeed(
1038-
output(
1039-
JSON.stringify([
1040-
{
1041-
name: "deploy",
1042-
status: "success",
1043-
downstream_pipeline: {
1044-
status: "failed",
1045-
web_url: "https://gitlab.com/bilal/web/-/pipelines/32",
1037+
)
1038+
.mockReturnValueOnce(
1039+
Effect.succeed(
1040+
output(
1041+
JSON.stringify([
1042+
{
1043+
name: "deploy",
1044+
status: "success",
1045+
downstream_pipeline: {
1046+
status: childStatus,
1047+
web_url: "https://gitlab.com/bilal/web/-/pipelines/32",
1048+
},
10461049
},
1047-
},
1048-
{ name: "docs", status: "created", downstream_pipeline: null },
1049-
]),
1050+
{ name: "docs", status: "created", downstream_pipeline: null },
1051+
]),
1052+
),
10501053
),
1051-
),
1052-
);
1053-
const cli = yield* GitLabPullRequestCli.GitLabPullRequestCli;
1054+
);
1055+
const cli = yield* GitLabPullRequestCli.GitLabPullRequestCli;
10541056

1055-
const detail = yield* cli.getMergeRequestDetail({
1056-
cwd: "/w",
1057-
repository: "acme/web",
1058-
number: 7,
1059-
});
1057+
const detail = yield* cli.getMergeRequestDetail({
1058+
cwd: "/w",
1059+
repository: "acme/web",
1060+
number: 7,
1061+
});
10601062

1061-
expect(detail.checks.map((check) => [check.name, check.status, check.url])).toEqual([
1062-
["Pipeline", "success", "https://gitlab.com/bilal/web/-/pipelines/31"],
1063-
["deploy", "failure", "https://gitlab.com/bilal/web/-/pipelines/32"],
1064-
]);
1065-
expect(argsOfCall(1)[1]).toBe("projects/12/pipelines/31/bridges?per_page=100");
1066-
}),
1063+
expect(
1064+
detail.checks.map((check) => [check.name, check.status, check.url, check.required]),
1065+
).toEqual([
1066+
["Pipeline", "success", "https://gitlab.com/bilal/web/-/pipelines/31", true],
1067+
[
1068+
"deploy",
1069+
childStatus === "running" ? "pending" : "failure",
1070+
"https://gitlab.com/bilal/web/-/pipelines/32",
1071+
false,
1072+
],
1073+
]);
1074+
expect(argsOfCall(1)[1]).toBe("projects/12/pipelines/31/bridges?per_page=100");
1075+
}),
10671076
);
10681077

10691078
it.effect("keeps the one pipeline check when the trigger jobs cannot be read whole", () =>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ describe("decodeMergeRequestDetailJson", () => {
143143
{
144144
name: "Pipeline",
145145
status: "success",
146+
required: true,
146147
description: "merge_request_event",
147148
url: "https://gitlab.com/acme/web/-/pipelines/9",
148149
},

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ function toChecks(
283283
{
284284
name: "Pipeline",
285285
status: toPipelineStatus(pipeline.status),
286+
// GitLab folds gating downstream pipelines into the head pipeline's status.
287+
required: true,
286288
description: trimmed(pipeline.source),
287289
url: trimmed(pipeline.web_url),
288290
},
@@ -442,6 +444,7 @@ export function decodeTriggerJobChecksJson(
442444
status: status === "failure" && job.value.allow_failure === true ? "neutral" : status,
443445
description: "Downstream pipeline",
444446
url: trimmed(downstream.web_url),
447+
required: false,
445448
});
446449
}
447450
return Result.succeed({ checks, rawCount: decoded.success.length });

0 commit comments

Comments
 (0)