coviolations.io - violations for ci¶
coviolations.io - tool for collecting and visualisation code violations works with travis-ci, drone.io and jenkins.
For using it with your projects you need to enable project on coviolations.io and create .covio.yml file.
.covio.yml file¶
In this file you need to specifie project name and violations. Example for django project:
violations:
pep8: pep8 . --exclude='*migrations*'
sloccount: sloccount .
You can use full-length violation declaration:
violations:
pep8: pep8 . --exclude='*migrations*'
pip_review:
command: pip-review
nofail: true
nofail - set force success status to violation.
Using with travis ci¶
For covio add in section after_success:
after_success:
- pip install coviolations_app
- covio
For using pep8 add to section before_install:
before_install:
- pip install pep8
For using sloccount add to section before_install:
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq sloccount
Example travis-ci config:
language: python
python:
- "2.7"
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq sloccount
- pip install pep8
install:
- npm install -g bower
- pip install -U -r requirements.txt
script:
- ./manage.py test violations projects tasks services app
after_success:
- covio
Using with drone.io¶
At the end of project script add
pip install coviolations_app
COVIO_TOKEN="token" covio
Replace token with project token from project page.
Example project script config:
sudo apt-get update -qq
sudo apt-get install -qq sloccount
pip install pep8
pip install -U -r requirements.txt
nosetests 2>test_out
COVIO_TOKEN="token" covio
Using with jenkins¶
At the end of project script add
pip install coviolations_app
COVIO_TOKEN="token" covio
Replace token with project token from project page.
With jenkins you need install dependencies manual.
Available violations¶
PEP8¶
Check your Python code against some of the style conventions in PEP 8.
.covio.yml:
violations:
pep8: pep8 . --exclude='*migrations*'
For travis-ci in .travis.yml:
before_install:
- pip install pep8
after_success:
- covio
For drone.io and jenkins in project script:
pip install pep8
COVIO_TOKEN="token" covio
sloccount¶
Count source lines of code (SLOC).
.covio.yml:
violations:
sloccount: sloccount .
For travis-ci in .travis.yml:
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq sloccount
after_success:
- covio
For drone.io and jenkins in project script:
sudo apt-get update -qq
sudo apt-get install -qq sloccount
COVIO_TOKEN="token" covio
Python unittests¶
The Python unit testing framework, sometimes referred to as “PyUnit,” is a Python language version of JUnit, by Kent Beck and Erich Gamma. JUnit is, in turn, a Java version of Kent’s Smalltalk testing framework. Each is the de facto standard unit testing framework for its respective language.
.covio.yml:
violations:
py_unittest: cat test_out
For travis-ci in .travis.yml with nose:
before_install:
- pip install nose
script:
- nosetests 2>test_out
after_success:
- covio
For travis-ci in .travis.yml with django:
script:
- ./manage.py test 2>test_out
after_success:
- covio
For drone.io and jenkins in project script with nose:
pip install nose 2>test_out
COVIO_TOKEN="token" covio
For drone.io and jenkins in project script with django:
./manage.py test 2>test_out
COVIO_TOKEN="token" covio
pip-review¶
Keeps your Python package dependencies pinned, but fresh.
.covio.yml:
violations:
pip_review: pip-review
For travis-ci in .travis.yml:
before_install:
- pip install pip-tools
after_success:
- covio
For drone.io and jenkins in project script:
pip install pep-tools
COVIO_TOKEN="token" covio
testem¶
Unit testing in Javascript can be tedious and painful, but Testem makes it so easy that you will actually want to write tests.
.covio.yml:
violations:
testem: cat testem_out
For travis-ci in .travis.yml:
script:
- testem ci > testem_out
after_success:
- covio
For drone.io and jenkins in project script:
testem ci > testem_out
COVIO_TOKEN="token" covio
coverage¶
Measure, collect, and report on code coverage in Python programs.
.covio.yml:
violations:
coverage: coverage report
For travis-ci in .travis.yml:
before_install:
- pip install coverage
after_success:
- covio
For drone.io and jenkins in project script:
pip install coverage
COVIO_TOKEN="token" covio
jslint¶
The JavaScript Verifier takes a JavaScript source and scans it.
.covio.yml:
violations:
jslint: jslint *.js
For travis-ci in .travis.yml:
before_install:
- npm install jslint
after_success:
- covio
For drone.io and jenkins in project script:
npm install jslint
COVIO_TOKEN="token" covio
xunit¶
Example configurations¶
Some example configurations.
Django project with travis-ci¶
We want use pep8, sloccount, python unittests, coverage and pip-review violations.
.travis.yml:
language: python
python:
- "2.7"
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq sloccount
- pip install pep8 pip-tools coviolations_app coverage
script:
- coverage run manage.py test 2>test_result
after_script:
- coverage report
- covio
.covio.yml:
violations:
pep8: pep8 . --exclude='*migrations*,*settings*,*components*,*docs*'
sloccount: sloccount .
py_unittest: cat test_result
coverage: coverage report
pip_review:
command: pip-review
nofail: true
We add nofail to pip_review, because we don’t need to mark task failed if we have outdated packages.
Django project with jenkins or drone.io¶
Run script:
pip install pep8 pip-tools coviolations_app coverage
coverage run manage.py test 2>test_result
coverage report
COVIO_TOKEN='' covio
You can obtain token on project page.
.covio.yml:
violations:
pep8: pep8 . --exclude='*migrations*,*settings*,*components*,*docs*'
py_unittest: cat test_result
coverage: coverage report
pip_review:
command: pip-review
nofail: true
Python project with nose with travis-ci¶
.travis.yml:
language: python
python:
- "2.7"
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq sloccount
- pip install pep8 pip-tools coviolations_app coverage
script:
- nosetests --with-coverage 2>test_result
after_script:
- coverage report
- covio
.covio.yml:
violations:
pep8: pep8 . --exclude='*migrations*,*settings*,*components*,*docs*'
sloccount: sloccount .
py_unittest: cat test_result
coverage: coverage report
pip_review:
command: pip-review
nofail: true
Python project with nose with jenkins or drone.io¶
Run script:
pip install pep8 pip-tools coviolations_app coverage
nosetests --with-coverage 2> test_result
coverage report
COVIO_TOKEN='' covio
You can obtain token on project page.
.covio.yml:
violations:
pep8: pep8 . --exclude='*migrations*,*settings*,*components*,*docs*'
py_unittest: cat test_result
coverage: coverage report
pip_review:
command: pip-review
nofail: true
JavaScript project with testem with travis-ci¶
We want use testem and jslint.
.travis.yml:
language: node_js
python:
- "2.7"
node_js:
- "0.10"
before_install:
- npm install testem jslint
- pip install coviolations_app
script:
- testem>test_result
after_script:
- covio
.covio.yml:
violations:
testem: cat test_result
jslint: jslint *.js
JavaScript project with testem with jenkins or drone-io¶
Run script:
npm install testem jslint
pip install coviolations_app
testem>test_result
COVIO_TOKEN='' covio
.covio.yml:
violations:
testem: cat test_result
jslint: jslint *.js