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 + Virtualenv¶
Scrutinizer uses virtualenv
by default to create an isolated Python environment. If no explicit version is
configured, we will automatically determine a version based on your project structure and usage of Python language
features each time an inspection is run.
We have many Python versions pre-installed, but you can configure any released Python version supported by pyenv in your configuration.
build:
environment:
python:
version: stackless-3.3.5
# Whether to setup a virtual environment in the repository root directory.
# Defaults to true if omitted.
virtualenv: true
Dependencies¶
Scrutinizer automatically installs your dependencies using pip
or distutils
. You can also add
custom commands to your configuration:
build:
nodes:
my-tests:
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 configuration file:
build:
nodes:
my-tests:
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:
nodes:
my-tests-with-coverage:
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 configuration file:
build:
nodes:
deploy:
requires:
- branch: master # you can use either the full branch name,
- branch: /feature_.*/ # or a regular rexpression
- node: my-tests # only run if my-tests node has succeeded
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
build:
nodes:
analysis:
tests:
override:
- py-scrutinizer-run
Learn more about configuring automated code reviews for Python.