Skip to content

An automated code linting bot that integrates various code lint tools with github pull requests.

License

Notifications You must be signed in to change notification settings

adampetrie/lint-review

 
 

Repository files navigation

Lint Review

Lint Review helps automate a tedious part of code review - enforcing coding standards. By using the github API Lint Review runs a repository's configured linters and updates pull requests with line comments where lint errors would be introduced.

Lint Review requires:

  • Python 2.7 (It will probably work in 2.6, but I've only tested 2.7)
  • RabbitMQ (or any other Message broker that is compatible with Celery)
  • A publically addressable hostname/IP that either github or your github:enterprise can reach.
  • A github account with read/write access to the repositories you want linted. This account is used to post comments on pull reviews.

Lint Review runs as two processes. A web process handles accepting webhooks from github, and a celery process handles cloning repositories and running lint tools. You'll also need to have rabbitmq-server running.

What's on this fork?

This fork is a modified version of lintreview that I configured to run on Heroku. Everything else about it is the same as the original lint-review repo. A patch of exactly what changed is included below.

Patch

  From 5aac0c688ec233791f5d3181fc3bdd4d7db96a50 Mon Sep 17 00:00:00 2001
  From: Adam Petrie <adam.petrie@wishabi.com>
  Date: Fri, 11 Mar 2016 09:32:26 -0500
  Subject: [PATCH 1/4] Add cffi to requirements
  
  ---
   requirements.txt | 1 +
   1 file changed, 1 insertion(+)
  
  diff --git a/requirements.txt b/requirements.txt
  index 9184bea..eca31b9 100644
  --- a/requirements.txt
  +++ b/requirements.txt
  @@ -7,3 +7,4 @@ celery==3.0.19
   mock==1.0.1
   gunicorn==0.17.2
   argparse>=1.2.0,<=1.3.0
  +cffi
  
  From f898f1b6e3887efd169f3f8b5a919831bace5627 Mon Sep 17 00:00:00 2001
  From: Adam Petrie <adam.petrie@wishabi.com>
  Date: Fri, 11 Mar 2016 09:46:29 -0500
  Subject: [PATCH 2/4] Add Procfile
  
  ---
   Procfile | 2 ++
   1 file changed, 2 insertions(+)
   create mode 100644 Procfile
  
  diff --git a/Procfile b/Procfile
  new file mode 100644
  index 0000000..cb9a00e
  --- /dev/null
  +++ b/Procfile
  @@ -0,0 +1,2 @@
  +web: gunicorn -c settings.py lintreview.web:app
  +worker: celery -A lintreview.tasks worker
  
  From 04f791f306280f0f7417e8ae4b3f176bbc6ca848 Mon Sep 17 00:00:00 2001
  From: Adam Petrie <adam.petrie@wishabi.com>
  Date: Fri, 11 Mar 2016 10:03:50 -0500
  Subject: [PATCH 3/4] Use celery 3.1.23
  
  ---
   requirements.txt | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
  
  diff --git a/requirements.txt b/requirements.txt
  index eca31b9..1a60280 100644
  --- a/requirements.txt
  +++ b/requirements.txt
  @@ -3,7 +3,7 @@ github3.py==1.0.0a4
   nose==1.2.1
   pep8==1.5.7
   flake8==2.2.2
  -celery==3.0.19
  +celery==3.1.23
   mock==1.0.1
   gunicorn==0.17.2
   argparse>=1.2.0,<=1.3.0
  
  From cbcee1cf231cc07da8cc05645b99ef172e197365 Mon Sep 17 00:00:00 2001
  From: Adam Petrie <adam.petrie@wishabi.com>
  Date: Fri, 11 Mar 2016 19:41:10 -0500
  Subject: [PATCH 4/4] Include setup.py in requirements.txt
  
  ---
   requirements.txt |  1 +
   settings.py      | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   setup.py         |  5 +---
   3 files changed, 92 insertions(+), 4 deletions(-)
   create mode 100644 settings.py
  
  diff --git a/requirements.txt b/requirements.txt
  index 1a60280..08c217a 100644
  --- a/requirements.txt
  +++ b/requirements.txt
  @@ -8,3 +8,4 @@ mock==1.0.1
   gunicorn==0.17.2
   argparse>=1.2.0,<=1.3.0
   cffi
  +-e .
  diff --git a/settings.py b/settings.py
  new file mode 100644
  index 0000000..0165c1f
  --- /dev/null
  +++ b/settings.py
  @@ -0,0 +1,90 @@
  +import os
  +
  +def env(key, default, cast=str):
  +    return cast(os.environ.get(key, default))
  +
  +
  +# Webserver configuration
  +#########################
  +
  +# gunicorn configuration
  +bind = env('LINTREVIEW_GUNICORN_HOST', '127.0.0.1') + ':' + env('PORT', '5000')
  +debug = env('LINTREVIEW_GUNICORN_DEBUG', True, bool)
  +loglevel = env('LINTREVIEW_GUNICORN_LOGLEVEL', 'debug')
  +
  +# Basic flask config
  +DEBUG = env('LINTREVIEW_FLASK_DEBUG', True, bool)
  +TESTING = env('LINTREVIEW_TESTING', True, bool)
  +SERVER_NAME = env('LINTREVIEW_SERVER_NAME', '127.0.0.1:5000')
  +
  +# Celery worker configuration
  +#############################
  +from kombu import Exchange, Queue
  +
  +# AMQP or other celery broker URL.
  +# amqp paths should be in the form of user:pass@host:port//virtualhost
  +BROKER_URL = env('RABBITMQ_BIGWIG_RX_URL', '')
  +
  +# Use json for serializing messages.
  +CELERY_TASK_SERIALIZER = 'json'
  +
  +# Show dates and times in UTC
  +CELERY_ENABLE_UTC = True
  +
  +
  +# General project configuration
  +###############################
  +
  +# Path where project code should be
  +# checked out when reviews are done
  +# Repos will be checked out into $WORKSPACE/$user/$repo/$number
  +# directories to prevent collisions.
  +WORKSPACE = env('LINTREVIEW_WORKSPACE', '/tmp/workspace')
  +
  +# This config file contains default settings for .lintrc
  +# LINTRC_DEFAULTS = './lintrc_defaults.ini'
  +
  +
  +# Github Configuration
  +######################
  +
  +# Use GITHUB_URL when working with github:e
  +GITHUB_URL = env('GITHUB_URL', 'https://api.github.com/')
  +
  +# Github username + password
  +# This is the user that lintreview will use
  +# to fetch repositories and leave review comments.
  +# Set the GITHUB_PASSWORD environment variable first.
  +# example: $ export GITHUB_PASSWORD=mygithubpassword
  +GITHUB_USER = env('GITHUB_USERNAME', '')
  +GITHUB_PASSWORD = env('GITHUB_PASSWORD', '')
  +
  +# You can also use an Oauth token for github, if you do
  +# uncomment this line. Using a token will take precedence
  +# over a username and password.
  +GITHUB_OAUTH_TOKEN = env('GITHUB_OAUTH_TOKEN', None)
  +
  +# Set to a path containing a custom CA bundle.
  +# This is useful when you have github:enterprise on an internal
  +# network with self-signed certificates.
  +SSL_CA_BUNDLE = None
  +
  +# After this many comments in a review, a single summary comment
  +# should be posted instead of individual line comments. This helps
  +# prevent really noisy reviews from slowing down github.
  +SUMMARY_THRESHOLD = env('LINTREVIEW_SUMMARY_THRESHOLD', 50, int)
  +
  +# Status Configuration
  +######################
  +# Customize the build status integration name. Defaults to lintreview.
  +# APP_NAME = 'lintreview'
  +
  +# Uncomment this option to enable adding an issue comment
  +# whenever a pull request passes all checks.
  +# OK_COMMENT = env('LINTREVIEW_OK_COMMENT',
  +#                 ':+1: No lint errors found.')
  +
  +# Enable to apply a label when updating build status.
  +# Pull requests that fail will have the label removed.
  +# Customize the label name when label statuses are enabled.
  +# OK_LABEL = env('LINTREVIEW_OK_LABEL', 'No lint errors')
  diff --git a/setup.py b/setup.py
  index 0dea83b..73e64ee 100644
  --- a/setup.py
  +++ b/setup.py
  @@ -3,8 +3,6 @@
   PACKAGE_NAME = "lintreview"
   VERSION = "0.5.2"
   
  -requirements = open('./requirements.txt', 'r')
  -
   setup(
       name=PACKAGE_NAME,
       version=VERSION,
  @@ -19,6 +17,5 @@
           'console_scripts': [
               'lintreview = lintreview.cli:main',
           ],
  -    },
  -    install_requires=requirements.readlines(),
  +    }
   )

About

An automated code linting bot that integrates various code lint tools with github pull requests.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 98.9%
  • Ruby 1.1%