blob: 968adcc29ebcfd64b2170d69582d84904a26d91b [file] [log] [blame]
Ben Rohlfsab7fbbf2021-04-29 10:27:03 +02001:linkattrs:
2= Gerrit Code Review - JavaScript Plugin Checks API
3
4This API is provided by link:pg-plugin-dev.html#plugin-checks[plugin.checks()].
5It allows plugins to contribute to the "Checks" tab and summary:
6
7image::images/user-checks-overview.png[width=800]
8
9Each plugin can link:#register[register] a checks provider that will be called
10when a change page is loaded. Such a call would return a list of `Runs` and each
11run can contain a list of `Results`.
12
Frank Borden6545f3b2022-12-02 12:45:20 +010013`Results` messages will render as markdown. It follows the
14[CommonMark](https://commonmark.org/help/) spec except inline images and direct
15HTML are not rendered and kept as plaintext.
16
Ben Rohlfsab7fbbf2021-04-29 10:27:03 +020017The details of the ChecksApi are documented in the
18link:https://gerrit.googlesource.com/gerrit/+/master/polygerrit-ui/app/api/checks.ts[source code].
19Note that this link points to the `master` branch and might thus reflect a
20newer version of the API than your Gerrit installation.
21
22If no plugins are registered with the ChecksApi, then the Checks tab will be
23hidden.
24
25You can read about the motivation, the use cases and the original plans in the
26link:https://www.gerritcodereview.com/design-docs/ci-reboot.html[design doc].
27
28Here are some examples of open source plugins that make use of the Checks API:
29
Orgad Shaneh18408fb2024-01-10 15:48:37 +020030* link:https://gerrit.googlesource.com/plugins/checks/+/master/web/plugin.ts[Gerrit Checks Plugin]
Josip Sokcevicbe8d63d2022-03-30 11:35:04 -070031* link:https://chromium.googlesource.com/infra/gerrit-plugins/buildbucket/+/main/web/plugin.ts[Chromium Buildbucket Plugin]
32* link:https://chromium.googlesource.com/infra/gerrit-plugins/code-coverage/+/main/web/plugin.ts[Chromium Coverage Plugin]
Ben Rohlfsab7fbbf2021-04-29 10:27:03 +020033
34[[register]]
35== register
36`checksApi.register(provider, config?)`
37
38.Params
39- *provider* Must implement a `fetch()` interface that returns a
40 `Promise<FetchResponse>` with runs and results. See also documentation in the
41 link:https://gerrit.googlesource.com/gerrit/+/master/polygerrit-ui/app/api/checks.ts[source code].
42- *config* Optional configuration values for the checks provider.
43
44[[announceUpdate]]
45== announceUpdate
46`checksApi.announceUpdate()`
47
48Tells Gerrit to call `provider.fetch()`.
Ben Rohlfsa1bcad72023-11-03 15:35:41 +010049
50[[updateResult]]
51== updateResult
52`checksApi.updateResult(run: CheckRun, result: CheckResult)`
53
54Updates an individual result. This can be used for lazy laoding detailled
55information. For example, if you are using the
56link:pg-plugin-endpoints.html#_check_result_expanded[`check-result-expanded`
57endpoint], then you can load more result details when the user expands a result
58row.
59
60The parameter `run` is only used to *find* the correct run for updating the
61result. It will only be used for comparing `change`, `patchset`, `attempt` and
62`checkName`. Its properties other than `results` will not be updated.
63
64For us being able to identify the result that you want to update you have to
65set the `externalId` property. An undefined `externalId` will result in an
66error.
67
68An example usage can be found in link:https://chromium.googlesource.com/infra/gerrit-plugins/buildbucket/+/main/web/checks-result.ts[Chromium Buildbucket Plugin].