-
Notifications
You must be signed in to change notification settings - Fork 119
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
Clean up coverage generation and reporting in tox & travis. #187
Conversation
Add [report] section.
* twistedchecker-diff shouldn't be in default envlist, as it only works in CI. * "trial" envs now just run trial. "coverage" envs run trial under coverage. * Clean up coverage runs so that we aren't littering the source tree with a bunch of .coverage.* files. * Add coverage_combine env which gathers coverage from other runs and reports on the total result. * Add codecov env to publish to codecov. Change Travis config: * Use "coverage" envs. * Publish to codecov after each test run, instead of one combined publish if they all succeed.
Codecov Report
@@ Coverage Diff @@
## master #187 +/- ##
==========================================
- Coverage 95.89% 95.84% -0.05%
==========================================
Files 12 12
Lines 1558 1542 -16
Branches 86 86
==========================================
- Hits 1494 1478 -16
Misses 52 52
Partials 12 12
Continue to review full report at Codecov.
|
Ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand the intent of these changes. I've made a couple of notes, but could you just write up a brief description about the intended structure here?
tox.ini
Outdated
trial-py{27,py,34,35,36}-tw{155,166,current,trunk} | ||
coverage-py{27,py,34,35,36}-tw{155,166,current,trunk} | ||
|
||
coverage_combine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including this in the envlist
is bad because that means it gets run in some random order in both tox
with no arguments and detox
with no arguments (where it's actively harmful). You can still run it with tox -e
without putting it in the envlist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really? When I run tox
with no arguments, it always runs them in a fixed order, and combine runs last. I haven't noticed this randomization…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glyph: Yeah, it runs strictly in the intended order. Are you sure it's random for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I didn't realize tox
actually ran the environments in order. Nevertheless, detox
runs them all at the same time, so this is still a bad idea ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in 657da86
tox.ini
Outdated
|
||
docs, docs-linkcheck | ||
|
||
skip_missing_interpreters = True | ||
|
||
|
||
## | ||
# Default testenv | ||
# Build (default environment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this comment change. Arguably the comment should just be deleted since it doesn't say much, but this is not a "build" now, is it? it's still a test env. Builds are done with setup.py wheel
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in 77390bb
tox.ini
Outdated
coverage: coverage | ||
|
||
|
||
whitelist_externals = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bad idea because it makes the tests hard to run on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tox.ini
Outdated
|
||
passenv = | ||
PATH | ||
LANG LC_ALL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to do localized testing? What is the purpose of passing LANG?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hold over from another thing, removing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in f02c021
tox.ini
Outdated
coverage: COVERAGE_FILE={toxworkdir}/coverage/coverage.{envname} | ||
{coverage_combine,codecov}: COVERAGE_FILE={toxworkdir}/coverage/coverage | ||
|
||
{coverage,coverage_combine}: COVERAGE_HTML={envlogdir}/coverage_report_html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be .html
rather than _html
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's a directory name
tox.ini
Outdated
coverage: cp "{env:COVERAGE_FILE}" "{envlogdir}/coverage" | ||
|
||
# Run coverage reports, ignore exit status | ||
coverage: - coverage html --rcfile="{toxinidir}/.coveragerc" -d "{env:COVERAGE_HTML}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage reporting is really slow, and should almost always be done only after a coverage combine
. definitely we shouldn't be generating both HTML and XML reports on every travis run, where they're just going to be thrown away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm. It takes pretty consistently a bit under 0.4s on my laptop to run coverage html and alittle over 0.4s to run coverage xml.
The reason it's don't done here after a combine is to make it easy to check coverage for each run separately. With Klein that doesn't very much (at all, last I checked), so that's not a big deal.
It'll be easy enough to make it separate, so I'll do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 6bcccb1
tox.ini
Outdated
coverage combine --append | ||
|
||
# Copy aside coverage data for each test environment in case we want to look at it later | ||
cp "{env:COVERAGE_FILE}" "{envlogdir}/coverage" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this just copy the coverage file from the coverage_combine
environment? i.e. nothing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you run coverage_combine
, the source files are deleted. This sets them aside in case you need to look at the coverage for a specific run after having run coverage_combine
(eg. tox
with no arguments). It's not critical, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in 7aac72d
tox.ini
Outdated
|
||
# Generate XML and publish to codecov.io | ||
# Ignore errors generating coverage XML, which may be due to < 100% coverage; we still want to publish | ||
- coverage xml --rcfile="{toxinidir}/.coveragerc" -o "{env:COVERAGE_XML}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this line start with a dash but the next one doesn't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents tox
from erroring out if this exits with an error due to insufficient coverage; we still want to proceed to invoking codecov
(the next line) in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see @glyph already asked for changes, so I just added a few more notes.
.gitignore
Outdated
@@ -1,11 +1,7 @@ | |||
*.pyc | |||
_trial_temp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's hard to tell which parts of this diff are spurious and which are actual change. can you keep the old order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, it's not that big a file, and I don't think it helped that much, but re-ordered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reordered in 3e7d556
tox.ini
Outdated
trial: trial --random=0 --logfile="{envlogdir}/trial.log" --temp-directory="{envlogdir}/trial.d" {posargs:klein} | ||
|
||
coverage: mkdir -p "{toxworkdir}/coverage" | ||
coverage: coverage run --rcfile="{toxinidir}/.coveragerc" "{envdir}/bin/trial" --random=0 --logfile="{envlogdir}/trial.log" --temp-directory="{envlogdir}/trial.d" {posargs:klein} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're explicitly passing in --rcfile, I see no reason to name the file ".coveragerc" and thus make it harder to find.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's just what the file has always been called. I don't have any trouble finding it, but I'm happy to rename it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed in d44dc11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I should have replied initially:
.coveragerc
is the official / standard name of this file - see the docs at http://coverage.readthedocs.io/en/coverage-4.4.1/config.html . coverage.conf
is some random thing we just made up. I would much rather not rename it.
tox.ini
Outdated
- coverage xml --rcfile="{toxinidir}/.coveragerc" -o "{env:COVERAGE_XML}" | ||
|
||
# Don't ignore exit status here; this is our failure status if coverage is insufficient. | ||
coverage report --rcfile="{toxinidir}/.coveragerc" --omit "*/test/*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually prefer to put the --fail-under here, so it's more obvious what conditions we use for failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I buy that.
This has a side effect I somehow didn't consider, which is that I don't need to ignore exit status so much in the tox file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in bc03700
Ready for review again. @glyph: Summary of changes posted at the top; sorry I didn't do that at the outset. |
tox.ini
Outdated
|
||
passenv = | ||
PATH | ||
CI CONTINUOUS_INTEGRATION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see anything in this changeset which references these. Are they for Hypothesis in #181?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah
Lemme break this into parts… |
Summary of what's changing here:
tox.ini
:coverage_combine
that combines coverage data and fails if coverage is incomplete.codecov
environment for publishing to Codecov.travis.yml
:.coveragerc
is nowcoverage.conf
:[report]
section, now that reports are generated in the Tox config.gitignore
:.tox