let notification flows start from submitted pull request reviews
This commit is contained in:
parent
31f8a521e0
commit
dd2f0d3ece
7 changed files with 142 additions and 11 deletions
|
|
@ -420,7 +420,8 @@ itself, all under `https://<swarm.domain>/webhook/forge/`:
|
|||
- an instance-wide `pull_request_review_request` system hook, which starts
|
||||
the [review classifier](review-classifier.md#trigger-and-lifecycle)
|
||||
- instance-wide `issues` + `issue_assign` and `pull_request` +
|
||||
`pull_request_assign` + `pull_request_sync` system hooks, whose deliveries it
|
||||
`pull_request_assign` + `pull_request_sync` + `pull_request_review_approved` +
|
||||
`pull_request_review_rejected` + `pull_request_review_comment` system hooks, whose deliveries it
|
||||
keeps in the `SWARM_EVENTS` stream for the
|
||||
[notification router](notify-router.md#the-path)
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,9 @@ router notices an unassign only on an issue it has seen an assign event for.
|
|||
|
||||
1. swarm-controller registers two instance-wide hooks, one for the `issues`
|
||||
and `issue_assign` events at `/webhook/forge/issues` and one for
|
||||
`pull_request`, `pull_request_assign` and `pull_request_sync` (a push to an
|
||||
open PR's branch) at `/webhook/forge/pull-request`. At each start it adds
|
||||
`pull_request`, `pull_request_assign`, `pull_request_sync` (a push to an
|
||||
open PR's branch) and the submitted-review events `pull_request_review_approved`,
|
||||
`pull_request_review_rejected` and `pull_request_review_comment` at `/webhook/forge/pull-request`. At each start it adds
|
||||
any of these events a registered hook lacks.
|
||||
2. On each delivery the controller checks the HMAC and publishes the body,
|
||||
unchanged, to the `SWARM_EVENTS` stream on
|
||||
|
|
@ -90,8 +91,8 @@ switched off, and the custom flows. Only the controller writes it, through
|
|||
`GET` and `PUT /api/notify/flows`. A `PUT` replaces the whole document in one
|
||||
compare-and-set. The controller answers 400 unless every flow passes the tree
|
||||
check above and reads only what exists: a source event from `issues`,
|
||||
`issue_assign`, `pull_request`, `pull_request_assign` or `pull_request_sync`,
|
||||
and condition and recipient fields from the event's field list. The same goes for the `{field}`
|
||||
`issue_assign`, `pull_request`, `pull_request_assign`, `pull_request_sync` or one of the
|
||||
three `pull_request_review_*` events, and condition and recipient fields from the event's field list. The same goes for the `{field}`
|
||||
placeholders in a todo's key and text. A `PUT` must carry the `revision` it read, `0` for no
|
||||
document, and gets 409 when the stored revision is another. Swarm UI's
|
||||
[`/notifications`](ui.md#notification-flows) page shows the document and
|
||||
|
|
@ -156,6 +157,21 @@ its own request queue, which replaces a waiting request for the same PR. A
|
|||
repo the classifier's account can't read, or a PR that account opened, answers
|
||||
`error:`.
|
||||
|
||||
**Reviews as a source.** A submitted review arrives as a pull request
|
||||
payload: `pull_request` and `repository` as for any PR event, `action` is
|
||||
`reviewed`, and `sender` is the reviewer. Approving, requesting changes and
|
||||
commenting are three event types, so a flow picks the verdict with its source
|
||||
and reads the reviewer with a condition on `sender`. A flow that asks argus to
|
||||
review once the classifier has approved:
|
||||
|
||||
| node | setting |
|
||||
| ---------------- | ----------------------------------- |
|
||||
| source | `pull_request_review_approved` |
|
||||
| match | `sender` equals `review-classifier` |
|
||||
| request_reviewer | `reviewer` = `argus` |
|
||||
|
||||
The skip rule above applies: the router asks for argus's review once per head.
|
||||
|
||||
**What the router runs.** It reads the key at most every 10 seconds, when an
|
||||
event arrives, and runs the built-ins you left on, then the custom flows that
|
||||
are on and pass the tree check. It logs a custom flow that fails the check,
|
||||
|
|
|
|||
Loading…
Reference in a new issue