diff --git a/ci/azure-pipelines-steps.yml b/ci/azure-pipelines-steps.yml index 7ba89b25f..ee89d24d7 100644 --- a/ci/azure-pipelines-steps.yml +++ b/ci/azure-pipelines-steps.yml @@ -69,11 +69,9 @@ steps: - script: | tox - ls -a .coverage_dir displayName: 'tox' - script: | - pwd - ls -a - codecov --required -t 813fb6da-087d-4b36-a185-5a530cab3455 --file coverage.xml + python3 ci/fix_coverage.py + codecov --required -t 813fb6da-087d-4b36-a185-5a530cab3455 displayName: 'codecov' diff --git a/ci/fix_coverage.py b/ci/fix_coverage.py new file mode 100644 index 000000000..b97e23e3e --- /dev/null +++ b/ci/fix_coverage.py @@ -0,0 +1,29 @@ +""" +Helper script to combine coverage (as codecov seems to have problems...). +Written in python to be cross-plotform +""" + +from os import chdir, listdir +from pathlib import Path +from pprint import pprint +from subprocess import run + +THIS_FILE = Path(__file__) +GIT_MAIN_DIR = THIS_FILE.parent.parent.resolve() +COVERAGE_DIR = GIT_MAIN_DIR.joinpath('.coverage_dir') + +def main(): + chdir(GIT_MAIN_DIR) + print(f"Working in {GIT_MAIN_DIR}, listing coverage dir {COVERAGE_DIR}") + pprint(listdir(COVERAGE_DIR)) + run(['coverage', 'combine'] + + [str(f) for f in COVERAGE_DIR.glob('coverage-*')], + check=True) + print(f"Combined coverage, listing {GIT_MAIN_DIR}") + pprint(listdir(GIT_MAIN_DIR)) + run(['coverage', 'xml'], check=True) + print(f"Created coverage xml, listing {GIT_MAIN_DIR}") + pprint(listdir(GIT_MAIN_DIR)) + +if __name__ == '__main__': + main() diff --git a/tox.ini b/tox.ini index cfd991b26..6e0422b3c 100644 --- a/tox.ini +++ b/tox.ini @@ -30,13 +30,12 @@ commands = test: python -c "import sys; print('64 bit?', sys.maxsize > 2**32)" test: python {toxinidir}/ci/fix_paths.py test: python -m pytest --pyargs h5py --cov=h5py --cov-config={toxinidir}/.coveragerc {posargs} - test: python -m coverage xml -i '{toxinidir}/.coverage_dir/coverage*' -o {toxinidir}/coverage.xml changedir = test: {toxworkdir} passenv = HDF5_DIR setenv = - COVERAGE_FILE={toxinidir}/.coverage_dir/coverage + COVERAGE_FILE={toxinidir}/.coverage_dir/coverage-{envname} # needed otherwise coverage cannot find the file when reporting pip_pre =