Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix publishing of coverage results to coveralls.io (+ misc test config updates) #890

Merged
merged 7 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
# as the convention.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*is

- 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
2 changes: 2 additions & 0 deletions tests/.coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ omit =
# Command-line scripts.
*/tuf/scripts/client.py
*/tuf/scripts/repo.py
*/tests/*
*/site-packages/*
13 changes: 13 additions & 0 deletions tests/aggregate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from __future__ import division
from __future__ import unicode_literals

import os
import sys
import unittest
import glob
Expand Down Expand Up @@ -90,9 +91,21 @@
random.shuffle(test_modules_to_run)

if __name__ == '__main__':
# NOTE: Temporary workaround to ensure that `tuf` code from the sibling `tuf`
# directory is prioritized over `tuf` code installed to some system or
# virtualenv site-packages directory, which in turn is required for
# coverage/coveralls to function correctly.
# FIXME: Consider refactoring the tests to not require this 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.
sys.path.insert(0,
os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

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
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ envlist = py27, py34, py35, py36
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 =
Expand Down