The following command was run: ``` pre-commit run --all-files ``` This ensures all the files in the repository are formatted to pass our checks. Change-Id: Ia2fe3529a50ad925d1076a612d60a4280adc40de Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/62572 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
2.5 KiB
Gerrit Bot
Getting Username and Password
Gerrit REST API uses the account username and password for the authentication purpose. They are necessary to make a request.
The following are steps to obtain the username and password from .gitcookies
files,
-
Follow this link https://gem5-review.googlesource.com/new-password and copy the authenticating script to a new file.
-
After that, run the
extract_gitcookies.pyto extract the username and password from the authenticating script. For example, the following command extracts the username and password fromgerrit_auth_scriptand writes them to.data/auth,
python3 extract_gitcookies.py gerrit_auth_script .data/auth
The .data/auth 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.pyfile is also able to read from.gitcookiesfile. For example,python3 extract_gitcookies.py ~/.gitcookies outputwill write all pairs of username and password in two lines per pair tooutput. - The gerrit-bot only reads the pair of username and password appearing
in the first and the second line in the
.data/authfile.
Gerrit Bot
The structure of the Gerrit bot is as follows:
- The
GerritBotConfigclass should contain all constants that are configurable prior to running.
Gerrit API
- Query options: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#query-options
Deployment
The Gerrit bot is intended to be run as a cron job. Each run of the Gerrit bot will query new changes made to the Gerrit server within a certain period of time, perform actions on each change, and exit.
The following are steps to deploy the Gerrit bot:
- Create
.datafolder in the same folder asbot.py,
mkdir .data
-
Follow the steps here to get the Gerrit bot account username and password.
-
To run the Gerrit bot once,
./bot.py
- To edit the cron table,
crontab -e
To run the Gerrit bot every 30 minutes, add the following line to the crontable,
*/1 * * * * cd /path/to/gerrit/bot/directory && ./bot.py