Reviewer bot for WMF's Gerrit
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore new pywikibot checkout dir Aug 1, 2016
LICENSE Add explicit license Feb 13, 2013
README.md README formatting Oct 18, 2016
add_reviewer.py Make regexps more resilient Apr 28, 2018
api_result New reviewer list format: one page with templates Dec 28, 2012
gerrit_rest.py Add user agent to REST agent Jun 29, 2014
id_rsa.pub Use local id_rsa Dec 27, 2012
l10n-test Ignore L10n-bot commits Dec 29, 2012
pop3bot.py Add more detailed logging on failure Apr 28, 2018
pywikibot Rework pywikibot dir (pywikibot/ needs to be importable) Jul 31, 2016
requirements use requests[security] Aug 1, 2016
run_bot Fix git checkout, make sure to checkout 2.0 branch Jul 31, 2016
run_pop3_bot new pywikibot checkout dir Aug 1, 2016
stream-bug-example + better debug output Jan 2, 2013
stream-events-example Added more testing & docs Dec 28, 2012
test.py Add DEBUG logging to help testing Aug 23, 2014
user-config.py

README.md

Gerrit reviewer bot for WMF's Gerrit.

This bot reads reviewers from https://www.mediawiki.org/wiki/Git/Reviewers and adds them to changes in Gerrit.

Changes are read from SSH ('add_reviewers.py') or POP3 ('pop3bot.py').

Development

virtualenv --system-site-packages reviewer-bot && cd reviewer-bot
source bin/activate
git clone http://github.com/valhallasw/gerrit-reviewer-bot src
cd src
pip install -r requirements
git clone https://gerrit.wikimedia.org/r/pywikibot/core pywikibot
cd pywikibot && git checkout 2.0

Then, to test:

$ python test.py Ic1250e94c2cbbd3cdc7f1f593be0e204bf735877
Processing changeset  Ic1250e94c2cbbd3cdc7f1f593be0e204bf735877 Moved to TWN, test whether the deployment really works... by Merlijn van Deen
  test.i18n.txt
Suggested reviewers:  ['siebrand', 'Sumanah']

The main algorithm for determining reviewers is the ReviewerFactory in add_reviewer.py. gerrit_rest.py contains basic functionality for accessing the Gerrit REST API. pop3bot.py reads Gerrit mails from a POP3 mailbox, retrieves the corresponding changes using the REST API, determines reviewers using the ReviewerFactory and finally adds reviewers via SSH.

Changes in the ReviewerFactory can best be tested using test.py, as above. If more information is required from Gerrit, try to do this using options to the /changes/ REST API.

Usage/deployment

First, copy reviewer-bot's id_rsa and config.py to the working directory. Then:

source bin/activate
python pop3bot.py

Config.py is a simple file containing

username = 'gmailusername@gmail.com'
password = 'whateveryourpasswordis'

(the gmail pop server is hard-coded at the moment)

This will start a single run. Wrap it in a loop with a sleep or use cron to use it constantly.