2e4e05cfc0
* Compare issues with known ones in the backend * rebase * Update list_repo_issues helper * Fix issues grouping by path * Cache Issue hash computed value * Repport issues that are tagged as new * Update publication * Add a comment section for issues outside the diff * Publish issues inside or outside the patch in two similar sections of the Phabricator comment * Only publish new issues to harbormaster * Improve message for known issues * Always refer to issues as 'defects' in Phabricator comment * Fix Phabricator publish return value * Make sure to run before/after on all the diffs of a revision * Only store new issues in bot's backend while runing before/after * Group in and out issue main comments * Preserve original publications (remove known issues footer) * Update existing tests * Add tests * Use a cached prop for issues' hash Define local repository in runtime settings * Fix before after random check for a revision * Suggestions * Use itertools.groupby or paths lookup * Improve RNG seed comment * Always compare issues that are found inside the diff * Raise error to sentry when GECKO_BASE_REV is unset on the decision task * Disable before/after for a non published revision * Override runtime local repository setting * Do not display existing issues stats |
||
---|---|---|
.. | ||
code_review_bot | ||
docker | ||
tests | ||
tools | ||
.dockerignore | ||
README.md | ||
VERSION | ||
requirements-dev.txt | ||
requirements.txt | ||
setup.py | ||
taskcluster-hook.json |
README.md
Static Analysis Bot
Developer setup
The code review bot is a Python 3 application, so it should be easy to bootstrap on your computer:
mkvirtualenv -p /usr/bin/python3 code-review
pip install -r requirements.txt -r requirements-dev.txt
pip install -e .
You should now be able to run linting and unit tests:
flake8
pytest
If those tests are OK, you can run the bot locally, by using a local configuration file with your Phabricator API token (see details at the end of this README), and a task reference to analyze.
export TRY_TASK_ID=XXX
export TRY_TASK_GROUP_ID=XXX
code-review-bot --configuration=path/to/config.yaml
Configuration
The code review bot is configured through the Taskcluster secrets service or a local YAML configuration file (the latter is preferred for new contributors as it's easier to setup)
The following configuration variables are currently supported:
APP_CHANNEL
[required] is provided by the common configuration (staging or production)REPORTERS
[required] lists all the reporting tools to use when a code review is completed (details below)PHABRICATOR
[required] holds the credentials to make API calls on Phabricator.ZERO_COVERAGE_ENABLED
is a boolean value enabling or disabling the zero coverage warning report.PAPERTRAIL_HOST
is the optional Papertrail host configuration, used for logging.PAPERTRAIL_PORT
is the optional Papertrail port configuration, used for logging.SENTRY_DSN
is the optional Sentry full url to report runtime errors.
The REPORTERS
configuration is a list of dictionaries describing which reporting tool to use at the end of the patches code review.
Supported reporting tools are emails (for admins) and Phabricator.
Each reporter configuration must contain a reporter
key with a unique name per tool. Each tool has its own configuration requirement.
You can view a full configuration sample here.
Phabricator credentials
They are required, and must be set like this:
PHABRICATOR:
url: 'https://phabricator.services.mozilla.com/api/'
api_key: api-XXXX
Reporter: Mail
Key reporter
is mail
The emails are sent through Taskcluster notify service, the hook must have notify:email:*
in its scopes (enabled on our staging & production instances)
Only one configuration is required: emails
is a list of emails addresses receiving the admin output for each analysis.
This reporter will send detailed information about every issue.
Reporter: Phabricator
Key reporter
is phabricator
Configuration:
analyzers_skipped
: The analyzers that will not be published on Phabricator.
This reporter will send detailed information about every publishable issue.
Example configuration
---
common:
APP_CHANNEL: development
PHABRICATOR:
url: https://dev.phabricator.mozilla.com
api_key: deadbeef123456
bot:
REPORTERS:
- reporter: phabricator