@aviaratech/ai-delivery 0.3.33 → 0.3.35
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/README.md +70 -3
- package/dist/boardReconcile.test.d.ts +1 -0
- package/dist/boardReconcile.test.js +1685 -0
- package/dist/boardReconcile.test.js.map +1 -0
- package/dist/cli.js +37 -1
- package/dist/cli.js.map +1 -1
- package/dist/cliResult.js +21 -1
- package/dist/cliResult.js.map +1 -1
- package/dist/cliResult.test.js +82 -0
- package/dist/cliResult.test.js.map +1 -1
- package/dist/config/deliveryConfig.d.ts +32 -0
- package/dist/config/deliveryConfig.js +5 -0
- package/dist/config/deliveryConfig.js.map +1 -1
- package/dist/config/deliveryConfig.test.js +67 -0
- package/dist/config/deliveryConfig.test.js.map +1 -1
- package/dist/currentTrackingScenario.test.js +6 -4
- package/dist/currentTrackingScenario.test.js.map +1 -1
- package/dist/directoryIndependent.test.js +2 -2
- package/dist/directoryIndependent.test.js.map +1 -1
- package/dist/dispatch.d.ts +1 -1
- package/dist/dispatch.js +33 -1
- package/dist/dispatch.js.map +1 -1
- package/dist/errors.d.ts +13 -0
- package/dist/errors.js +15 -0
- package/dist/errors.js.map +1 -1
- package/dist/fixtures/inertEntrypoints.js +7 -0
- package/dist/fixtures/inertEntrypoints.js.map +1 -1
- package/dist/github/commandIdentityPolicy.js +1 -0
- package/dist/github/commandIdentityPolicy.js.map +1 -1
- package/dist/github/discovery.d.ts +2 -0
- package/dist/github/discovery.js +17 -3
- package/dist/github/discovery.js.map +1 -1
- package/dist/github/nativeIssueMetadata.d.ts +27 -0
- package/dist/github/nativeIssueMetadata.js +58 -0
- package/dist/github/nativeIssueMetadata.js.map +1 -1
- package/dist/github/projectDelivery.d.ts +36 -0
- package/dist/github/projectDelivery.js +136 -31
- package/dist/github/projectDelivery.js.map +1 -1
- package/dist/github/relationships.d.ts +5 -2
- package/dist/github/relationships.js +59 -2
- package/dist/github/relationships.js.map +1 -1
- package/dist/issue.d.ts +72 -3
- package/dist/issue.js +354 -117
- package/dist/issue.js.map +1 -1
- package/dist/issueBatchUpdate.test.js +229 -12
- package/dist/issueBatchUpdate.test.js.map +1 -1
- package/dist/issueDates.test.d.ts +1 -0
- package/dist/issueDates.test.js +253 -0
- package/dist/issueDates.test.js.map +1 -0
- package/dist/issueTracking.test.js +436 -11
- package/dist/issueTracking.test.js.map +1 -1
- package/dist/mcp/index.js +4 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/tools.d.ts +598 -0
- package/dist/mcp/tools.js +10 -0
- package/dist/mcp/tools.js.map +1 -1
- package/dist/pluginInstaller.js +21 -23
- package/dist/pluginInstaller.js.map +1 -1
- package/dist/pluginInstaller.test.js +121 -1
- package/dist/pluginInstaller.test.js.map +1 -1
- package/dist/pluginPackaging.test.js +135 -6
- package/dist/pluginPackaging.test.js.map +1 -1
- package/dist/pr.d.ts +7 -0
- package/dist/pr.js +104 -99
- package/dist/pr.js.map +1 -1
- package/dist/pr.test.js +202 -223
- package/dist/pr.test.js.map +1 -1
- package/dist/prAssociation.test.js +11 -10
- package/dist/prAssociation.test.js.map +1 -1
- package/dist/review.d.ts +1 -0
- package/dist/review.js +7 -6
- package/dist/review.js.map +1 -1
- package/dist/review.test.js +8 -4
- package/dist/review.test.js.map +1 -1
- package/dist/services/boardReconcileService.d.ts +1204 -0
- package/dist/services/boardReconcileService.js +1571 -0
- package/dist/services/boardReconcileService.js.map +1 -0
- package/dist/services/deliveryAdmission.d.ts +2 -0
- package/dist/services/deliveryAdmission.js +2 -2
- package/dist/services/deliveryAdmission.js.map +1 -1
- package/dist/setup.test.js +474 -32
- package/dist/setup.test.js.map +1 -1
- package/dist/stdoutRegression.test.js +27 -2
- package/dist/stdoutRegression.test.js.map +1 -1
- package/dist/targetPolicyRoutes.test.js +2 -2
- package/dist/targetPolicyRoutes.test.js.map +1 -1
- package/dist/verification.js +38 -2
- package/dist/verification.js.map +1 -1
- package/dist/verificationGate.test.js +25 -2
- package/dist/verificationGate.test.js.map +1 -1
- package/dist/version.d.ts +6 -0
- package/dist/version.js +16 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -1
- package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
- package/plugins/ai-delivery/plugin.json +1 -1
- package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +24 -0
- package/plugins/ai-delivery/runtime/dist/cli.js +68 -67
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +4 -4
package/dist/pr.test.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import assert from 'node:assert/strict';
|
|
2
2
|
import { describe, it } from 'vitest';
|
|
3
|
-
import { publishPr, mergePr, finishIssue } from './pr.js';
|
|
3
|
+
import { publishPr, mergePr, finishIssue, prChecks } from './pr.js';
|
|
4
4
|
import { digestValue } from './delivery/common.js';
|
|
5
|
-
import { readRequiredReviewState } from './review.js';
|
|
6
5
|
const head = 'a'.repeat(40);
|
|
7
6
|
const merge = 'b'.repeat(40);
|
|
8
7
|
function fixture(state = 'clean', option = {}) {
|
|
@@ -54,7 +53,7 @@ function fixture(state = 'clean', option = {}) {
|
|
|
54
53
|
draft: publicationDraft ?? false,
|
|
55
54
|
merged,
|
|
56
55
|
merge_commit_sha: merged ? merge : null,
|
|
57
|
-
mergeable: state === 'clean',
|
|
56
|
+
mergeable: state === 'clean' || state === 'unstable' || state === 'has_hooks',
|
|
58
57
|
mergeable_state: state,
|
|
59
58
|
head: { sha: head, ref: 'issue/17', repo: { full_name: 'example/widget' } },
|
|
60
59
|
base: {
|
|
@@ -66,79 +65,64 @@ function fixture(state = 'clean', option = {}) {
|
|
|
66
65
|
});
|
|
67
66
|
const rest = {
|
|
68
67
|
request: async (route) => {
|
|
69
|
-
if (
|
|
70
|
-
return { data: [] };
|
|
71
|
-
const count = Object.hasOwn(option, 'requiredApprovals') ? option.requiredApprovals : 0;
|
|
72
|
-
if (option.ruleVisibility === 'unknown')
|
|
68
|
+
if (option.requirementsUnavailable)
|
|
73
69
|
throw { status: 403 };
|
|
74
|
-
if (route.endsWith('/rules/branches/{branch}'))
|
|
75
|
-
if (option.ruleVisibility === 'partial')
|
|
76
|
-
throw { status: 403 };
|
|
70
|
+
if (route.endsWith('/rules/branches/{branch}'))
|
|
77
71
|
return {
|
|
78
|
-
status:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}),
|
|
84
|
-
data: option.reviewPolicy === 'ruleset'
|
|
85
|
-
? [
|
|
86
|
-
{
|
|
87
|
-
type: 'pull_request',
|
|
88
|
-
ruleset_id: 41,
|
|
89
|
-
ruleset_source_type: 'Repository',
|
|
90
|
-
ruleset_source: 'example/widget',
|
|
91
|
-
parameters: { required_approving_review_count: count },
|
|
92
|
-
},
|
|
72
|
+
status: 200,
|
|
73
|
+
headers: {},
|
|
74
|
+
data: option.requirementsViaClassic
|
|
75
|
+
? []
|
|
76
|
+
: [
|
|
93
77
|
{
|
|
94
78
|
type: 'required_status_checks',
|
|
95
|
-
ruleset_id: 41,
|
|
96
|
-
ruleset_source_type: 'Repository',
|
|
97
|
-
ruleset_source: 'example/widget',
|
|
98
79
|
parameters: {
|
|
99
|
-
required_status_checks:
|
|
80
|
+
required_status_checks: (option.configuredRequiredChecks ??
|
|
81
|
+
[
|
|
82
|
+
...(option.nativeChecks ?? []).filter((check) => check.required),
|
|
83
|
+
...(option.nativeStatuses ?? []).filter((check) => check.required),
|
|
84
|
+
].map((check) => check.name)).map((context) => ({ context })),
|
|
100
85
|
},
|
|
101
86
|
},
|
|
102
|
-
]
|
|
103
|
-
: [],
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
if (route.endsWith('/protection')) {
|
|
107
|
-
if (option.ruleVisibility === 'permission-404' || option.ruleVisibility === 'generic-404')
|
|
108
|
-
throw {
|
|
109
|
-
status: 404,
|
|
110
|
-
response: {
|
|
111
|
-
status: option.ruleVisibility === 'permission-404' ? 403 : 404,
|
|
112
|
-
data: { message: option.ruleVisibility === 'generic-404' ? 'Not Found' : 'Branch not protected' },
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
if (option.reviewPolicy === 'ruleset' && !Object.hasOwn(option, 'classicApprovals'))
|
|
116
|
-
throw { status: 404, response: { status: 404, data: { message: 'Branch not protected' } } };
|
|
117
|
-
return {
|
|
118
|
-
status: option.classicStatus ?? 200,
|
|
119
|
-
headers: {},
|
|
120
|
-
data: {
|
|
121
|
-
required_pull_request_reviews: {
|
|
122
|
-
required_approving_review_count: Object.hasOwn(option, 'classicApprovals')
|
|
123
|
-
? option.classicApprovals
|
|
124
|
-
: count,
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
if (route.endsWith('/rulesets'))
|
|
130
|
-
return {
|
|
131
|
-
status: 200,
|
|
132
|
-
headers: {},
|
|
133
|
-
data: [{ id: 41, source_type: 'Repository', source: 'example/widget', enforcement: 'active' }],
|
|
87
|
+
],
|
|
134
88
|
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
89
|
+
return {
|
|
90
|
+
status: 200,
|
|
91
|
+
headers: {},
|
|
92
|
+
data: {
|
|
93
|
+
required_pull_request_reviews: { required_approving_review_count: 0 },
|
|
94
|
+
required_status_checks: option.requirementsViaClassic
|
|
95
|
+
? { contexts: option.configuredRequiredChecks ?? [] }
|
|
96
|
+
: null,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
checks: {
|
|
101
|
+
listForRef: async () => ({
|
|
102
|
+
data: {
|
|
103
|
+
total_count: (option.nativeChecks ?? []).length,
|
|
104
|
+
check_runs: (option.nativeChecks ?? []).slice(0, 100).map((check) => ({
|
|
105
|
+
name: check.name,
|
|
106
|
+
status: check.status.toLowerCase(),
|
|
107
|
+
conclusion: check.conclusion?.toLowerCase() ?? null,
|
|
108
|
+
})),
|
|
109
|
+
},
|
|
110
|
+
}),
|
|
111
|
+
},
|
|
112
|
+
repos: {
|
|
113
|
+
getCombinedStatusForRef: async () => ({
|
|
114
|
+
data: {
|
|
115
|
+
state: (option.nativeStatuses ?? []).some((check) => ['FAILURE', 'ERROR'].includes(check.state))
|
|
116
|
+
? 'failure'
|
|
117
|
+
: 'success',
|
|
118
|
+
total_count: (option.nativeStatuses ?? []).length,
|
|
119
|
+
statuses: (option.nativeStatuses ?? [])
|
|
120
|
+
.slice(0, 100)
|
|
121
|
+
.map((check) => ({ context: check.name, state: check.state.toLowerCase() })),
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
get: async () => ({ data: { node_id: 'REPO', default_branch: 'main', full_name: 'example/widget' } }),
|
|
140
125
|
},
|
|
141
|
-
repos: { get: async () => ({ data: { node_id: 'REPO', default_branch: 'main', full_name: 'example/widget' } }) },
|
|
142
126
|
git: {
|
|
143
127
|
getCommit: async () => ({ data: { sha: head, tree: { sha: '0'.repeat(40) } } }),
|
|
144
128
|
getRef: async ({ ref }) => ({
|
|
@@ -172,7 +156,7 @@ function fixture(state = 'clean', option = {}) {
|
|
|
172
156
|
data: {
|
|
173
157
|
id: 99,
|
|
174
158
|
user: { login: 'reviewer[bot]' },
|
|
175
|
-
state:
|
|
159
|
+
state: 'APPROVED',
|
|
176
160
|
commit_id: head,
|
|
177
161
|
body: reviewBody,
|
|
178
162
|
html_url: 'https://github.com/example/widget/pull/23#pullrequestreview-99',
|
|
@@ -285,26 +269,6 @@ function fixture(state = 'clean', option = {}) {
|
|
|
285
269
|
},
|
|
286
270
|
},
|
|
287
271
|
};
|
|
288
|
-
if (query.includes('DeliveryReviewAccess'))
|
|
289
|
-
return {
|
|
290
|
-
repository: {
|
|
291
|
-
pullRequest: {
|
|
292
|
-
reviews: {
|
|
293
|
-
nodes: option.reviewAccessUnknown
|
|
294
|
-
? []
|
|
295
|
-
: [
|
|
296
|
-
{
|
|
297
|
-
fullDatabaseId: 99,
|
|
298
|
-
author: { login: option.reviewAccessActor ?? 'reviewer' },
|
|
299
|
-
authorCanPushToRepository: option.reviewCannotPush !== true,
|
|
300
|
-
commit: { oid: head },
|
|
301
|
-
state: 'APPROVED',
|
|
302
|
-
},
|
|
303
|
-
],
|
|
304
|
-
},
|
|
305
|
-
},
|
|
306
|
-
},
|
|
307
|
-
};
|
|
308
272
|
if (query.includes('DeliveryClosingIssues'))
|
|
309
273
|
return {
|
|
310
274
|
repository: {
|
|
@@ -383,132 +347,17 @@ function fixture(state = 'clean', option = {}) {
|
|
|
383
347
|
return { context, merges, closes: () => closes };
|
|
384
348
|
}
|
|
385
349
|
describe('remote GitHub lifecycle', () => {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
const { context, merges, closes } = fixture('clean', {
|
|
390
|
-
reviewPolicy: 'ruleset',
|
|
391
|
-
reviewDecision: null,
|
|
392
|
-
requiredApprovals: source === 'ruleset' ? unknownCount : 0,
|
|
393
|
-
classicApprovals: source === 'classic' ? unknownCount : 0,
|
|
394
|
-
});
|
|
395
|
-
await assert.rejects(finishIssue(context, { issueNumber: 17, prNumber: 23 }));
|
|
396
|
-
assert.equal(merges.length, 0);
|
|
397
|
-
assert.equal(closes(), 0);
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
for (const rulePage of ['missing-headers', 'non-200', 'continuation']) {
|
|
402
|
-
it(`refuses mixed zero/null with incomplete applicable rule page ${rulePage}`, async () => {
|
|
403
|
-
const { context, merges, closes } = fixture('clean', {
|
|
404
|
-
reviewPolicy: 'ruleset',
|
|
405
|
-
reviewDecision: null,
|
|
406
|
-
classicApprovals: 0,
|
|
407
|
-
rulePage,
|
|
408
|
-
});
|
|
409
|
-
await assert.rejects(finishIssue(context, { issueNumber: 17, prNumber: 23 }));
|
|
410
|
-
assert.equal(merges.length, 0);
|
|
411
|
-
assert.equal(closes(), 0);
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
it('refuses mixed zero/null with a fulfilled non-successful classic response', async () => {
|
|
415
|
-
const { context, merges, closes } = fixture('clean', {
|
|
416
|
-
reviewPolicy: 'ruleset',
|
|
417
|
-
reviewDecision: null,
|
|
418
|
-
classicApprovals: 0,
|
|
419
|
-
classicStatus: 500,
|
|
420
|
-
});
|
|
421
|
-
await assert.rejects(finishIssue(context, { issueNumber: 17, prNumber: 23 }));
|
|
422
|
-
assert.equal(merges.length, 0);
|
|
423
|
-
assert.equal(closes(), 0);
|
|
424
|
-
});
|
|
425
|
-
it('merges mixed zero/null only when both complete policy sources explicitly require zero', async () => {
|
|
426
|
-
const { context, merges, closes } = fixture('clean', {
|
|
427
|
-
reviewPolicy: 'ruleset',
|
|
428
|
-
reviewDecision: null,
|
|
429
|
-
classicApprovals: 0,
|
|
430
|
-
});
|
|
431
|
-
await finishIssue(context, { issueNumber: 17, prNumber: 23 });
|
|
350
|
+
it('uses native eligibility without comparing historical artifact identity', async () => {
|
|
351
|
+
const { context, merges } = fixture('clean', { reviewBinding: 'stale-head' });
|
|
352
|
+
await mergePr(context, { issueNumber: 17, prNumber: 23, reviewedHeadSha: head });
|
|
432
353
|
assert.equal(merges.length, 1);
|
|
433
354
|
assert.equal(merges[0]?.sha, head);
|
|
434
|
-
assert.equal(closes(), 1);
|
|
435
355
|
});
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
assert.equal(decision.status, 'unknown');
|
|
442
|
-
assert.equal(decision.submittedReviewAuthorCanPushToRepository, true);
|
|
443
|
-
const preview = await mergePr(context, { issueNumber: 17, prNumber: 23, reviewedHeadSha: head, dryRun: true });
|
|
444
|
-
assert.equal(preview.headSha, head);
|
|
445
|
-
assert.equal(merges.length, 0);
|
|
446
|
-
assert.equal(closes(), 0);
|
|
447
|
-
await finishIssue(context, { issueNumber: 17, prNumber: 23, reviewedHeadSha: head });
|
|
448
|
-
assert.equal(merges.length, 1);
|
|
449
|
-
assert.equal(merges[0]?.sha, head);
|
|
450
|
-
assert.equal(closes(), 1);
|
|
451
|
-
});
|
|
452
|
-
for (const requiredApprovals of [undefined, null, -1, 1, '0', false, {}]) {
|
|
453
|
-
it(`refuses ${reviewPolicy} null decision with unconfirmed zero count ${JSON.stringify(requiredApprovals)}`, async () => {
|
|
454
|
-
const { context, merges, closes } = fixture('clean', { reviewPolicy, requiredApprovals, reviewDecision: null });
|
|
455
|
-
await assert.rejects(finishIssue(context, { issueNumber: 17, prNumber: 23 }));
|
|
456
|
-
assert.equal(merges.length, 0);
|
|
457
|
-
assert.equal(closes(), 0);
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
for (const ruleVisibility of ['partial', 'unknown', 'permission-404', 'generic-404']) {
|
|
461
|
-
it(`refuses ${reviewPolicy} zero/null with ${ruleVisibility} visibility`, async () => {
|
|
462
|
-
const { context, merges, closes } = fixture('clean', { reviewPolicy, ruleVisibility, reviewDecision: null });
|
|
463
|
-
await assert.rejects(finishIssue(context, { issueNumber: 17, prNumber: 23 }));
|
|
464
|
-
assert.equal(merges.length, 0);
|
|
465
|
-
assert.equal(closes(), 0);
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
for (const reviewDecision of [undefined, 'UNKNOWN', false, 0, {}]) {
|
|
469
|
-
it(`refuses ${reviewPolicy} zero reviews with missing or malformed decision ${JSON.stringify(reviewDecision)}`, async () => {
|
|
470
|
-
const { context, merges, closes } = fixture('clean', { reviewPolicy, reviewDecision });
|
|
471
|
-
await assert.rejects(finishIssue(context, { issueNumber: 17, prNumber: 23 }));
|
|
472
|
-
assert.equal(merges.length, 0);
|
|
473
|
-
assert.equal(closes(), 0);
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
for (const guard of [
|
|
477
|
-
{ decisionUnavailable: true },
|
|
478
|
-
{ decisionHeadMoved: true },
|
|
479
|
-
{ baseMoved: true },
|
|
480
|
-
{ baseChangedAfterDecision: 'name' },
|
|
481
|
-
{ baseChangedAfterDecision: 'sha' },
|
|
482
|
-
{ headMoved: true },
|
|
483
|
-
{ reviewMoved: true },
|
|
484
|
-
{ reviewCannotPush: true },
|
|
485
|
-
{ reviewAccessUnknown: true },
|
|
486
|
-
{ reviewAccessActor: 'foreign-reviewer' },
|
|
487
|
-
{ reviewBinding: 'stale-head' },
|
|
488
|
-
{ reviewBinding: 'wrong-tree' },
|
|
489
|
-
{ reviewBinding: 'wrong-scope' },
|
|
490
|
-
{ reviewBinding: 'invalid-digest' },
|
|
491
|
-
{ reviewBinding: 'marker-only' },
|
|
492
|
-
{ reviewBinding: 'wrong-issue' },
|
|
493
|
-
{ reviewBinding: 'wrong-pr' },
|
|
494
|
-
{ reviewBinding: 'wrong-role' },
|
|
495
|
-
]) {
|
|
496
|
-
it(`preserves ${reviewPolicy} zero/null merge guard ${JSON.stringify(guard)}`, async () => {
|
|
497
|
-
const { context, merges, closes } = fixture('clean', { ...guard, reviewPolicy, reviewDecision: null });
|
|
498
|
-
await assert.rejects(finishIssue(context, { issueNumber: 17, prNumber: 23 }));
|
|
499
|
-
assert.equal(merges.length, 0);
|
|
500
|
-
assert.equal(closes(), 0);
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
for (const state of [null, 'unknown', 'blocked', 'unstable', 'behind', 'dirty']) {
|
|
504
|
-
it(`refuses ${reviewPolicy} zero/null with non-CLEAN native check and merge state ${String(state)}`, async () => {
|
|
505
|
-
const { context, merges, closes } = fixture(state, { reviewPolicy, reviewDecision: null });
|
|
506
|
-
await assert.rejects(finishIssue(context, { issueNumber: 17, prNumber: 23 }));
|
|
507
|
-
assert.equal(merges.length, 0);
|
|
508
|
-
assert.equal(closes(), 0);
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
}
|
|
356
|
+
it('accepts native PR association despite a superseded linked branch snapshot', async () => {
|
|
357
|
+
const { context, merges } = fixture('clean', { unrelatedBranch: true });
|
|
358
|
+
await mergePr(context, { issueNumber: 17, prNumber: 23 });
|
|
359
|
+
assert.equal(merges.length, 1);
|
|
360
|
+
});
|
|
512
361
|
for (const reviewBinding of [
|
|
513
362
|
'stale-head',
|
|
514
363
|
'wrong-tree',
|
|
@@ -519,20 +368,154 @@ describe('remote GitHub lifecycle', () => {
|
|
|
519
368
|
'wrong-pr',
|
|
520
369
|
'wrong-role',
|
|
521
370
|
]) {
|
|
522
|
-
it(`
|
|
523
|
-
const { context, merges
|
|
524
|
-
|
|
371
|
+
it(`defers ${reviewBinding} historical review eligibility to GitHub`, async () => {
|
|
372
|
+
const { context, merges } = fixture('clean', { reviewBinding });
|
|
373
|
+
context.clients.rest.pulls.listReviews = (async () => {
|
|
374
|
+
throw new Error('Historical review comparison must not run');
|
|
375
|
+
});
|
|
376
|
+
context.clients.rest.git.getCommit = (async () => {
|
|
377
|
+
throw new Error('Historical tree comparison must not run');
|
|
378
|
+
});
|
|
379
|
+
context.clients.rest.pulls.listFiles = (async () => {
|
|
380
|
+
throw new Error('Historical diff comparison must not run');
|
|
381
|
+
});
|
|
382
|
+
await mergePr(context, { issueNumber: 17, prNumber: 23 });
|
|
383
|
+
assert.equal(merges.length, 1);
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
it('merges a native zero-review decision without requiring an extra App approval', async () => {
|
|
387
|
+
const { context, merges } = fixture('clean', { reviewDecision: null });
|
|
388
|
+
delete context.reviewerClients;
|
|
389
|
+
context.clients.rest.pulls.listReviews = (async () => {
|
|
390
|
+
throw new Error('Extra approval must not be required');
|
|
391
|
+
});
|
|
392
|
+
await mergePr(context, { issueNumber: 17, prNumber: 23 });
|
|
393
|
+
assert.equal(merges.length, 1);
|
|
394
|
+
});
|
|
395
|
+
for (const [status, conclusion] of [
|
|
396
|
+
['IN_PROGRESS', null],
|
|
397
|
+
['COMPLETED', 'FAILURE'],
|
|
398
|
+
['COMPLETED', 'TIMED_OUT'],
|
|
399
|
+
]) {
|
|
400
|
+
it(`names the required native money-path-review blocker ${status}/${conclusion}`, async () => {
|
|
401
|
+
const { context, merges } = fixture('blocked', {
|
|
402
|
+
nativeChecks: [{ name: 'money-path-review', required: true, status, conclusion }],
|
|
403
|
+
});
|
|
404
|
+
await assert.rejects(mergePr(context, { issueNumber: 17, prNumber: 23 }), /money-path-review/u);
|
|
405
|
+
assert.equal(merges.length, 0);
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
it('reports discovered required check names and permits a failed optional check', async () => {
|
|
409
|
+
const { context, merges } = fixture('unstable', {
|
|
410
|
+
nativeChecks: [
|
|
411
|
+
{ name: 'local-verify', required: true, status: 'COMPLETED', conclusion: 'SUCCESS' },
|
|
412
|
+
{ name: 'money-path-review', required: true, status: 'COMPLETED', conclusion: 'NEUTRAL' },
|
|
413
|
+
{ name: 'optional', required: false, status: 'COMPLETED', conclusion: 'FAILURE' },
|
|
414
|
+
],
|
|
415
|
+
});
|
|
416
|
+
const checks = await prChecks(context, 23);
|
|
417
|
+
assert.deepEqual(checks.requiredChecks.map((check) => check.name), ['local-verify', 'money-path-review']);
|
|
418
|
+
await mergePr(context, { issueNumber: 17, prNumber: 23 });
|
|
419
|
+
assert.equal(merges.length, 1);
|
|
420
|
+
});
|
|
421
|
+
it('discovers required legacy names alongside a full page of head check runs', async () => {
|
|
422
|
+
const { context, merges } = fixture('clean', {
|
|
423
|
+
nativeChecks: Array.from({ length: 100 }, (_, i) => ({
|
|
424
|
+
name: `optional${i}`,
|
|
425
|
+
required: false,
|
|
426
|
+
status: 'COMPLETED',
|
|
427
|
+
conclusion: 'SUCCESS',
|
|
428
|
+
})),
|
|
429
|
+
nativeStatuses: [{ name: 'legacy-required', required: true, state: 'SUCCESS' }],
|
|
430
|
+
});
|
|
431
|
+
const checks = await prChecks(context, 23);
|
|
432
|
+
assert.deepEqual(checks.requiredChecks.map((check) => check.name), ['legacy-required']);
|
|
433
|
+
await mergePr(context, { issueNumber: 17, prNumber: 23 });
|
|
434
|
+
assert.equal(merges.length, 1);
|
|
435
|
+
});
|
|
436
|
+
it('refuses GitHub blocked eligibility for a failing required legacy status', async () => {
|
|
437
|
+
const { context, merges } = fixture('blocked', {
|
|
438
|
+
nativeStatuses: [{ name: 'legacy-required', required: true, state: 'FAILURE' }],
|
|
439
|
+
});
|
|
440
|
+
await assert.rejects(mergePr(context, { issueNumber: 17, prNumber: 23 }), /legacy-required/u);
|
|
441
|
+
assert.equal(merges.length, 0);
|
|
442
|
+
});
|
|
443
|
+
it('refuses unavailable review decision readback even when GitHub REST is clean', async () => {
|
|
444
|
+
const { context, merges } = fixture('clean', { decisionUnavailable: true });
|
|
445
|
+
await assert.rejects(mergePr(context, { issueNumber: 17, prNumber: 23 }));
|
|
446
|
+
assert.equal(merges.length, 0);
|
|
447
|
+
});
|
|
448
|
+
for (const reviewDecision of [undefined, 'UNKNOWN', false, 0, {}, 'REVIEW_REQUIRED', 'CHANGES_REQUESTED']) {
|
|
449
|
+
it(`refuses unavailable or blocking native review decision ${JSON.stringify(reviewDecision)}`, async () => {
|
|
450
|
+
const { context, merges } = fixture('clean', { reviewDecision });
|
|
451
|
+
await assert.rejects(mergePr(context, { issueNumber: 17, prNumber: 23 }));
|
|
525
452
|
assert.equal(merges.length, 0);
|
|
526
|
-
assert.equal(closes(), 0);
|
|
527
453
|
});
|
|
528
454
|
}
|
|
529
|
-
for (const option of [
|
|
530
|
-
|
|
455
|
+
for (const option of [
|
|
456
|
+
{ decisionHeadMoved: true },
|
|
457
|
+
{ baseChangedAfterDecision: 'name' },
|
|
458
|
+
{ baseChangedAfterDecision: 'sha' },
|
|
459
|
+
]) {
|
|
460
|
+
it(`refuses native head/base decision drift ${JSON.stringify(option)}`, async () => {
|
|
531
461
|
const { context, merges } = fixture('clean', option);
|
|
532
|
-
await assert.rejects(mergePr(context, { issueNumber: 17, prNumber: 23 })
|
|
462
|
+
await assert.rejects(mergePr(context, { issueNumber: 17, prNumber: 23 }));
|
|
533
463
|
assert.equal(merges.length, 0);
|
|
534
464
|
});
|
|
535
465
|
}
|
|
466
|
+
it('accepts GitHub passing eligibility with native pre-receive hooks', async () => {
|
|
467
|
+
const { context, merges } = fixture('has_hooks');
|
|
468
|
+
await mergePr(context, { issueNumber: 17, prNumber: 23 });
|
|
469
|
+
assert.equal(merges.length, 1);
|
|
470
|
+
});
|
|
471
|
+
it('names a configured required check that has never reported', async () => {
|
|
472
|
+
const { context, merges } = fixture('blocked', {
|
|
473
|
+
configuredRequiredChecks: ['local-verify', 'money-path-review'],
|
|
474
|
+
nativeChecks: [{ name: 'local-verify', required: true, status: 'COMPLETED', conclusion: 'SUCCESS' }],
|
|
475
|
+
});
|
|
476
|
+
const checks = await prChecks(context, 23);
|
|
477
|
+
assert.deepEqual(checks.requiredChecks.map((check) => check.name), ['local-verify', 'money-path-review']);
|
|
478
|
+
await assert.rejects(mergePr(context, { issueNumber: 17, prNumber: 23 }), /money-path-review/u);
|
|
479
|
+
assert.equal(merges.length, 0);
|
|
480
|
+
});
|
|
481
|
+
it('retains configured requirements without relying on a check rollup', async () => {
|
|
482
|
+
const { context } = fixture('blocked', { configuredRequiredChecks: ['money-path-review'] });
|
|
483
|
+
const read = context.clients.graphql;
|
|
484
|
+
context.clients.graphql = (async (query, variables) => {
|
|
485
|
+
assert.ok(!query.includes('statusCheckRollup'));
|
|
486
|
+
return read(query, variables);
|
|
487
|
+
});
|
|
488
|
+
const checks = await prChecks(context, 23);
|
|
489
|
+
assert.deepEqual(checks.requiredChecks, [{ name: 'money-path-review', headState: 'not-reported' }]);
|
|
490
|
+
});
|
|
491
|
+
it('discovers an unreported classic-protection requirement', async () => {
|
|
492
|
+
const { context } = fixture('blocked', {
|
|
493
|
+
requirementsViaClassic: true,
|
|
494
|
+
configuredRequiredChecks: ['classic-required'],
|
|
495
|
+
});
|
|
496
|
+
const checks = await prChecks(context, 23);
|
|
497
|
+
assert.deepEqual(checks.requiredChecks, [{ name: 'classic-required', headState: 'not-reported' }]);
|
|
498
|
+
assert.equal(checks.requiredCheckDiscovery, 'complete');
|
|
499
|
+
});
|
|
500
|
+
it('preserves a failing legacy status beside a successful same-name required check run', async () => {
|
|
501
|
+
const { context, merges } = fixture('blocked', {
|
|
502
|
+
nativeChecks: [{ name: 'money-path-review', required: true, status: 'COMPLETED', conclusion: 'SUCCESS' }],
|
|
503
|
+
nativeStatuses: [{ name: 'money-path-review', required: true, state: 'FAILURE' }],
|
|
504
|
+
});
|
|
505
|
+
const checks = await prChecks(context, 23);
|
|
506
|
+
assert.equal(checks.headChecksComplete, true);
|
|
507
|
+
assert.equal(checks.combinedStatus, 'failure');
|
|
508
|
+
assert.equal(checks.requiredChecks.length, 1);
|
|
509
|
+
assert.match(checks.requiredChecks[0].headState, /success/u);
|
|
510
|
+
assert.match(checks.requiredChecks[0].headState, /failure/u);
|
|
511
|
+
await assert.rejects(mergePr(context, { issueNumber: 17, prNumber: 23 }), /money-path-review/u);
|
|
512
|
+
assert.equal(merges.length, 0);
|
|
513
|
+
});
|
|
514
|
+
it('declares requirement discovery partial when native rule reads are unavailable', async () => {
|
|
515
|
+
const { context } = fixture('blocked', { requirementsUnavailable: true });
|
|
516
|
+
const checks = await prChecks(context, 23);
|
|
517
|
+
assert.equal(checks.requiredCheckDiscovery, 'partial');
|
|
518
|
+
});
|
|
536
519
|
it('refuses publication of a collaborator PR before promotion', async () => {
|
|
537
520
|
const { context } = fixture();
|
|
538
521
|
context.clients.rest.pulls.list = (async () => ({
|
|
@@ -573,7 +556,7 @@ describe('remote GitHub lifecycle', () => {
|
|
|
573
556
|
});
|
|
574
557
|
assert.equal(result.prNumber, 23);
|
|
575
558
|
});
|
|
576
|
-
for (const state of ['blocked', 'behind', 'dirty', '
|
|
559
|
+
for (const state of ['blocked', 'behind', 'dirty', 'unknown', null]) {
|
|
577
560
|
it(`refuses GitHub merge eligibility ${String(state)} without a local receipt fallback`, async () => {
|
|
578
561
|
const { context, merges } = fixture(state);
|
|
579
562
|
await assert.rejects(mergePr(context, { issueNumber: 17, prNumber: 23 }), /GitHub|mergeable|clean|CLEAN/u);
|
|
@@ -595,11 +578,9 @@ describe('remote GitHub lifecycle', () => {
|
|
|
595
578
|
});
|
|
596
579
|
for (const [name, option] of [
|
|
597
580
|
['moved base', { baseMoved: true }],
|
|
598
|
-
['dismissed review readback', { reviewMoved: true }],
|
|
599
581
|
['moved reviewed head', { headMoved: true }],
|
|
600
582
|
['unknown decision', { reviewDecision: 'UNKNOWN' }],
|
|
601
583
|
['required review', { reviewDecision: 'REVIEW_REQUIRED' }],
|
|
602
|
-
['unrelated linked branch', { unrelatedBranch: true }],
|
|
603
584
|
]) {
|
|
604
585
|
it(`refuses ${name} without merge or issue closure`, async () => {
|
|
605
586
|
const { context, merges, closes } = fixture('clean', option);
|
|
@@ -659,8 +640,6 @@ describe('retained issue guarded squash delivery', () => {
|
|
|
659
640
|
assert.equal(closes(), 0);
|
|
660
641
|
});
|
|
661
642
|
for (const option of [
|
|
662
|
-
{ reviewCannotPush: true },
|
|
663
|
-
{ reviewAccessUnknown: true },
|
|
664
643
|
{ reviewDecision: 'REVIEW_REQUIRED' },
|
|
665
644
|
{ baseMoved: true },
|
|
666
645
|
{ headMoved: true },
|