Jump to content

Tool:Fix Suggester Bot

From Wikitech
Toolforge tools
Fix Suggester Bot
Description Generate fix suggestions using code quality tools, and post suggestions to patches in code review
Keywords bot, code quality
Author(s) Kosta Harlan, Gergő Tisza
Maintainer(s) (View all)
Source code https://gitlab.wikimedia.org/KostaHarlan/fix-suggester-bot/
License GNU General Public License 3.0 or later
Issues Open tasks · Report a bug

A set of scripts running on Toolforge to analyze patches and offer fix suggestions when the patches fail code quality tool analysis.

Code review system / code quality tools
Code review system phpcs eslint

How it works


Two jobs are running in the Toolforge jobs framework environment.

The first one subscribes to "patchset-created" events via Gerrit stream events using an SSH key associated with the Fix Suggester Bot account in Gerrit:

toolforge-jobs run fix-suggester-bot-subscribe --command "php fix-suggester-bot/bin/console fix-suggester-bot:subscribe:gerrit -v" --image php8.2 --continuous

The above command puts the JSON stream message from Gerrit into a MySQL database table.

Another process is responsible for consuming the messages in the queue:

toolforge-jobs run fix-suggester-bot-consume --command "php fix-suggester-bot/bin/console messenger:consume --time-limit=3600 gerrit_async -vv" --image php8.2 --continuous

This command runs configured code quality tools (phpcs, currently) and generates fix suggestions in a JSON file. These are then posted as fix suggestion in Gerrit.

At the moment, it only listens to events for the mediawiki/extensions/GrowthExperiments project. This is defined in the `env.local` file in /data/project/fixsuggesterbot/fix-suggester-bot.

Both commands are configuring using an env.local file in /data/project/fixsuggesterbot/fix-suggester-bot


  • TBD

Source code

Source code: Fix Suggester Bot