Add a registry of Review Bot worker tools.

Review Request #11533 — Created March 17, 2021 and submitted — Latest diff uploaded

Information

ReviewBot
release-3.0.x

Reviewers

Review Bot has been heavily dependent on
pkg_resources.iter_entry_points for tool lookup. This is fine to use
for an initial scan, but we were calling it on every tool execution,
which was slow, and made it hard to write unit tests against anything
not provided by a package.

This change introduces a basic tools registry in
reviewbot.tools.base.registry. This handles tool discovery,
registration, unregistration, iteration, and fetching of tools.

Tools are only discovered on startup now, and we fetch directly from the
registry when executing one.

Unit tests were added to cover the new registry functions.

Unit tests pass for Python 2.x and 3.x.

Manually tested starting the worker, loading in the tools list into
Review Board, and running tools against new code.

Diff Revision 2

This is not the most recent revision of the diff. The latest diff is revision 3. See what's changed.

orig
1
2
3

Commits

First Last Summary ID Author
Add a registry of Review Bot worker tools.
Review Bot has been heavily dependent on `pkg_resources.iter_entry_points` for tool lookup. This is fine to use for an initial scan, but we were calling it on every tool execution, which was slow, and made it hard to write unit tests against anything not provided by a package. This change introduces a basic tools registry in `reviewbot.tools.base.registry`. This handles tool discovery, registration, unregistration, iteration, and fetching of tools. Tools are only discovered on startup now, and we fetch directly from the registry when executing one. Unit tests were added to cover the new registry functions.
06a3d3f7d047eb42a3fad78a1b292796cf5d93f7 Christian Hammond
bot/reviewbot/celery.py
bot/reviewbot/tasks.py
bot/reviewbot/tools/base/registry.py
bot/reviewbot/tools/tests/test_registry.py
Loading...