@atolis-hq/wake 0.2.92 → 0.2.93
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/src/core/tick-runner.js +48 -11
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
|
@@ -374,14 +374,12 @@ export function createTickRunner(deps) {
|
|
|
374
374
|
const targetResourceUri = input.approvalResolution.targetResourceUri;
|
|
375
375
|
const commentId = input.approvalResolution.triggeringCommentId.replace(/[^a-z0-9]+/gi, '-');
|
|
376
376
|
const reviewBody = reviewerMessageFromApprovalComment(input.approvalResolution.triggeringCommentBody ?? '');
|
|
377
|
-
//
|
|
378
|
-
//
|
|
379
|
-
//
|
|
380
|
-
//
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
// failing doesn't stop the other from being attempted.
|
|
384
|
-
const blockedReasons = [];
|
|
377
|
+
// approve and autoMerge are independent: one failing doesn't stop the
|
|
378
|
+
// other from being attempted. If autoMerge succeeds, a failed approval is
|
|
379
|
+
// not a policy block on its own; GitHub can reject self-approval while
|
|
380
|
+
// still accepting auto-merge for repos that do not require review.
|
|
381
|
+
const approvalBlockedReasons = [];
|
|
382
|
+
const autoMergeBlockedReasons = [];
|
|
385
383
|
const approvedEventId = `pr-merge-approved-${commentId}`;
|
|
386
384
|
if (input.mergePolicy.approve &&
|
|
387
385
|
(await deps.stateStore.readEventEnvelope(approvedEventId)) === null) {
|
|
@@ -408,10 +406,11 @@ export function createTickRunner(deps) {
|
|
|
408
406
|
}));
|
|
409
407
|
}
|
|
410
408
|
catch (error) {
|
|
411
|
-
|
|
409
|
+
approvalBlockedReasons.push(`Merge policy blocked the approval step: ${describeMergeActorError(error)}`);
|
|
412
410
|
}
|
|
413
411
|
}
|
|
414
412
|
const autoMergeEventId = `pr-auto-merge-enabled-${commentId}`;
|
|
413
|
+
let autoMergeSucceeded = false;
|
|
415
414
|
if (input.mergePolicy.autoMerge &&
|
|
416
415
|
(await deps.stateStore.readEventEnvelope(autoMergeEventId)) === null) {
|
|
417
416
|
try {
|
|
@@ -435,14 +434,52 @@ export function createTickRunner(deps) {
|
|
|
435
434
|
idempotencyKey: `${input.approvalResolution.triggeringCommentId}:pr-auto-merge`,
|
|
436
435
|
},
|
|
437
436
|
}));
|
|
437
|
+
autoMergeSucceeded = true;
|
|
438
438
|
}
|
|
439
439
|
catch (error) {
|
|
440
|
-
|
|
440
|
+
autoMergeBlockedReasons.push(`Merge policy blocked the auto-merge step: ${describeMergeActorError(error)}`);
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
|
+
else if (input.mergePolicy.autoMerge) {
|
|
444
|
+
autoMergeSucceeded = true;
|
|
445
|
+
}
|
|
446
|
+
const blockedReasons = autoMergeSucceeded && input.mergePolicy.autoMerge
|
|
447
|
+
? autoMergeBlockedReasons
|
|
448
|
+
: [...approvalBlockedReasons, ...autoMergeBlockedReasons];
|
|
443
449
|
if (blockedReasons.length > 0) {
|
|
444
450
|
return { blocked: true, reason: blockedReasons.join(' ') };
|
|
445
451
|
}
|
|
452
|
+
// Approval failed but auto-merge covered it (e.g. GitHub rejecting
|
|
453
|
+
// self-approval on the bot's own PR) - not a policy block, but the
|
|
454
|
+
// failure should still leave a visible trail instead of vanishing
|
|
455
|
+
// silently, since it may also be a real permissions/config problem.
|
|
456
|
+
if (approvalBlockedReasons.length > 0) {
|
|
457
|
+
const occurredAt = eventStampNow();
|
|
458
|
+
await deliverOutboundEvent(createEventEnvelope({
|
|
459
|
+
eventId: `pr-merge-approval-note-${commentId}`,
|
|
460
|
+
workItemKey: input.projection.workItemKey,
|
|
461
|
+
streamScope: 'work-item',
|
|
462
|
+
direction: 'outbound',
|
|
463
|
+
sourceSystem: 'wake',
|
|
464
|
+
sourceEventType: PUBLISH_INTENT_REQUESTED_EVENT,
|
|
465
|
+
sourceRefs: {
|
|
466
|
+
repo: input.projection.issue.repo,
|
|
467
|
+
issueNumber: input.projection.issue.number,
|
|
468
|
+
resourceUri: targetResourceUri,
|
|
469
|
+
},
|
|
470
|
+
occurredAt,
|
|
471
|
+
ingestedAt: occurredAt,
|
|
472
|
+
trigger: 'context-only',
|
|
473
|
+
payload: {
|
|
474
|
+
kind: 'status-update',
|
|
475
|
+
origin: input.projection.origin ?? 'github',
|
|
476
|
+
body: `Approval step did not block the merge, but did not succeed on its own: ${approvalBlockedReasons.join(' ')}`,
|
|
477
|
+
idempotencyKey: `${commentId}:pr-merge-approval-note`,
|
|
478
|
+
deliveryState: 'PENDING',
|
|
479
|
+
},
|
|
480
|
+
derivedHints: { stage: input.projection.wake.stage },
|
|
481
|
+
}));
|
|
482
|
+
}
|
|
446
483
|
return { blocked: false };
|
|
447
484
|
}
|
|
448
485
|
// The one deterministic approval transition: /approved, wake:auto, and a
|
|
@@ -2054,7 +2091,7 @@ export function createTickRunner(deps) {
|
|
|
2054
2091
|
},
|
|
2055
2092
|
payload: {
|
|
2056
2093
|
...publishIntent.payload,
|
|
2057
|
-
kind:
|
|
2094
|
+
kind: 'status-update',
|
|
2058
2095
|
body: sentinel === 'DONE'
|
|
2059
2096
|
? `${parsedRunnerResult.body}\n\n${prReviewApprovalMarker}`
|
|
2060
2097
|
: `${parsedRunnerResult.body}\n\n<!-- wake:pr-review-changes-requested -->`,
|
package/dist/src/version.js
CHANGED