Skip to content

Commit

Permalink
Merge pull request #890 from lukpueh/fix-coveralls
Browse files Browse the repository at this point in the history
Fix publishing of coverage results to coveralls.io (+ misc test config updates)
  • Loading branch information
lukpueh authored Sep 11, 2019
2 parents bafebee + 098769b commit 4fb4cb2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 29 deletions.
40 changes: 20 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
dist: xenial
language: python
dist: trusty
sudo: false
cache: pip
python: 3.6

env:
- TOXENV=py27
- TOXENV=py34
- TOXENV=py36
matrix:
include:
- python: "2.7"
env: TOXENV=py27
- python: "3.4"
env: TOXENV=py34
- python: "3.5"
env: TOXENV=py35
- python: "3.6"
env: TOXENV=py36

before_script:
- pip install pylint bandit tox
install:
- pip install tox coveralls

script:
- pylint tuf
- bandit -r tuf
- tox

after_success:
- cd tests
- coveralls
- cd -

branches:
only:
- develop
- pylint
- bandit
# Workaround to get coverage reports with relative paths.
# FIXME: Consider refactoring the tests to not require the test aggregation
# script being invoked from the `tests` directory, so that `.coverage` is
# written to and .coveragrc can also reside in the project root directory, as
# is the convention.
- cp tests/.coverage .
- coveralls --rcfile=tests/.coveragerc
8 changes: 5 additions & 3 deletions ci-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
securesystemslib[crypto,pynacl]
six
iso8601
coverage
coveralls
pylint
requests
pylint
bandit
# Pin to versions supported by `coveralls` (see .travis.yml)
# https://github.com/coveralls-clients/coveralls-python/releases/tag/1.8.1
coverage<5.0
12 changes: 7 additions & 5 deletions tests/.coveragerc
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
[run]
branch = True

omit =
# Command-line scripts.
*/tuf/scripts/client.py
*/tuf/scripts/repo.py
*/tests/*
*/site-packages/*

[report]
exclude_lines =
pragma: no cover
def __str__
if __name__ == .__main__.:

omit =
# Command-line scripts.
*/tuf/scripts/client.py
*/tuf/scripts/repo.py
1 change: 1 addition & 0 deletions tests/aggregate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
suite = unittest.TestLoader().loadTestsFromNames(test_modules_to_run)
all_tests_passed = unittest.TextTestRunner(
verbosity=1, buffer=True).run(suite).wasSuccessful()

if not all_tests_passed:
sys.exit(1)

Expand Down
11 changes: 10 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@

[tox]
envlist = py27, py34, py35, py36
skipsdist = true

[testenv]
# TODO: Consider refactoring the tests to not require the aggregation script
# being invoked from the `tests` directory. This seems to be the convention and
# would make use of other testing tools such as coverage/coveralls easier.
changedir = tests

commands =
coverage run --source tuf aggregate_tests.py
pylint {toxinidir}/tuf
bandit -r {toxinidir}/tuf
coverage run aggregate_tests.py
coverage report -m --fail-under 97

deps =
-r{toxinidir}/ci-requirements.txt
# Install TUF in editable mode, instead of tox default virtual environment
# installation (see `skipsdist`), to get relative paths in coverage reports
--editable {toxinidir}

install_command = pip install --pre {opts} {packages}

0 comments on commit 4fb4cb2

Please sign in to comment.