Skip to content

Commit

Permalink
Add coverage to project reports.
Browse files Browse the repository at this point in the history
  • Loading branch information
kinow committed Oct 23, 2018
1 parent af3c749 commit 4675ac2
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 9 deletions.
84 changes: 84 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# -----------------------------------------------------------------------------
# (C) British Crown Copyright 2012-8 Met Office.
#
# This file is part of Rose, a framework for meteorological suites.
#
# Rose is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Rose is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Rose. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------

# This is the Coverage.py configuration file. This is used by Travis-CI when running
# the tests and collecting coverage

[run]

branch=True
cover_pylib=False
concurrency=thread
data_file=${TRAVIS_BUILD_DIR}/.coverage
disable_warnings=
debug=
# callers
# dataio
# multiprocess
# dataio
# dataop
# pid
# plugin
# process
# sys
# trace
# Include can be used only if source is not used!
#include
note=
omit=
*/lib/python/isodatetime*
parallel = False
plugins=
source=
./bin
./lib/python
timid = False


[report]

exclude_lines =
pragma: no cover
def __repr__
raise NotImplementedError
if __name__ == .__main__.:
def parse_args
fail_under=0
ignore_errors = False
include=
omit=
*/lib/python/isodatetime*
partial_branches=
precision=2
show_missing=False
skip_covered=False
sort=Name


[html]

directory=htmlcov
extra_css=
title=


[xml]

output=coverage.xml
package_depth=99
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ etc/opt
lib/bash/rose_init_site
doc
venv

# coverage
.coverage
.coverage.*
coverage.xml
htmlcov/
22 changes: 13 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ before_install:
- ssh-keygen -t 'rsa' -f "${HOME}/.ssh/id_rsa" -N '' -q
- cat "${HOME}/.ssh/id_rsa.pub" >>"${HOME}/.ssh/authorized_keys"
- ssh-keyscan -t 'rsa' 'localhost' >>"${HOME}/.ssh/known_hosts"
# Coverage dependencies
- pip install coverage pytest-cov

install:
install:
- >
sudo apt-get install -y at build-essential gfortran heirloom-mailx
python-pip python-dev graphviz libgraphviz-dev python-jinja2
Expand All @@ -32,14 +34,16 @@ install:
- sudo apt-get update
- sudo apt-get install -y subversion

script: skip

jobs:
include:
- stage: test
- script: >
rose test-battery --state=save -j 5 ||
(echo -e "\n\nRerunning Failed Tests...\n\n";
rose test-battery -v --state=save,failed -j 5)
- script: >
rose make-docs --venv --dev --strict clean linkcheck doctest html slides latexpdf
- script:
- export COVERAGE_PROCESS_START="${TRAVIS_BUILD_DIR}/.coveragerc"
- export PYTHONPATH="${TRAVIS_BUILD_DIR}/.travis"
- coverage run .travis/cover.py
- unset PYTHONPATH
- script:
- rose make-docs --venv --dev --strict clean linkcheck doctest html slides latexpdf
- after_success:
- coverage xml --ignore-errors
- bash <(curl -s https://codecov.io/bash)
31 changes: 31 additions & 0 deletions .travis/cover.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# (C) British Crown Copyright 2012-8 Met Office.
#
# This file is part of Rose, a framework for meteorological suites.
#
# Rose is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Rose is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Rose. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------

from subprocess import call


def main():
call(
'rose test-battery --state=save -j 5 || (echo -e "\n\nRerunning Failed Tests...\n\n"; rose test-battery -v --state=save,failed -j 5)',
shell=True)


if __name__ == '__main__':
main()
27 changes: 27 additions & 0 deletions .travis/sitecustomize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# (C) British Crown Copyright 2012-8 Met Office.
#
# This file is part of Rose, a framework for meteorological suites.
#
# Rose is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Rose is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Rose. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------

"""This file is used by Travis-CI to start the coverage process. In order to make
Python aware of it, we export PYTHONPATH when running the tests"""


import coverage

coverage.process_startup()

0 comments on commit 4675ac2

Please sign in to comment.