@chernabog/recipes 0.5.0 → 0.7.0
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/flows/address-review.ts +76 -6
- package/flows/epic.ts +249 -78
- package/flows/human-initiated.ts +2 -1
- package/flows/implement.ts +76 -16
- package/flows/plan.ts +64 -12
- package/flows/post-merge.ts +299 -107
- package/flows/re-review.ts +25 -3
- package/flows/resolve-conflicts.ts +83 -26
- package/flows/review.ts +22 -3
- package/package.json +3 -3
package/flows/address-review.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// the keys a run in flight resumes by, so renaming one restarts that step.
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
|
+
Blocks,
|
|
15
16
|
defineFlow,
|
|
16
17
|
Events,
|
|
17
18
|
Implement,
|
|
@@ -33,7 +34,15 @@ import * as Schema from "effect/Schema";
|
|
|
33
34
|
// left moves the record there first.
|
|
34
35
|
// A person has one labelled auto:needs-human, and a run of another flow one it
|
|
35
36
|
// owns; both are left alone. Each is routed by its assignees and reviewers.
|
|
36
|
-
|
|
37
|
+
// Then pull requests whose fix a CI job pushed, ending the job while its CI
|
|
38
|
+
// ran: each is held until the checks are green or red.
|
|
39
|
+
const trigger = Effect.gen(function* () {
|
|
40
|
+
return [...(yield* Review.changesToAddress), ...(yield* Review.fixesAwaitingCi)];
|
|
41
|
+
}).pipe(
|
|
42
|
+
// Every record it reads is checked first, as its document's are (ADR 21, decision 5).
|
|
43
|
+
Blocks.checked("review.changesRequested", "author.waitForCi"),
|
|
44
|
+
reportAs("trigger"),
|
|
45
|
+
);
|
|
37
46
|
|
|
38
47
|
const answerReview = (address: Review.AddressItem) =>
|
|
39
48
|
Effect.gen(function* () {
|
|
@@ -83,17 +92,55 @@ const answerReview = (address: Review.AddressItem) =>
|
|
|
83
92
|
base: address.baseRef,
|
|
84
93
|
withPerson: session.withPerson,
|
|
85
94
|
});
|
|
95
|
+
// In a CI job, still-pending CI ends the job here, and the pull request
|
|
96
|
+
// comes back through Review.fixesAwaitingCi once CI finishes.
|
|
86
97
|
yield* Implement.waitForCi(
|
|
87
98
|
address.pullRequest,
|
|
88
99
|
worktree,
|
|
89
100
|
{ ...session, branch: address.headRef, base: address.baseRef },
|
|
90
|
-
{ id: `review-${round}
|
|
101
|
+
{ id: `review-${round}`, ...Review.parkOnPullRequest(address.pullRequest) },
|
|
91
102
|
);
|
|
92
103
|
yield* Review.askAgain(address.pullRequest, round, address.reviewer, outcome.summary);
|
|
93
104
|
|
|
94
105
|
return `#${address.pullRequest}: addressed review ${round}; asked ${address.reviewer} to review again`;
|
|
95
106
|
});
|
|
96
107
|
|
|
108
|
+
// The fix is pushed, and a CI job ended while its CI ran, which has finished:
|
|
109
|
+
// wait on from the round the record names (a fix of red CI resumes the
|
|
110
|
+
// author's session), then ask the reviewer again.
|
|
111
|
+
const resumeCi = (address: Review.AddressItem, resumed: Review.ResumingCi) =>
|
|
112
|
+
Effect.gen(function* () {
|
|
113
|
+
const review = yield* Review.changesAsked(address);
|
|
114
|
+
const round = review.round ?? 1;
|
|
115
|
+
const author = yield* Review.authorSession(address.pullRequest);
|
|
116
|
+
|
|
117
|
+
const session = {
|
|
118
|
+
sessionId: Option.some(author.sessionId),
|
|
119
|
+
adapter: Option.some(author.adapter),
|
|
120
|
+
withPerson: author.withPerson === true,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const worktree = yield* Review.prepareAuthorWorktree(address.headRef);
|
|
124
|
+
yield* Implement.waitForCi(
|
|
125
|
+
address.pullRequest,
|
|
126
|
+
worktree,
|
|
127
|
+
{ ...session, branch: address.headRef, base: address.baseRef },
|
|
128
|
+
{
|
|
129
|
+
id: `review-${round}`,
|
|
130
|
+
...Review.parkOnPullRequest(address.pullRequest),
|
|
131
|
+
firstRound: resumed.round,
|
|
132
|
+
},
|
|
133
|
+
);
|
|
134
|
+
yield* Review.askAgain(
|
|
135
|
+
address.pullRequest,
|
|
136
|
+
round,
|
|
137
|
+
address.reviewer,
|
|
138
|
+
"the commits pushed since that review. Their CI finished after the job that pushed them ended.",
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
return `#${address.pullRequest}: addressed review ${round}; asked ${address.reviewer} to review again`;
|
|
142
|
+
});
|
|
143
|
+
|
|
97
144
|
const workflow = (item: WorkItem) =>
|
|
98
145
|
Effect.gen(function* () {
|
|
99
146
|
const address = yield* Review.addressItemOf(item);
|
|
@@ -103,7 +150,25 @@ const workflow = (item: WorkItem) =>
|
|
|
103
150
|
// Anything that stops it hands the pull request to a person, unless it
|
|
104
151
|
// closed meanwhile. It owns the pull request throughout, so no other run
|
|
105
152
|
// pushes to the branch under it; one another run owns is skipped.
|
|
106
|
-
|
|
153
|
+
const answering = Effect.gen(function* () {
|
|
154
|
+
const resumed = Review.resumingCi(address);
|
|
155
|
+
|
|
156
|
+
if (Option.isSome(resumed)) {
|
|
157
|
+
return yield* resumeCi(address, resumed.value);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return yield* answerReview(address);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// One that changes a behavior spec no person approved goes to a person,
|
|
164
|
+
// unanswered; a run taking up a fix's wait for CI went past this already.
|
|
165
|
+
const guarded = Effect.gen(function* () {
|
|
166
|
+
if (Option.isNone(Review.resumingCi(address))) {
|
|
167
|
+
yield* PullRequest.specGuard(address.pullRequest);
|
|
168
|
+
}
|
|
169
|
+
}).pipe(Effect.catchTag("NotFound", (gone) => Effect.fail(new Skip({ reason: gone.message }))));
|
|
170
|
+
|
|
171
|
+
const answered = answering.pipe(
|
|
107
172
|
Effect.catchTags({
|
|
108
173
|
NeedsHuman: (needsHuman) => toPerson(needsHuman.reason),
|
|
109
174
|
StepFailed: (failed) => toPerson(`${failed.step}: ${failed.message}`),
|
|
@@ -115,8 +180,9 @@ const workflow = (item: WorkItem) =>
|
|
|
115
180
|
PullRequestClosed: (closed) => Effect.fail(new Skip({ reason: closed.message })),
|
|
116
181
|
NotFound: (gone) => Effect.fail(new Skip({ reason: gone.message })),
|
|
117
182
|
}),
|
|
118
|
-
PullRequest.owning(address.pullRequest),
|
|
119
183
|
);
|
|
184
|
+
|
|
185
|
+
return yield* guarded.pipe(Effect.andThen(answered), PullRequest.owning(address.pullRequest));
|
|
120
186
|
});
|
|
121
187
|
|
|
122
188
|
// What config.yaml may set for this flow, under settings: or flows.<name>.settings.
|
|
@@ -144,6 +210,10 @@ const flow = defineFlow({
|
|
|
144
210
|
});
|
|
145
211
|
|
|
146
212
|
// The GitHub events that can change what its trigger finds, so it wakes in CI
|
|
147
|
-
// rather than only on the schedule: a review submitted
|
|
213
|
+
// rather than only on the schedule: a review submitted, and a finished CI run,
|
|
214
|
+
// which frees a fix a CI job left waiting on its CI. Its trigger reads each
|
|
148
215
|
// pull request's phase, so a phase event wakes it too.
|
|
149
|
-
export default Events.declare(flow, {
|
|
216
|
+
export default Events.declare(flow, {
|
|
217
|
+
events: [Events.reviewSubmitted, Events.ciCompleted],
|
|
218
|
+
readsPhases: true,
|
|
219
|
+
});
|