@chernabog/recipes 0.1.0 → 0.2.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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Chernabog's recipes: complete flows, written from [`@chernabog/sdk`](https://www.npmjs.com/package/@chernabog/sdk)'s blocks, that a repo copies into its `.chernabog/` or imports from this package. Each recipe is documented at <https://dataquail.github.io/chernabog/recipes/>.
4
4
 
5
+ Its recipes are `implement`, `review`, `re-review`, `address-review` and `resolve-conflicts`, the review loop; `plan`, which splits a spec into an epic of sub-issues; `epic`, which works through an epic's tasks as pull requests, each based on the branch of the task it builds on; and `human-initiated`, the hybrid path.
6
+
5
7
  `chernabog init` adds this package to a repo's `.chernabog/package.json`. You don't need to install it by hand.
6
8
 
7
9
  ## The recipe package format
@@ -15,26 +15,28 @@ import {
15
15
  Implement,
16
16
  NeedsHuman,
17
17
  PullRequest,
18
- Repo,
19
18
  reportAs,
20
19
  Review,
20
+ Routing,
21
+ Settings,
21
22
  Skip,
22
23
  type WorkItem,
23
24
  } from "@chernabog/sdk";
24
25
  import * as Arr from "effect/Array";
25
26
  import * as Effect from "effect/Effect";
26
27
  import * as Option from "effect/Option";
28
+ import * as Schema from "effect/Schema";
27
29
 
28
30
  // Pull requests this persona wrote whose latest approval or request for
29
31
  // changes asks for changes on the current head, so nothing was pushed since.
30
32
  // A person has one labelled auto:needs-human, and a run of another flow one it
31
- // owns; both are left alone.
33
+ // owns; both are left alone. Each is routed by its assignees and reviewers.
32
34
  const trigger = Effect.gen(function* () {
33
- const repo = yield* Repo;
35
+ const labelNames = yield* Settings.labels;
34
36
  const items: Array<WorkItem> = [];
35
37
 
36
38
  for (const pull of yield* Review.authoredByMe) {
37
- if (pull.labels.includes(repo.labels.needsHuman)) {
39
+ if (pull.labels.includes(labelNames.needsHuman)) {
38
40
  continue;
39
41
  }
40
42
 
@@ -55,7 +57,7 @@ const trigger = Effect.gen(function* () {
55
57
  }
56
58
 
57
59
  for (const review of Option.toArray(latest)) {
58
- items.push(Review.addressItem(pull, review, decisive.length));
60
+ items.push(yield* Review.routed(pull, Review.addressItem(pull, review, decisive.length)));
59
61
  }
60
62
  }
61
63
 
@@ -100,14 +102,16 @@ const answerReview = (address: Review.AddressItem) =>
100
102
 
101
103
  yield* Review.checkChanged(address.pullRequest, round, address.reviewedSha, worktree);
102
104
  yield* Implement.localGate(worktree, { id: `review-${round}`, session });
103
- // Only a fix made in front of a person may touch humanOnlyPaths.
105
+ // Only a fix made in front of a person may touch humanOnlyPaths. A layer
106
+ // of a stack is checked against the layer below, so only its own commits count.
104
107
  yield* Implement.push(`push-review-${round}`, worktree, address.headRef, {
108
+ base: address.baseRef,
105
109
  withPerson: session.withPerson,
106
110
  });
107
111
  yield* Implement.waitForCi(
108
112
  address.pullRequest,
109
113
  worktree,
110
- { ...session, branch: address.headRef },
114
+ { ...session, branch: address.headRef, base: address.baseRef },
111
115
  { id: `review-${round}` },
112
116
  );
113
117
  yield* Review.askAgain(address.pullRequest, round, address.reviewer, outcome.summary);
@@ -137,11 +141,26 @@ const workflow = (item: WorkItem) =>
137
141
  );
138
142
  });
139
143
 
144
+ // What config.yaml may set for this flow, under settings: or flows.<name>.settings.
145
+ const settings = Schema.Struct({
146
+ ...Routing.Settings.fields,
147
+ ...Settings.Labels.fields,
148
+ ...Settings.Base.fields,
149
+ ...Settings.LocalGate.fields,
150
+ ...Settings.Rules.fields,
151
+ ...Settings.Ci.fields,
152
+ ...Settings.Reviewers.fields,
153
+ });
154
+
140
155
  export default defineFlow({
156
+ labels: Settings.declaredLabels,
157
+ settings,
141
158
  trigger,
142
159
  gate: Implement.gate,
143
160
  concurrency: 1,
144
161
  // Its trigger finds only pull requests this persona wrote.
145
162
  ownWork: true,
163
+ // A pull request closed or merged ends the run as superseded.
164
+ stillValid: Review.stillValid,
146
165
  workflow,
147
166
  });