Continuous Integration, and Continuous Deployment for Python

Scrutinizer works well for Python code. We automatically infer a default build configuration for you, you can tweak this default configuration via a .scrutinizer.yml file that you place in your project's root folder.

Python Version

Scrutinizer uses virtualenv to create an isolated Python environment. We either use Python 2.7.7 or Python 3.5 whatever seems better.

We have many Python versions pre-installed. You can set a specific version in your .scrutinizer.yml:

build:
    environment:
        python: stackless-3.3.5

If you need a different Python version, let us know.

Dependencies

Scrutinizer automatically installs your dependencies using pip or distutils. You can also add custom commands to your .scrutinizer.yml:

build:
    dependencies:
        before:
            - pip install abc

Databases

We provide several databases and queues including MySQL, PostgreSQL, and RabbitMQ pre-installed, if you like you can also install custom software in your build environment.

Testing

Scrutinizer will automatically try to infer your test commands. We support running tests via tox, nosetests, or manage.py in case you are using Django.

You can override the default test commands in your .scrutinizer.yml file:

build:
    tests:
        override:
            - ./run-tests.sh

Code Coverage

By default, we will automatically generate code coverage for your tests. If you change the test commands, you can also generate code-coverage manually. Your configuration could look like this:

build:
    tests:
        override:
            -
                command: './run-tests.sh'
                coverage:
                    file: '.coverage'
                    config_file: '.coveragerc'
                    format: 'py-cc'

Scrutinizer will automatically process your coverage data and also merge it in case you run your tests in parallel, and also provide graphs that plot its evolution over time. See our code coverage overview page for other languages.

Deployment

Scrutinizer provides first-class support for deployment. Once all your tests have passed, it will automatically trigger deployment of your code. You can define deploy commands in your .scrutinizer.yml file:

build:
    deployment:
        -
            branch: master          # you can use either the full branch name,
            branch: feature_*       # an asterisc for e.g. any feature branches
            branch: /feature_.*/    # or the same as a regular expression
            commands:
                - cd deploy && fab deploy

Automated Reviews

Scrutinizer supports a wide-range of automated checks for Python code including code rating, code metrics, duplicate code detection, and many more. A basic configuration which enables code rating and duplicate code detection looks like this:

checks:
    python:
        code_rating: true
        duplicate_code: true

Learn more about configuring automated code reviews for Python.