Page MenuHomePhabricator

[wm-checks-api] support kindrobot
Closed, ResolvedPublic

Description

@SDunlap wrote a robot reporting to Gerrit. It is used to do end-to-end testing of WikiLambda

Example reports: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikiLambda/+/891656

Some documentation: https://people.wikimedia.org/~kindrobot/duct/presentation.html

We should integrate the report in Gerrit Checks API.

Message are tagged with autogenerated:e2e and originate from real_author.username='aw-gitlab-bot'

Event Timeline

I appreciate the support! Perhaps if you're going to integrate this into the Gerrit Checks API, we should have a quick think about what this will look like if (hopefully when) this gets scaled to other teams.

I'm not sure if it makes more sense for there to be:

  1. one instance of this bot per team
    1. in which case there would probably be different tags and real_author.usernames
    2. does that create more work for the Gerrit Checks API to support it?
  2. one instance for all teams
    1. which I'm not a huge fan of at the moment because I'm trying to build the ethos of teams controlling their own CI destiny on GitLab)
  3. or some hybrid where there are multiple instances that share the credentials

For options two and three, the real_author.username would probably be something more generic like, gitlab-reporter and the tag would probably be autogenerated:gitlab-ci-results. I'm not sure if you'd have any thoughts @hashar .

I'd rather share the credentials and use a single account for that robot. That sounds easier to have only one account reporting to Gerrit which I think will make it easier to lookup the robot doc, find the point of contact if there is an issue etc. It also simplify adding another instance since you don't need to create a new account or having to add it to Gerrit Service Users group.

Each message in Gerrit is a ChangeMessageInfo, the TypeScript API for Gerrit version 3.5 can be read at https://gerrit.wikimedia.org/r/plugins/gitiles/operations/software/gerrit/+/refs/heads/stable-3.5/polygerrit-ui/app/api/rest-api.ts#434

/**
 * The ChangeMessageInfo entity contains information about a message attached
 * to a change.
 * https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#change-message-info
 */
export declare interface ChangeMessageInfo {
  id: ChangeMessageId;
  author?: AccountInfo;
  reviewer?: AccountInfo;
  updated_by?: AccountInfo;
  real_author?: AccountInfo;
  date: Timestamp;
  message: string;
  accounts_in_message?: AccountInfo[];
  tag?: ReviewInputTag;
  _revision_number?: PatchSetNum;
}

The Checks API has a TypeScript definition is at https://gerrit.googlesource.com/gerrit/+/master/polygerrit-ui/app/api/checks.ts )

The integration is about adjusting the JavaScript code I wrote https://gerrit.wikimedia.org/g/operations/software/gerrit/+/refs/heads/deploy/wmf/stable-3.5/plugins/wm-checks-api.js . It merely crawls through the messages (which are instances of ChangeMessageInfo) then create a CheckResult which Gerrit then render in the Check tab of the change.

In the JavaScript we can use real_author.username='aw-gitlab-bot' for any instance/teams, render that in the UI as End-to-End, potentially rely on the tag to differentiate different instance if the report has to vary, but I would imagine all instances will report with more or less the same message.

There is a bot for which I just copy the whole message as is T330850#8664535 :)

I will see at crafting a preliminary version and surely I should revisit the documentation so that others can "easily" adjust the JavaScript.

(you could name it DUCT) that is an excellent robot name, then aw-gitlab-bot is fine as well, it is merely an implementation detail.

This task prompted me to document how to add a bot account for Gerrit and some hint about the Checks UI https://wikitech.wikimedia.org/wiki/Gerrit/Bot_account

An update: I haven't forgotten about this patch. Beside a long range of other duties, I have picked the integration of Patch demo first since it seemed reasonably easy. In a couple hour I had something pleasant enough. As a teaser T332474#8874936

Change 923688 had a related patch set uploaded (by Hashar; author: Hashar):

[operations/software/gerrit@deploy/wmf/stable-3.5] wm-checks-api: add support for DUCT

https://gerrit.wikimedia.org/r/923688

I have done the implementation :)

Example rendering on https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikiLambda/+/904804 which has a failure:


duct_run.png (312×578 px, 39 KB)
The run is named DUCT E2E cause picking names is hard and Gerrit requires something more specific than End-to-end. That does not show much information beside the summary and when the run has completed.


duct_result.png (235×716 px, 35 KB)
In the result tab is show the summary and the links extracted from Results: and Environment. The later looks like some wiki name, I prefix it with https:// to make it a link. Of course if the env has vanished, that would yield a 404.

duct_pan_pan.png (177×782 px, 32 KB)
On https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikiLambda/+/923669 I noticed another kind of message:

PAN-PAN: end-to-end deploy stage failed

I have amended the implementation to only require Results: and this way it captures the PAN-PAN message (as an error).


Side note: since the bot contributes to the Verified label it is showing in the result. But jenkins-bot voted Verified+2 and somehow there is a bug in Gerrit which make it display V+2 while that bot voted V-1. I think they expected each bot to vote under their own label.

Change 923688 merged by jenkins-bot:

[operations/software/gerrit@deploy/wmf/stable-3.5] wm-checks-api: add support for DUCT

https://gerrit.wikimedia.org/r/923688

Mentioned in SAL (#wikimedia-operations) [2023-05-30T11:14:02Z] <hashar@deploy1002> Started deploy [gerrit/gerrit@6deabc9]: wm-checks-api: add support for DUCT - T331651

Mentioned in SAL (#wikimedia-operations) [2023-05-30T11:14:10Z] <hashar@deploy1002> Finished deploy [gerrit/gerrit@6deabc9]: wm-checks-api: add support for DUCT - T331651 (duration: 00m 08s)

hashar claimed this task.

I have deployed it, please reopen the task if there is something off or needs to be tweaked :]