merge-steward 0.10.4 → 0.10.5
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/service-queue.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export declare class MergeStewardQueueCommands {
|
|
|
20
20
|
priority?: number;
|
|
21
21
|
}): QueueEntry | undefined;
|
|
22
22
|
scanStartupAdmissions(): Promise<void>;
|
|
23
|
+
scanEligibleOpenPrs(): Promise<{
|
|
24
|
+
scanned: number;
|
|
25
|
+
admitted: number;
|
|
26
|
+
}>;
|
|
23
27
|
tryAdmit(prNumber: number, branch: string, headSha: string): Promise<boolean>;
|
|
24
28
|
dequeueByPR(prNumber: number): void;
|
|
25
29
|
updateHeadByPR(prNumber: number, headSha: string): void;
|
package/dist/service-queue.js
CHANGED
|
@@ -68,20 +68,24 @@ export class MergeStewardQueueCommands {
|
|
|
68
68
|
async scanStartupAdmissions() {
|
|
69
69
|
this.logger.info({ repoId: this.config.repoId }, "Scanning startup admissions");
|
|
70
70
|
try {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (await this.tryAdmit(pr.number, pr.branch, pr.headSha))
|
|
75
|
-
admitted += 1;
|
|
76
|
-
}
|
|
77
|
-
if (open.length > 0) {
|
|
78
|
-
this.logger.info({ scanned: open.length, admitted }, "Startup scan for eligible open PRs complete");
|
|
71
|
+
const { scanned, admitted } = await this.scanEligibleOpenPrs();
|
|
72
|
+
if (scanned > 0) {
|
|
73
|
+
this.logger.info({ scanned, admitted }, "Startup scan for eligible open PRs complete");
|
|
79
74
|
}
|
|
80
75
|
}
|
|
81
76
|
catch (error) {
|
|
82
77
|
this.logger.warn({ err: error }, "Startup scan for eligible open PRs failed");
|
|
83
78
|
}
|
|
84
79
|
}
|
|
80
|
+
async scanEligibleOpenPrs() {
|
|
81
|
+
const open = await this.github.listOpenPRs();
|
|
82
|
+
let admitted = 0;
|
|
83
|
+
for (const pr of open) {
|
|
84
|
+
if (await this.tryAdmit(pr.number, pr.branch, pr.headSha))
|
|
85
|
+
admitted += 1;
|
|
86
|
+
}
|
|
87
|
+
return { scanned: open.length, admitted };
|
|
88
|
+
}
|
|
85
89
|
async tryAdmit(prNumber, branch, headSha) {
|
|
86
90
|
if (this.config.excludeBranches.some((pattern) => matchGlob(pattern, branch))) {
|
|
87
91
|
this.logger.debug({ prNumber, branch }, "Branch excluded from admission");
|
|
@@ -14,6 +14,7 @@ export declare class MergeStewardRuntime {
|
|
|
14
14
|
private readonly eviction;
|
|
15
15
|
private readonly specBuilder;
|
|
16
16
|
private readonly logger;
|
|
17
|
+
private readonly beforeTick?;
|
|
17
18
|
private tickTimer;
|
|
18
19
|
private tickInProgress;
|
|
19
20
|
private lastTickStartedAt;
|
|
@@ -21,7 +22,7 @@ export declare class MergeStewardRuntime {
|
|
|
21
22
|
private lastTickOutcome;
|
|
22
23
|
private lastTickError;
|
|
23
24
|
private currentQueueBlock;
|
|
24
|
-
constructor(config: StewardConfig, policy: GitHubPolicyCache, store: QueueStore, git: GitOperations, ci: CIRunner, github: GitHubPRApi, eviction: EvictionReporter, specBuilder: SpeculativeBranchBuilder, logger: Logger);
|
|
25
|
+
constructor(config: StewardConfig, policy: GitHubPolicyCache, store: QueueStore, git: GitOperations, ci: CIRunner, github: GitHubPRApi, eviction: EvictionReporter, specBuilder: SpeculativeBranchBuilder, logger: Logger, beforeTick?: (() => Promise<void>) | undefined);
|
|
25
26
|
start(): Promise<void>;
|
|
26
27
|
stop(): Promise<void>;
|
|
27
28
|
triggerReconcile(): Promise<{
|
package/dist/service-runtime.js
CHANGED
|
@@ -9,6 +9,7 @@ export class MergeStewardRuntime {
|
|
|
9
9
|
eviction;
|
|
10
10
|
specBuilder;
|
|
11
11
|
logger;
|
|
12
|
+
beforeTick;
|
|
12
13
|
tickTimer;
|
|
13
14
|
tickInProgress = false;
|
|
14
15
|
lastTickStartedAt = null;
|
|
@@ -16,7 +17,7 @@ export class MergeStewardRuntime {
|
|
|
16
17
|
lastTickOutcome = "idle";
|
|
17
18
|
lastTickError = null;
|
|
18
19
|
currentQueueBlock = null;
|
|
19
|
-
constructor(config, policy, store, git, ci, github, eviction, specBuilder, logger) {
|
|
20
|
+
constructor(config, policy, store, git, ci, github, eviction, specBuilder, logger, beforeTick) {
|
|
20
21
|
this.config = config;
|
|
21
22
|
this.policy = policy;
|
|
22
23
|
this.store = store;
|
|
@@ -26,6 +27,7 @@ export class MergeStewardRuntime {
|
|
|
26
27
|
this.eviction = eviction;
|
|
27
28
|
this.specBuilder = specBuilder;
|
|
28
29
|
this.logger = logger;
|
|
30
|
+
this.beforeTick = beforeTick;
|
|
29
31
|
}
|
|
30
32
|
async start() {
|
|
31
33
|
this.logger.info({ pollIntervalMs: this.config.pollIntervalMs }, "Steward service starting");
|
|
@@ -79,6 +81,7 @@ export class MergeStewardRuntime {
|
|
|
79
81
|
this.lastTickOutcome = "running";
|
|
80
82
|
this.lastTickError = null;
|
|
81
83
|
try {
|
|
84
|
+
await this.beforeTick?.();
|
|
82
85
|
let tickQueueBlockEvent = null;
|
|
83
86
|
await reconcile({
|
|
84
87
|
store: this.store,
|
package/dist/service.js
CHANGED
|
@@ -28,8 +28,10 @@ export class MergeStewardService {
|
|
|
28
28
|
this.eviction = eviction;
|
|
29
29
|
this.specBuilder = specBuilder;
|
|
30
30
|
this.logger = logger;
|
|
31
|
-
this.runtime = new MergeStewardRuntime(config, policy, store, git, ci, github, eviction, specBuilder, logger);
|
|
32
31
|
this.queueCommands = new MergeStewardQueueCommands(config, policy, store, github, specBuilder, logger);
|
|
32
|
+
this.runtime = new MergeStewardRuntime(config, policy, store, git, ci, github, eviction, specBuilder, logger, async () => {
|
|
33
|
+
await this.queueCommands.scanEligibleOpenPrs();
|
|
34
|
+
});
|
|
33
35
|
this.watchQueries = new MergeStewardWatchQueries(config, store, this.runtime);
|
|
34
36
|
}
|
|
35
37
|
/** Expose the GitHub client for webhook handler branch→PR lookups. */
|
|
@@ -116,7 +116,7 @@ export function getDefaultEntryId(snapshot, filter, preferredPrNumber) {
|
|
|
116
116
|
return match.id;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
return snapshot.summary.headEntryId ?? visibleEntries[0]?.id ??
|
|
119
|
+
return snapshot.summary.headEntryId ?? visibleEntries[0]?.id ?? null;
|
|
120
120
|
}
|
|
121
121
|
export function getRepoHealth(repo, now = Date.now()) {
|
|
122
122
|
const snapshot = repo.snapshot;
|