Gerrit newcomer bot: one small step to welcome new developers and track their patches
In this post I highlight the process I followed in my work to develop a bot that welcomes new developers and help track their patches in Gerrit, a collaboration tool for reviewing code. Not, just that, but there is slightly more to it.
One of the main problem this bot address is the lack of well-maintained workflow within Wikimedia to monitor new developer patches that land in Gerrit. There do exist some tools that have tried to address this issue earlier as well but have not been of much use in our internal workflow. One of them is the analytics tool Bitergia that we use for collecting and analyzing community metrics. Though Bitergia supposedly provides names of authors who submit their first changeset but being blocked by a technical dependency, in its current state it wasn’t of much help. Another solution that exists is in the form of a script which generates open changesets by newbie owner on MediaWiki.org. However, the changesets weren’t getting updated regularly and also due to the nature of the results; it didn’t provide an option to filter patches by a specific date range.
An easy solution would have been either waiting for the technical blocker to get resolved on Bitergia or improve the existing script that populates a list of changesets on MediaWiki.org. In both scenarios, a crucial user experience caveat gets in the way. It is a challenge for code reviewers to navigate between the two platforms used for monitoring patches (Gerrit and Bitergia/MediaWiki).
Andre Klapper and I brainstormed for quite a while and then came up with this conclusion — it is not worth building a third tool and a completely new workflow that is tied to a single person’s account and needs certain rights to get access to it. Instead, it is worthwhile investigating the possibility of a dashboard or workflow that we could integrate with Gerrit itself.
I researched existing solutions developed by other open source organizations and ended up exploring the approaches built by OpenStack and LibreOffice. OpenStack’s tool Jeepyb is a collection of tools that make use of Gerrit for their community easier. Within this collection is a script welcome_message.py that adds a “Welcome! New Contributor” as one of the ‘reviewers’ to the new patch in Gerrit submitted by a first-time contributor and also a welcome message as a comment to the patch itself. Also, LibreOffice has a set of queries for querying newcomer patches. This seemed pretty interesting!
Learning from these two approaches, we developed a newcomer bot for Gerrit and a process around it that serves our needs as follows:
1) Welcomes a first-time contributor by adding a “Welcome, new contributor” as a reviewer and the following message to their patch:
Thank you for making your first contribution to Wikimedia! :) To learn how to get your code changes reviewed faster and more likely to get accepted, read https://www.mediawiki.org/wiki/Gerrit/Code_review/Getting_reviews. To explore more newcomer friendly projects, read https://www.mediawiki.org/wiki/New_Developers. We look forward to your next patch submission in Gerrit!
2) Add contributors with less than five patches in Gerrit to a group called “Newcomers”. With this it becomes possible to query those patches in Gerrit by typing in the search terms:
- First time contributors:
reviewer:Welcome, new contributor!https://gerrit.wikimedia.org/r/#/q/reviewer:%22Welcome%252C+new+contributor!%22
- New contributors with five patches in total:
3) Utilizing the capabilities that bot added along with the existing ones in Gerrit, we documented other queries on MediaWiki.org that help find newcomer patches in Gerrit telling more about their code review and verified status. In addition, we now also send a weekly email to our community mailing list pointing to these patches that need code review help!
Here’s a link to the code repo: https://github.com/wikimedia/labs-tools-gerrit-newcomer-bot. If you’ve any questions on how to plug this into your Gerrit, ping me!