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

update tox/travis to check code coverage on py3 #1471

Merged
merged 8 commits into from
Mar 5, 2015

Conversation

mmerickel
Copy link
Member

Coverage is combined between py2 and py3 for an aggregate coverage
metric. This means we can stop putting "no cover" gates around py3 code
and ignoring whether it's ever tested.

This is the best way I could find to do this based on several resources [1,2]. I'd be ecstatic if someone has a cleaner way. The only negative I see of this approach is running the tests one final time to dump xunit and coverage.xml files.

Fixes #1470.

[1] http://blog.ionelmc.ro/2014/05/25/python-packaging/
[2] https://github.com/tuskar/python-tuskarclient/blob/master/tox.ini

coverage is combined between py2 and py3 for an aggregate coverage
metric. This means we can stop putting "no cover" gates around py3 code
and ignoring whether it's ever tested.
@tseaver
Copy link
Member

tseaver commented Nov 22, 2014

The report env is failing -- we aren't getting 100% coverage of all those lines previously skipped due to pragma: no cover.

@mmerickel
Copy link
Member Author

Damn it passed locally but it might be running differently on travis. Time to investigate.

@mmerickel
Copy link
Member Author

Yeah so, I'm not sure how to get around this issue. Each sub-job is executed in its own sandbox on travis in parallel so they cannot share the coverage file.

@mmerickel
Copy link
Member Author

The best way I can think of to get around this is to create one final job that does this. So each individual job does not run coverage and goes quickly. Then there is a final job that runs "TOXENV=clean,py26,py32,cover" or something like that. What do you think @tseaver? This seems reasonable to me.

@tseaver
Copy link
Member

tseaver commented Dec 1, 2014

You have to have coverage enbaled during the py26 and py27 runs, too.

@mmerickel
Copy link
Member Author

@tseaver That's correct but I could send that in as a separate env option like WITH_COVERAGE. I've seen that done on some of the originally linked templates. Or just define a py26_cover and py32_cover.

@mmerickel
Copy link
Member Author

I'm open to some alternatives but this latest push 14126ca has the following outputs:

  • coverage-py26.xml, nosetests-py26.xml
  • coverage-py27.xml, nosetests-py27.xml
  • coverage-py32.xml, nosetests-py32.xml
  • coverage.py33.xml, nosetests-py33.xml
  • coverage.py34.xml, nosetests-py34.xml
  • coverage.pypy.xml, nosetests-pypy.xml
  • coverage.pypy3.xml, nosetests-pypy3.xml
  • coverage.xml (an aggregate of the project that is at 100%)

Main change required to our jenkins box is to read nosetests-py26.xml instead of nosetests.xml because that one is not generated any longer (it was always just py26 but the name has changed).

Advantages:

  • We no longer use nosexcover. Less dependencies.
  • Uncovered some test fixtures that weren't being used due to better output.
  • Aggregate report of 100% coverage with far fewer "no cover" pragmas.
  • We are now incentivized to get coverage to 100% in modules that are not compat.py to improve specific-version output.

Disadvantages:

  • The individual coverage reports are not at 100% which can be annoying when running in a dev environment. Developers would need to learn to run tox -e py26,py32,cover to get a total. I think this is fine.
  • Coverage seems to run pretty slow on pypy.

@tseaver
Copy link
Member

tseaver commented Feb 19, 2015

LGTM overall. I think I would prefer to make py27 the "canonical" PY2 version at this point, but we can tweak that later.

@mmerickel
Copy link
Member Author

I've thought about this a bit and the main change I want to make before this is merged is that the tests run dog-damn slow on travis when running coverage. I don't have a good idea how to fix it though. Tentative idea is:

  • Turn off tests for most envs.
  • Run final (slow) test on just py26,py32,cover with an env variable to turn on coverage.

@mmerickel
Copy link
Member Author

@tseaver can you please re-evaluate this based on my latest changes? Minus some quirks on tox syntax I'm pretty happy with this configuration. The outputs are the following:

  • nosetests-py26.xml
  • nosetests-py27.xml
  • nosetests-py32.xml
  • nosetests-py33.xml
  • nosetests-py34.xml
  • nosetests-pypy.xml
  • nosetests-pypy3.xml
  • coverage-py2.xml
  • coverage-py3.xml
  • coverage.xml (an aggregate of the project that is at 100%)

@mmerickel
Copy link
Member Author

@mcdonc
Copy link
Member

mcdonc commented Mar 4, 2015

I have no problem with any of this.

@mmerickel
Copy link
Member Author

@mcdonc jenkins will have to be fixed to use nosetests-py27.xml

From what I have read at some point you can actually have jenkins use multiple xml files to combine the results, but I cannot verify this.

mmerickel added a commit that referenced this pull request Mar 5, 2015
update tox/travis to check code coverage on py3
@mmerickel mmerickel merged commit 6c1a1c6 into master Mar 5, 2015
@mmerickel mmerickel deleted the feature.py3-coverage branch March 5, 2015 16:28
@tseaver
Copy link
Member

tseaver commented Mar 9, 2015

Jenkins did break. I tweaked its config to look for nosetests-py27.xml, and re-ran to ensure it succeeds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update tests to check coverage of py3 code instead of setting "no cover"
3 participants