Use Fabric in travis and insert a fabfile for developers

This commit is contained in:
Norman Jäckel 2013-04-16 00:19:59 +02:00
parent 329e488cf2
commit b9d4af7de7
3 changed files with 61 additions and 8 deletions

View File

@ -2,11 +2,5 @@ language: python
python: python:
- "2.6" - "2.6"
- "2.7" - "2.7"
install: install: "pip install -r requirements.txt --use-mirrors"
- pip install -r requirements.txt --use-mirrors script: "fab travis_ci"
- python extras/scripts/create_local_settings.py
script:
- export DJANGO_SETTINGS_MODULE=tests.settings
- coverage run ./manage.py test tests && coverage report -m
- pep8 --max-line-length=150 --exclude="urls.py," --statistics openslides
- pep8 --max-line-length=150 --statistics tests

58
fabfile.py vendored Normal file
View File

@ -0,0 +1,58 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Fabric file for OpenSlides developers.
:copyright: 20112013 by OpenSlides team, see AUTHORS.
:license: GNU GPL, see LICENSE for more details.
"""
import os
import webbrowser
from fabric.api import local
from fabric.contrib import django
def test(module='tests'):
"""
Runs all unit tests for OpenSlides using coverage. The settings file
in the tests directory is used, therefor the environment
variable DJANGO_SETTINGS_MODULE is set to 'tests.settings'.
"""
django.settings_module('tests.settings')
local('coverage run ./manage.py test %s' % module)
def coverage():
"""
Runs all tests and builds the coverage html files. The index of these
files is opened in the end.
"""
test()
local('coverage html')
webbrowser.open(os.path.join(os.path.dirname(__file__), 'htmlcov', 'index.html'))
def pep8():
"""
Checks for PEP 8 errors in openslides and in tests.
"""
local('pep8 --max-line-length=150 --exclude="urls.py," --statistics openslides')
local('pep8 --max-line-length=150 --statistics tests')
def prepare_commit():
"""
Does everything before a commit should be done. At the moment it
does the same as travis_ci()
"""
travis_ci()
def travis_ci():
"""
Command that is run by Travis CI.
"""
test()
pep8()

View File

@ -6,6 +6,7 @@ reportlab==2.7
tornado==3.0.1 tornado==3.0.1
# required for travis # required for travis
Fabric==1.6.0
coverage==3.6 coverage==3.6
django-discover-runner==0.3 django-discover-runner==0.3
pep8==1.4.5 pep8==1.4.5