Installation

Versions

We recommend you to use the stable version unless you want to contribute.

Stable version

kwalitee is on PyPI so all you need is:

$ pip install --user kwalitee

Development version

$ git clone https://github.com/inveniosoftware/kwalitee
$ cd kwalitee
$ pip install --user -r requirements.txt

Installation of the command-line interface

Kwalitee can be used as a Command-line interface, which has some handy features like the githooks and the Messages checks.

By default the messages checks will try to use GitPython but we are recommending you to install and use pygit2. As, it has not stable version yet, the installation requires some work.

Ubuntu

$ sudo apt-add-repository ppa:dennis/python
$ sudo apt-get update
$ sudo apt-get install python-dev libffi-dev libgit2
$ pip install cffi pygit2

If you don’t find a suitable version using ppa:dennis/python, you can always install it manually via cmake.

OSX

The important detail here is to use the same version for libgit2 and pygit2. Homebrew is a way to get it working.

$ brew update
$ brew install libgit2 # currently 0.21.0 (2014-07-28)
$ pip install pygit2

Deployment of the web server

kwalitee is composed of a WSGI server and a worker to handle the long tasks asynchronously.

Requirements

  • A WSGI web server, we recommend nginx + uWSGI but anything may do. Apache + mod_wsgi is working as well.
  • A Redis server.

Configuration

There are not many things you have to configure on a fresh installation, here are the few you should be aware of.

ACCESS_TOKEN

Is the API token for your user on Github. You need it in order to be able to publish comments and statuses.

It can be defined per account as well. See: Command-line interface and kwalitee.models.Account.

AUTO_CREATE

Unless AUTO_CREATE is set to true, you’ll have to enable the repositories individually to authorize events from Github.

$ kwalitee repository add invenio/test
invenio/test is now allowed to webhook kwalitee!

WSGI application

The web application can be served using nginx + uWSGI or gunicorn.

Development server

Using Flask Script’s Server, you can run it without any external servers or libraries.

$ kwalitee runserver

uWSGI

This configuration file will serve the applicatino on port 8000.

; uwsgi.ini
[uwsgi]

http = 0.0.0.0:8000
master = true

processes = 4
die-on-term = true
vaccum = true
max-requests = 100

chdir = <VIRTUALENV>/opt/kwalitee
virtualenv = <VIRTUALENV>
module = kwalitee.wsgi:application
touch-reload = uwsgi.ini

enable-threads = true

And start it this way.

$ uwsgi --init uwsgi.ini

See more on uWSGI documentation.

nginx + uWSGI

TODO

Worker

A simple way to run the worker is the following. It works well for development and/or debug purposes. Consider relying on a deamon supervisor like: upstart, systemd, runit or supervisord.

$ python -m kwalitee.worker

Upstart (Ubuntu)

The worker can also be handled using upstart. Here is the configuration for it. VirtualEnv is a clean way to set everything up and is recommended.

# /etc/init/<myservice>.conf
description "Kwalitee RQ worker"

respawn
respawn limit 15 5
console log
setuid <USER>
setgid <GROUP>

exec /usr/bin/python -m kwalitee.worker
# Or if you've set it up in a virtualenv
#exec <VIRTUALENV>/bin/python -m kwalitee.worker

Then, you can manage it using upstart like anything else.

$ sudo start <myservice>
$ sudo stop <myservice>