Add test coverage support

- Split out requirements in two files
  (testing and main)

- Add Bash script running test with coverage

- Add .coveragerc configuration file,
  including Django coverage plugin

- Add post-build to Travis script running CodeCov
This commit is contained in:
Jean-Fred Berthelot 2016-12-20 17:38:22 +00:00 committed by Jean-Frédéric
parent f337b79643
commit a68c2f6b5d
6 changed files with 32 additions and 3 deletions

6
.coveragerc Normal file
View File

@ -0,0 +1,6 @@
[run]
branch = True
plugins =
django_coverage_plugin
omit = *migrations*

View File

@ -20,4 +20,9 @@ before_script:
script: script:
- tox - tox
- docker-compose run web python manage.py test cabot - docker-compose run web bash bin/test_with_coverage
after_success:
- pip install codecov
- pip install django_coverage_plugin==1.3.1
- codecov

View File

@ -23,7 +23,8 @@ RUN ln -s `which nodejs` /usr/bin/node
RUN pip install --upgrade pip RUN pip install --upgrade pip
COPY requirements.txt ./ COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt COPY requirements-dev.txt ./
RUN pip install --no-cache-dir -r requirements-dev.txt
COPY requirements-plugins.txt ./ COPY requirements-plugins.txt ./
RUN pip install --no-cache-dir -r requirements-plugins.txt RUN pip install --no-cache-dir -r requirements-plugins.txt

14
bin/test_with_coverage Normal file
View File

@ -0,0 +1,14 @@
#!/bin/bash
set -x
output_dir='test-results'
mkdir -p $output_dir
coverage run --source="./cabot/" manage.py test
status=$?
coverage report --omit="cabot/cabotapp/tests*"
coverage xml --omit="cabot/cabotapp/tests*" -o $output_dir/coverage.xml
coverage html --omit="cabot/cabotapp/tests*" -d $output_dir/htmlcov/
exit $status

4
requirements-dev.txt Normal file
View File

@ -0,0 +1,4 @@
-r requirements.txt
coverage==4.2
django_coverage_plugin==1.3.1
mock==1.0.1

View File

@ -21,7 +21,6 @@ gunicorn==18.0
gevent==1.0.1 gevent==1.0.1
httplib2==0.7.7 httplib2==0.7.7
icalendar==3.2 icalendar==3.2
mock==1.0.1
psycogreen==1.0 psycogreen==1.0
psycopg2==2.5.1 psycopg2==2.5.1
pytz==2014.10 pytz==2014.10