Files
gem5/util/gerrit-bot
Hoa Nguyen dbe4ab5c0f util: Add a gerrit bot
This bot utilizes the Gerrit REST API to query for new changes
made to Gerrit within a certain amount of time and performs a set
of tests on the changes.

Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Change-Id: I9d5af31d952bc0cd791f1569e6aac7c270e687e4
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34737
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2020-11-26 08:07:03 +00:00
..
2020-11-26 08:07:03 +00:00
2020-11-26 08:07:03 +00:00
2020-11-26 08:07:03 +00:00
2020-11-26 08:07:03 +00:00
2020-11-26 08:07:03 +00:00
2020-11-26 08:07:03 +00:00

Gerrit Bot

Getting Username and Password

  • Follow this link https://gem5-review.googlesource.com/new-password and copy the authenticating script to a file, supposedly gerrit_auth_script.

  • After that, run the extract_gitcookies.py to extract the username and password from the obtained script. For example, the following command extracts the username and password from gerrit_auth_script and writes them to GEM5_BOT_AUTH_INFO,

python3 extract_gitcookies.py gerrit_auth_script GEM5_BOT_AUTH_INFO

The GEM5_BOT_AUTH_INFO will have two lines: the first line contains the username and the second line is the corresponding password. Notes:

  • The above link, https://gem5-review.googlesource.com/new-password, generates a new pair of username and password per visit.
  • The extract_gitcookies.py file is also able to read from .gitcookies file. For example, python3 extract_gitcookies.py ~/.gitcookies output will write all pairs of username and password in two lines per pair to output.
  • The gerrit-bot only reads the pair of username and password appearing in the first and the second line in the GEM5_BOT_AUTH_INFO file.

Gerrit Bot

Notes: this is likely to be changed.

The idea of implementing the bot is as follows,

  • The Configs class should contain all constants that are configurable prior to running.
  • Classes such as LabelInfo and ReviewInput are simplied versions resembling those data structures of the same name according to the Gerrit REST API documentation.
  • In the class GerritRestAPIRequester,
    • The __generate_*_request() functions should be a one-to-one function to a set of Gerrit REST API endpoints. The functions should generate a requests.Request object.
    • The send_*() functions are adapted to a more specific use case.

Gerrit API

Appendix I. extract_gitcookies.py

This script extracts all pairs of username and password from the gerrit authentication script from a file or a .gitcookies file.

The usage of the script is as follows,

python3 extract_gitcookies.py input_path output_path

Appendix II. MAINTAINERS.json

This file should be consistent with the file MAINTAINERS.