patchrelay 0.51.0 → 0.51.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/build-info.json
CHANGED
|
@@ -2,6 +2,13 @@ import { resolveMergeQueueProtocol } from "./merge-queue-protocol.js";
|
|
|
2
2
|
import { buildMainRepairBranchName, buildMainRepairDescription, buildMainRepairPromptContext, buildMainRepairTitle, isMainRepairIssue, } from "./main-repair.js";
|
|
3
3
|
import { execCommand } from "./utils.js";
|
|
4
4
|
const MAIN_BRANCH_HEALTH_GRACE_MS = 120_000;
|
|
5
|
+
function isUnhealthyMainConclusion(conclusion) {
|
|
6
|
+
return conclusion === "failure"
|
|
7
|
+
|| conclusion === "timed_out"
|
|
8
|
+
|| conclusion === "cancelled"
|
|
9
|
+
|| conclusion === "action_required"
|
|
10
|
+
|| conclusion === "stale";
|
|
11
|
+
}
|
|
5
12
|
export class MainBranchHealthMonitor {
|
|
6
13
|
db;
|
|
7
14
|
config;
|
|
@@ -36,17 +43,20 @@ export class MainBranchHealthMonitor {
|
|
|
36
43
|
&& issue.factoryState !== "done"
|
|
37
44
|
&& issue.factoryState !== "failed"
|
|
38
45
|
&& issue.factoryState !== "escalated"));
|
|
46
|
+
const summary = await this.readMainBranchFailure(project.github.repoFullName, baseBranch);
|
|
47
|
+
if (!summary) {
|
|
48
|
+
if (existing) {
|
|
49
|
+
this.resolveRecoveredMainRepair(existing);
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const protocol = resolveMergeQueueProtocol(project);
|
|
39
54
|
if (existing) {
|
|
40
55
|
const age = Date.now() - Date.parse(existing.updatedAt);
|
|
41
56
|
if (age < MAIN_BRANCH_HEALTH_GRACE_MS) {
|
|
42
57
|
return;
|
|
43
58
|
}
|
|
44
59
|
}
|
|
45
|
-
const summary = await this.readMainBranchFailure(project.github.repoFullName, baseBranch);
|
|
46
|
-
if (!summary) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const protocol = resolveMergeQueueProtocol(project);
|
|
50
60
|
if (existing) {
|
|
51
61
|
this.queueExistingMainRepair(existing, summary, protocol.priorityLabel);
|
|
52
62
|
return;
|
|
@@ -128,6 +138,29 @@ export class MainBranchHealthMonitor {
|
|
|
128
138
|
this.enqueueIssue(issue.projectId, issue.linearIssueId);
|
|
129
139
|
}
|
|
130
140
|
}
|
|
141
|
+
resolveRecoveredMainRepair(issue) {
|
|
142
|
+
if (issue.activeRunId !== undefined)
|
|
143
|
+
return;
|
|
144
|
+
if (issue.prState === "open" || issue.factoryState === "awaiting_queue" || issue.factoryState === "pr_open") {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
this.db.issueSessions.clearPendingIssueSessionEventsRespectingActiveLease(issue.projectId, issue.linearIssueId);
|
|
148
|
+
this.db.upsertIssue({
|
|
149
|
+
projectId: issue.projectId,
|
|
150
|
+
linearIssueId: issue.linearIssueId,
|
|
151
|
+
factoryState: "done",
|
|
152
|
+
pendingRunType: null,
|
|
153
|
+
});
|
|
154
|
+
this.feed?.publish({
|
|
155
|
+
level: "info",
|
|
156
|
+
kind: "github",
|
|
157
|
+
issueKey: issue.issueKey,
|
|
158
|
+
projectId: issue.projectId,
|
|
159
|
+
stage: "done",
|
|
160
|
+
status: "main_repair_resolved",
|
|
161
|
+
summary: "Closed stale main_repair after main recovered externally",
|
|
162
|
+
});
|
|
163
|
+
}
|
|
131
164
|
async readMainBranchFailure(repoFullName, baseBranch) {
|
|
132
165
|
const { stdout: shaOut } = await execCommand("gh", [
|
|
133
166
|
"api",
|
|
@@ -146,7 +179,7 @@ export class MainBranchHealthMonitor {
|
|
|
146
179
|
], { timeoutMs: 10_000 });
|
|
147
180
|
const runs = JSON.parse(checksOut || "[]");
|
|
148
181
|
const failingChecks = runs
|
|
149
|
-
.filter((run) => run.status === "completed" && run.conclusion
|
|
182
|
+
.filter((run) => run.status === "completed" && isUnhealthyMainConclusion(run.conclusion) && typeof run.name === "string" && run.name.trim())
|
|
150
183
|
.map((run) => ({ name: run.name.trim(), ...(run.details_url ? { url: run.details_url } : {}) }));
|
|
151
184
|
if (failingChecks.length === 0) {
|
|
152
185
|
return undefined;
|