Closed pjhoberman closed 2 months ago
Can this be related to using coverage -a
https://coverage.readthedocs.io/en/latest/cmd.html ? It seems like the repositories which combine coverage from multiple individual runs using the append
option are the ones which can no longer be read by coveralls
.
One way to fix it is using coverage xml
before calling the action. That solved the issue for me.
This is how our circleci config looks relevant to tests:
# Run tests
- run:
name: Run tests
command: |
echo "==========================================================="
echo "Gather the unit test files."
echo "-----------------------------------------------------------"
TESTFILES=$(circleci tests glob "src/**/test_*.py")
echo "Munge the test files into unique, sorted lines in a file."
echo $TESTFILES | tr ' ' '\n' | sort | uniq > circleci_test_files.txt
echo "-----------------------------------------------------------"
echo "Ask CircleCI to split the tests by previous timings."
echo " (this is a feature of their parallelism tools)"
TESTFILES=$(circleci tests split --split-by=timings circleci_test_files.txt)
echo "Split test files:"
echo $TESTFILES
echo "-----------------------------------------------------------"
echo "Make the test filenames Python modules to pass to the test runner."
TEST_MODULES=$(echo $TESTFILES | sed "s+src/++g" | tr "/" "." | sed "s+\.py++g")
echo "-----------------------------------------------------------"
echo "Test the following modules:"
echo $TEST_MODULES
echo "-----------------------------------------------------------"
python -m coverage run --source=src -m discovery.manage test --verbosity 2 $TEST_MODULES
echo "-----------------------------------------------------------"
- coveralls/upload:
parallel: true
flag_name: test1
verbose: true
# Run coverage report for Coveralls
- run:
name: Generate Coverage Report for Coveralls
command: |
python -m coverage lcov
- store_test_results:
path: coverage/results
upload-coverage:
executor: node/default
steps:
- coveralls/upload:
parallel_finished: true
carryforward: test1
@pjhoberman based on your config above, I sent you some workaround steps in our existing email thread.
But for the benefit of other readers here...
The error you're getting is not related to the version of Coverage Reporter anymore (we believe that previous issue was fixed with the release of 0.6.10
).
Instead, Coverage Reporter is choking on your .coverage
file, for two (2) reasons:
pytest-cov
parser has had trouble parsing that fairly nonstandard .coverage
file format - Rather than being a text file, the .coverage
file is a SQLite3 database, and, as coverage.py seems to also be pushing some boundaries around future coverage types, it is both a difficult to parse format and changing over time. So, we have stopped trying to parse that file altogether and are following what appears to be the current "canonical" approach (according to several implementations we've seen), which is to convert the .coverage
file to (cobertura-format) XML using the coverage xml
command (per the README), and then sending that format report through to our cobertura
parser. (See below for how to use cobertura
format instead of lcov
if you care to.)coverage_format:
input option - Without using this input option to specify which format of coverage report the Coverage Reporter should look for, it will look for, and try to parse, all coverage reports of any format it finds. This is a problem---or at least redundant---when you have the same report in two different formats in your environment, which you seem to (.coevrage
and lcov
). But, in short, the way to avoid trying to parse the .coverage
report is to specify coverage_format: lcov
in your input options.You can fix this in one (1) step:
coverage_format: lcov
to your input options, per the change below: - coveralls/upload:
coverage_format: lcov
parallel: true
flag_name: test1
verbose: true
# Run coverage report for Coveralls
- run:
name: Generate Coverage Report for Coveralls
command: |
python -m coverage lcov
- store_test_results:
path: coverage/results
upload-coverage:
executor: node/default
steps:
- coveralls/upload:
parallel_finished: true
carryforward: test1
Or you can even take the more "canonical" approach I mention above and convert your .coverage
file to (cobertura) XML, which seems to be the most reliable conversion.
That would take two (2) steps:
coverage_format: cobertura
to your input options.coverage
to xml
with coverage xml
Per the following changes:
- coveralls/upload:
coverage_format: cobertura
parallel: true
flag_name: test1
verbose: true
# Run coverage report for Coveralls
- run:
name: Generate Coverage Report for Coveralls
command: |
python -m coverage xml
- store_test_results:
path: coverage/results
upload-coverage:
executor: node/default
steps:
- coveralls/upload:
parallel_finished: true
carryforward: test1
(Note that the coverage_format:
for (Cobertura) XML is cobertura
, as opposed to xml
.)
Hope that helps.
If that fixes your problem, feel free to close this issue since, as I say, it's not related to the version of Coverage Reporter, and we don't believe there are any issues with 0.6.10
(which is still the latest version).
P.S. I just noticed you seem to be specifying a storage location for your reports, per:
- store_test_results:
path: coverage/results
So, to proactively avoid issues, or if Coverage Reporter appears to have any trouble finding your reports, you can use the coverage_file
or input option (described here) to tell Reporter where to find the exact file(s) you want to upload.
@afinetooth thanks for this. Resolved.
What was wrong?
I'm not able to upload the report using the 0.6.10 version that was just released.
Logs
Similar to https://github.com/coverallsapp/coverage-reporter/issues/119, but with the new version. This started happening for us yesterday (April 18, 2024).