@coda-console/review 3.1.0 → 3.2.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/.coda/workflows/pull-request.bpmn +12 -6
- package/.coda/workflows/simple.bpmn +14 -7
- package/README.md +4 -2
- package/package.json +1 -1
- package/scripts/approval.mjs +12 -6
|
@@ -377,6 +377,7 @@ GitHub 上各项检查用 `gh pr checks {{github.event.pull_request.html_url}}`
|
|
|
377
377
|
<coda:output name="inputs" />
|
|
378
378
|
<coda:output name="missing" />
|
|
379
379
|
<coda:output name="asks" />
|
|
380
|
+
<coda:output name="needs" />
|
|
380
381
|
</extensionElements>
|
|
381
382
|
<script>node "${CODA_PLUGIN_PATH}/scripts/approval.mjs"</script>
|
|
382
383
|
</scriptTask>
|
|
@@ -614,8 +615,9 @@ GitHub 上各项检查用 `gh pr checks {{github.event.pull_request.html_url}}`
|
|
|
614
615
|
<documentation>用户批准合并时勾的流程要一段文字,批准卡上没有写:
|
|
615
616
|
{{split(approval.asks, "\n")[loopCounter]}}
|
|
616
617
|
PR #{{github.event.number}}({{github.event.pull_request.html_url}})已合并。
|
|
617
|
-
按这次合并进来的改动写这段面向用户的文字(Markdown
|
|
618
|
-
|
|
618
|
+
按这次合并进来的改动写这段面向用户的文字(Markdown,不写内部实现,不用审查意见),备注只放文字本身。
|
|
619
|
+
选「这一项这次不跑」(备注可不写):这段文字不写,要它的流程这次都不跑,其余勾了的照常运行;都不跑了就直接结束。不想发出这段文字、写不出时选它,不要答复 rejected。</documentation>
|
|
620
|
+
<extensionElements><coda:choice id="done" name="已写好" primary="true" note="required" /><coda:choice id="skip" name="这一项这次不跑" /></extensionElements>
|
|
619
621
|
<multiInstanceLoopCharacteristics isSequential="true" coda:inputCollection='=split(approval.missing, ",")' coda:inputElement="input" />
|
|
620
622
|
</userTask>
|
|
621
623
|
<sequenceFlow id="filled" sourceRef="fill" targetRef="merged-inputs" />
|
|
@@ -624,22 +626,26 @@ PR #{{github.event.number}}({{github.event.pull_request.html_url}})已合并
|
|
|
624
626
|
<coda:env name="INPUTS" value="=approval.inputs" />
|
|
625
627
|
<coda:env name="MISSING" value="=approval.missing" />
|
|
626
628
|
<coda:env name="ASKS" value="=approval.asks" />
|
|
627
|
-
<coda:env name="FILLS" value="=fill" />
|
|
628
|
-
<coda:output name="inputs" />
|
|
629
|
+
<coda:env name="FILLS" value="=fill" /><coda:env name="NEEDS" value="=approval.needs" /><coda:env name="ONLY" value="=approval.only" />
|
|
630
|
+
<coda:output name="inputs" /><coda:output name="only" />
|
|
629
631
|
</extensionElements>
|
|
630
632
|
<script>node "${CODA_PLUGIN_PATH}/scripts/approval.mjs" inputs</script>
|
|
631
633
|
</scriptTask>
|
|
632
|
-
<sequenceFlow id="to-run-merged" sourceRef="merged-inputs" targetRef="
|
|
634
|
+
<sequenceFlow id="to-run-merged" sourceRef="merged-inputs" targetRef="left" />
|
|
635
|
+
<exclusiveGateway id="left" name="还有要跑的合并后流程吗" default="left-run" />
|
|
636
|
+
<sequenceFlow id="left-none" sourceRef="left" targetRef="delivered-none"><conditionExpression xsi:type="tFormalExpression">=merged-inputs.only = "[]"</conditionExpression></sequenceFlow>
|
|
637
|
+
<sequenceFlow id="left-run" sourceRef="left" targetRef="run-merged" />
|
|
633
638
|
<serviceTask id="run-merged" name="合并后的流程" coda:action="run-workflows" coda:status="运行合并后的流程">
|
|
634
639
|
<extensionElements>
|
|
635
640
|
<coda:param name="hook" value="merged" />
|
|
636
|
-
<coda:param name="only" value="=
|
|
641
|
+
<coda:param name="only" value="=merged-inputs.only" />
|
|
637
642
|
<coda:param name="commit" value="=github.event.pull_request.merge_commit_sha" />
|
|
638
643
|
<coda:param name="inputs" value="=merged-inputs.inputs" />
|
|
639
644
|
</extensionElements>
|
|
640
645
|
</serviceTask>
|
|
641
646
|
<sequenceFlow id="ran-merged" sourceRef="run-merged" targetRef="delivered" />
|
|
642
647
|
<endEvent id="delivered" coda:status="已合并,合并后的流程已结束" />
|
|
648
|
+
<endEvent id="delivered-none" coda:status="已合并,没有要跑的合并后流程" />
|
|
643
649
|
</subProcess>
|
|
644
650
|
<sequenceFlow id="to-delivered" sourceRef="delivering" targetRef="delivering-done" />
|
|
645
651
|
<endEvent id="delivering-done" coda:notify="=approval.notify" />
|
|
@@ -271,7 +271,7 @@
|
|
|
271
271
|
<extensionElements>
|
|
272
272
|
<coda:env name="APPROVED" value="=approve" /><coda:env name="JOINERS" value="=joiners.list" />
|
|
273
273
|
<coda:output name="at" /><coda:output name="deleteBranch" /><coda:output name="notify" /><coda:output name="what" />
|
|
274
|
-
<coda:output name="only" /><coda:output name="inputs" /><coda:output name="missing" /><coda:output name="asks" />
|
|
274
|
+
<coda:output name="only" /><coda:output name="inputs" /><coda:output name="missing" /><coda:output name="asks" /><coda:output name="needs" />
|
|
275
275
|
</extensionElements>
|
|
276
276
|
<script>node "${CODA_PLUGIN_PATH}/scripts/approval.mjs"</script>
|
|
277
277
|
</scriptTask>
|
|
@@ -300,27 +300,34 @@
|
|
|
300
300
|
<documentation>用户批准合并时勾的流程要一段文字,批准卡上没有写:
|
|
301
301
|
{{split(approval.asks, "\n")[loopCounter]}}
|
|
302
302
|
PR {{pr.url}} 已合并,合并提交 {{merge.commit}}。
|
|
303
|
-
按这次合并进来的改动写这段面向用户的文字(Markdown
|
|
304
|
-
|
|
303
|
+
按这次合并进来的改动写这段面向用户的文字(Markdown,不写内部实现,不用审查意见),备注只放文字本身。
|
|
304
|
+
选「这一项这次不跑」(备注可不写):这段文字不写,要它的流程这次都不跑,其余勾了的照常运行;都不跑了就直接结束。不想发出这段文字、写不出时选它,不要答复 rejected。</documentation>
|
|
305
|
+
<extensionElements><coda:choice id="done" name="已写好" primary="true" note="required" /><coda:choice id="skip" name="这一项这次不跑" /></extensionElements>
|
|
305
306
|
<multiInstanceLoopCharacteristics isSequential="true" coda:inputCollection='=split(approval.missing, ",")' coda:inputElement="input" />
|
|
306
307
|
</userTask>
|
|
307
308
|
<sequenceFlow id="filled" sourceRef="fill" targetRef="merged-inputs" />
|
|
308
309
|
<scriptTask id="merged-inputs" name="整理合并后流程的参数" coda:timeout="5" coda:checkout="false" scriptFormat="bash">
|
|
309
310
|
<extensionElements>
|
|
310
311
|
<coda:env name="INPUTS" value="=approval.inputs" /><coda:env name="MISSING" value="=approval.missing" />
|
|
311
|
-
<coda:env name="ASKS" value="=approval.asks" /><coda:env name="FILLS" value="=fill" />
|
|
312
|
-
<coda:output name="inputs" />
|
|
312
|
+
<coda:env name="ASKS" value="=approval.asks" /><coda:env name="FILLS" value="=fill" /><coda:env name="NEEDS" value="=approval.needs" /><coda:env name="ONLY" value="=approval.only" />
|
|
313
|
+
<coda:output name="inputs" /><coda:output name="only" />
|
|
313
314
|
</extensionElements>
|
|
314
315
|
<script>node "${CODA_PLUGIN_PATH}/scripts/approval.mjs" inputs</script>
|
|
315
316
|
</scriptTask>
|
|
316
|
-
<sequenceFlow id="to-run-merged" sourceRef="merged-inputs" targetRef="
|
|
317
|
+
<sequenceFlow id="to-run-merged" sourceRef="merged-inputs" targetRef="left" />
|
|
318
|
+
<exclusiveGateway id="left" name="还有要跑的合并后流程吗" default="left-run" />
|
|
319
|
+
<sequenceFlow id="left-none" sourceRef="left" targetRef="done-none"><conditionExpression xsi:type="tFormalExpression">=merged-inputs.only = "[]"</conditionExpression></sequenceFlow>
|
|
320
|
+
<sequenceFlow id="left-run" sourceRef="left" targetRef="run-merged" />
|
|
317
321
|
<serviceTask id="run-merged" name="合并后的流程" coda:action="run-workflows" coda:status="运行合并后的流程">
|
|
318
322
|
<extensionElements>
|
|
319
|
-
<coda:param name="hook" value="merged" /><coda:param name="only" value="=
|
|
323
|
+
<coda:param name="hook" value="merged" /><coda:param name="only" value="=merged-inputs.only" />
|
|
320
324
|
<coda:param name="commit" value="=merge.commit" /><coda:param name="inputs" value="=merged-inputs.inputs" />
|
|
321
325
|
</extensionElements>
|
|
322
326
|
</serviceTask>
|
|
323
327
|
<sequenceFlow id="ran-merged" sourceRef="run-merged" targetRef="done" />
|
|
328
|
+
<endEvent id="done-none" name="已合并" coda:status="已合并,没有要跑的合并后流程" coda:notify="=approval.notify">
|
|
329
|
+
<extensionElements><coda:output name="pr" value="=pr.url" /><coda:output name="commit" value="=merge.commit" /><coda:output name="notify" value="=approval.notify" /></extensionElements>
|
|
330
|
+
</endEvent>
|
|
324
331
|
<endEvent id="done" name="已合并" coda:notify="=approval.notify">
|
|
325
332
|
<extensionElements><coda:output name="pr" value="=pr.url" /><coda:output name="commit" value="=merge.commit" /><coda:output name="notify" value="=approval.notify" /></extensionElements>
|
|
326
333
|
</endEvent>
|
package/README.md
CHANGED
|
@@ -45,6 +45,8 @@ prompts/principles/ 评审重点,一项一段,按设置取
|
|
|
45
45
|
|
|
46
46
|
3.0.0 把批准卡上写死的「部署」「发布预览版」「发布正式版」换成挂点 `merged`([Coda #2521](https://github.com/coda-console/coda/issues/2521) 第 4 步):勾选项是项目里加入这个挂点的流程,合并后只运行勾了的;去掉「写更新说明」,加入者要的文字卡上没写时由开 PR 的会话(简易开发是主 Agent)逐项补写。`review.mergeOptions` 只剩 `deleteBranch`、`notify`,原来的 `deploy`、`preview`、`release` 不再认。卡上去掉了说明性的文字,只留做决定用的数据。需要支持 `hook-joiners` 与 `coda:optionList` 的 Coda(协议 5.17.0)。
|
|
47
47
|
|
|
48
|
+
3.2.0 给「填写合并后流程要的文字」加了第二个选项「这一项这次不跑」:不写这段文字,要它的流程这次都不跑,其余勾了的照常运行(下文「挂点 merged」)。
|
|
49
|
+
|
|
48
50
|
## 项目提供的部分
|
|
49
51
|
|
|
50
52
|
插件管流程,项目在自己的仓库里提供四样,跟着代码走:
|
|
@@ -115,7 +117,7 @@ prompts/principles/ 评审重点,一项一段,按设置取
|
|
|
115
117
|
删除用 Git 的 `--force-with-lease=<ref>:<sha>`,推送期间分支变动也不会误删。读取或删除失败会让运行失败,处理后可从失败处继续,之后再运行合并后的流程。
|
|
116
118
|
不勾选时流程不主动删分支;GitHub 仓库自身的「合并后自动删除分支」设置仍独立生效。
|
|
117
119
|
6. **合并后的流程**:合并确认后,勾了的(`approval.only`)在合并提交(`merge_commit_sha`)上用 `run-workflows hook=merged` 运行,参数是卡上写的文字;
|
|
118
|
-
它们要的文字卡上没写的,先交开 PR 的会话「填写合并后流程要的文字」(下文「挂点 merged
|
|
120
|
+
它们要的文字卡上没写的,先交开 PR 的会话「填写合并后流程要的文字」(下文「挂点 merged」)。一个都没勾,或勾了的都被选了「这一项这次不跑」,就直接结束。
|
|
119
121
|
失败时运行失败,结果交回开 PR 的会话,由它查明后手动重跑对应的流程。
|
|
120
122
|
|
|
121
123
|
- PR 在 GitHub 网页上合并或关闭(不经这条运行的「等 GitHub 确认」,也不是上面那种你批准的版本在合并时先送到的关闭),运行随之结束,交出去的任务和卡片撤回,不删除分支、不运行合并后的流程。
|
|
@@ -183,7 +185,7 @@ PR 生命流程与简易开发声明挂点 `merged`:合并后要做的事由
|
|
|
183
185
|
- **加入者带什么**:`name` 是卡上勾选项的名字(不写用流程名),`detail` 一行说明,`default` 是否默认勾(不写为不勾,默认不勾就由加入者这样表达),`order` 排序(小的在前),可选 `inputs`:它要从卡上拿的自己的文字参数(本流程 `type` 为 string 的 `coda:input`,标签取参数的 `label`),如发布说明 `notes`。
|
|
184
186
|
- **卡上**:批准前用 `hook-joiners`(`hook=merged`,`commit` 是要合并的提交)列出加入者,作为「合并」的勾选项,你可以勾任意几个;勾上带 `inputs` 的出现对应的输入框。
|
|
185
187
|
- **合并后**:在合并提交上用 `run-workflows`(`hook=merged`,`only` 是勾了的流程名,`commit` 是合并提交,`inputs` 是卡上写的文字加补写的)运行勾了的,等它们都结束;每个加入者只拿到它声明的参数。没勾任何一个就不调用。
|
|
186
|
-
- **卡上没写的文字**:勾了的加入者要、卡上没写的输入,先交开 PR 的会话(简易开发是主 Agent
|
|
188
|
+
- **卡上没写的文字**:勾了的加入者要、卡上没写的输入,先交开 PR 的会话(简易开发是主 Agent)「填写合并后流程要的文字」,每个输入一张、依次,任务里写明是哪一项、哪几个流程要;「已写好」的备注必填,只附文件没写字时「整理合并后流程的参数」失败并写明是哪一项。选「这一项这次不跑」(备注可不写)是这段文字不写:「整理合并后流程的参数」把所有勾了且要这段文字的加入者(几个加入者共用一段文字,如预览发布与正式发布都要 `notes`,就全部)从 `only` 里去掉,输出新的 `only` 交给 `run-workflows`,其余勾了的照常运行;新的 `only` 为空就不调用 `run-workflows`,运行照常成功结束,状态写「已合并,没有要跑的合并后流程」。
|
|
187
189
|
|
|
188
190
|
## 评审一段提交
|
|
189
191
|
|
package/package.json
CHANGED
package/scripts/approval.mjs
CHANGED
|
@@ -2,23 +2,28 @@
|
|
|
2
2
|
// asking for changes later voids it), and what they chose to follow the merge: `deleteBranch`, `notify`, and the workflows
|
|
3
3
|
// joining the hook `merged` they ticked (JOINERS is the list hook-joiners gave the card): `only`, their names as JSON for
|
|
4
4
|
// run-workflows; `inputs`, the text the card took for them; `missing`, the ids (comma separated) of the inputs they ask
|
|
5
|
-
// for that the card left empty,
|
|
5
|
+
// for that the card left empty, `asks`, a line for each, in the same order, saying which of them asks, and `needs`, for
|
|
6
|
+
// each of those ids the ticked workflows that ask for it (JSON). `what` is the
|
|
6
7
|
// choice as the merge step says it. Put out here, not by the merge step, so that the process follows the choice however it
|
|
7
8
|
// hears of the merge: after the merge step, or from GitHub while that step still runs.
|
|
8
9
|
//
|
|
9
10
|
// With `inputs`, after the merge: what run-workflows gives them, the card's text and what the session wrote for each of
|
|
10
|
-
// `missing` (FILLS, one task each, in order); one written with no text fails the step, naming it.
|
|
11
|
+
// `missing` (FILLS, one task each, in order); one written with no text fails the step, naming it. A text the session
|
|
12
|
+
// answered `skip` for is not written, and every ticked workflow asking for it drops out of `only` (ONLY, NEEDS): the
|
|
13
|
+
// `only` to run, `[]` when none is left.
|
|
11
14
|
import { json, output } from './step.mjs';
|
|
12
15
|
|
|
13
16
|
if (process.argv[2] === 'inputs') {
|
|
14
|
-
const inputs = json('INPUTS', {}), ids = (process.env.MISSING || '').split(',').filter(Boolean);
|
|
15
|
-
const fills = json('FILLS', []), asks = (process.env.ASKS || '').split('\n');
|
|
17
|
+
const inputs = json('INPUTS', {}), ids = (process.env.MISSING || '').split(',').filter(Boolean), needs = json('NEEDS', {});
|
|
18
|
+
const fills = json('FILLS', []), asks = (process.env.ASKS || '').split('\n'), dropped = new Set();
|
|
16
19
|
ids.forEach((id, i) => {
|
|
20
|
+
if (fills[i]?.choice === 'skip') { needs[id].forEach(joiner => dropped.add(joiner)); return; }
|
|
17
21
|
const text = String(fills[i]?.note ?? '').trim();
|
|
18
22
|
if (!text) { console.error(`${asks[i] || id}:没有填写,不运行合并后的流程`); process.exit(1); }
|
|
19
23
|
inputs[id] = text;
|
|
20
24
|
});
|
|
21
25
|
output('inputs', JSON.stringify(inputs));
|
|
26
|
+
output('only', JSON.stringify(json('ONLY', []).filter(id => !dropped.has(id))));
|
|
22
27
|
process.exit(0);
|
|
23
28
|
}
|
|
24
29
|
|
|
@@ -28,7 +33,7 @@ const ticked = json('JOINERS', []).filter(joiner => chosen(joiner.id)), inputs =
|
|
|
28
33
|
for (const joiner of ticked) for (const { id, label } of joiner.inputs ?? []) {
|
|
29
34
|
const text = String(written[id] ?? '').trim();
|
|
30
35
|
if (text) inputs[id] = text;
|
|
31
|
-
else (missing.get(id) ?? missing.set(id, { label, for: [] }).get(id)).for.push(joiner
|
|
36
|
+
else (missing.get(id) ?? missing.set(id, { label, for: [] }).get(id)).for.push(joiner);
|
|
32
37
|
}
|
|
33
38
|
output('at', Date.now());
|
|
34
39
|
output('deleteBranch', chosen('deleteBranch'));
|
|
@@ -36,6 +41,7 @@ output('notify', chosen('notify'));
|
|
|
36
41
|
output('only', JSON.stringify(ticked.map(joiner => joiner.id)));
|
|
37
42
|
output('inputs', JSON.stringify(inputs));
|
|
38
43
|
output('missing', [...missing.keys()].join(','));
|
|
39
|
-
output('asks', [...missing.values()].map(m => `「${m.label}」:${m.for.join('、')}要`).join('\n'));
|
|
44
|
+
output('asks', [...missing.values()].map(m => `「${m.label}」:${m.for.map(joiner => joiner.name).join('、')}要`).join('\n'));
|
|
45
|
+
output('needs', JSON.stringify(Object.fromEntries([...missing].map(([id, m]) => [id, m.for.map(joiner => joiner.id)]))));
|
|
40
46
|
output('what', ['合并', ...(chosen('deleteBranch') ? ['合并后删除远程分支'] : []), ...ticked.map(joiner => joiner.name),
|
|
41
47
|
...(chosen('notify') ? ['全部完成后通知 Agent'] : [])].join(' · '));
|