Skip to content

Commit 3648557

Browse files
fix(forgejo): finished statuses no longer keep a pull request watch pending
Forgejo reports a job that did not run as `skipped` and a non-passing finished job as `warning`. The adapter mapped both to pending, so a gated deploy job kept a pull request watch open forever. Map skipped to skipped, warning to neutral, and leave only pending and unknown states pending, as the GitLab adapter already does. Replaces the per-state resolver test and the already-passing watch assertion with one provider-level test through getChangeRequestChecks. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 05a8ba8 commit 3648557

4 files changed

Lines changed: 64 additions & 49 deletions

File tree

‎apps/server/src/orchestration-v2/pullRequestWatch.test.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,6 @@ describe("evaluatePullRequestWatch", () => {
9696
assert.deepEqual(evaluatePullRequestWatch(watch(), plain, noRemarks).changes, []);
9797
});
9898

99-
it("reports passed when a check was skipped and the rest succeeded", () => {
100-
const green = detail({ checks: [check("checks", "success"), check("deploy", "skipped")] });
101-
assert.deepEqual(evaluatePullRequestWatch(watch(), green, noRemarks).changes, [
102-
{ kind: "checks-passed", count: 2, required: false },
103-
]);
104-
});
105-
10699
it("reports passed again when a required check shows up already passed", () => {
107100
const required = (name: string, status: PullRequestCheck["status"]) => ({
108101
...check(name, status),

‎packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,67 @@ it.effect("reads the newest Forgejo checks without repository or viewer requests
164164
);
165165
});
166166

167+
it.effect("reads Forgejo jobs that did not run as finished checks", () =>
168+
Effect.gen(function* () {
169+
const provider = yield* ForgejoPullRequestProvider.make;
170+
const read = provider.getChangeRequestChecks;
171+
if (read === undefined) return yield* Effect.die("checks read missing");
172+
const result = yield* read({
173+
cwd: "/repo",
174+
repository: "acme/web",
175+
host: "forgejo.test",
176+
number: 1,
177+
});
178+
assert.deepStrictEqual(
179+
result.checks.map((check) => [check.name, check.status]),
180+
[
181+
["deploy", "skipped"],
182+
["audit", "neutral"],
183+
["docs", "pending"],
184+
],
185+
);
186+
}).pipe(
187+
Effect.provide(
188+
Layer.mock(ForgejoCli.ForgejoCli)({
189+
api: (input) => {
190+
const status = (context: string, state: string) => ({
191+
context,
192+
status: state,
193+
description: null,
194+
target_url: null,
195+
updated_at: "2026-10-11T00:00:00Z",
196+
});
197+
const body = input.path.endsWith("pulls/1")
198+
? {
199+
number: 1,
200+
title: "Checks",
201+
body: "",
202+
html_url: "https://forgejo.test/acme/web/pulls/1",
203+
user: null,
204+
state: "open",
205+
merged: false,
206+
head: { ref: "feature", sha: "head", repo: null },
207+
base: { ref: "main", sha: "base", repo: null },
208+
created_at: "2026-10-11T00:00:00Z",
209+
updated_at: "2026-10-11T00:00:00Z",
210+
closed_at: null,
211+
merged_at: null,
212+
labels: [],
213+
}
214+
: input.path.endsWith("page=1")
215+
? [
216+
status("deploy", "skipped"),
217+
status("audit", "warning"),
218+
status("docs", "future-state"),
219+
]
220+
: [];
221+
return encodeJsonEffect(body).pipe(Effect.orDie, Effect.map(processOutput));
222+
},
223+
}),
224+
),
225+
),
226+
);
227+
167228
it.effect("opens Forgejo Actions check links on the pull request's server", () =>
168229
Effect.gen(function* () {
169230
const provider = yield* ForgejoPullRequestProvider.make;

‎packages/source-control-forgejo/src/server/forgejoPullRequestJson.test.ts‎

Lines changed: 0 additions & 40 deletions
This file was deleted.

‎packages/source-control-forgejo/src/server/forgejoPullRequestJson.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,9 @@ export function forgejoCommit(commit: typeof ForgejoCommit.Type): PullRequestCom
213213
};
214214
}
215215

216-
// Forgejo's commit status states; Actions reports a job that did not run as `skipped` and a
217-
// cancelled job as `failure`. A skipped job is done, so it must not hold back "checks passed".
216+
// Forgejo Actions reports a job that did not run as `skipped` and a cancelled one as `failure`,
217+
// and `warning` is finished without being a pass. Only `pending` and states we do not know may
218+
// hold a watch open.
218219
function forgejoCheckStatus(state: string): PullRequestCheckStatus {
219220
switch (state) {
220221
case "success":

0 commit comments

Comments
 (0)