I have a buildspec
file like this:
version: 0.2
phases:
install:
commands:
- pip install pytest
- pip install pytest-cov
- pip install .
build:
commands:
- python -m pytest --junitxml=unittests.xml
reports:
unit_tests:
files:
- unittests.xml
file-format: JUNITXML
which builds successfully and I can view my report under Report groups
as expected.
Now I would like to extend it and also see the coverage using the option --cov-report
. I tried
version: 0.2
phases:
install:
commands:
- pip install pytest
- pip install pytest-cov
- pip install .
build:
commands:
- python -m pytest --junitxml=unittests.xml --cov-report=xml:coverage.xml
reports:
unit_tests:
files:
- unittests.xml
file-format: JUNITXML
coverage_tests:
files:
- coverage.xml
file-format: COBERTURAXML
but without success. I get the output:
generated xml file: /codebuild/output/<removed>/unittests.xml
... <skipped a few lines here>
Report export config is NO_EXPORT, skip exporting reports
Preparing to copy CODE_COVERAGE report coverage_tests
Expanding base directory path: .
Assembling file list
Expanding .
Expanding file paths for base directory .
Assembling file list
Expanding coverage.xml
Skipping invalid file path coverage.xml
No matching report paths found
Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED
Phase context status code: Message:
Error in UPLOAD_ARTIFACTS phase: [coverage_tests: [report files not
found in build]]
How can I create the report properly?
As pointed out by @TeejayBruno in the comments, I missed the required flag.
When I use (rest of the file unchanged)
- python -m pytest --junitxml=unittests.xml --cov-report=xml --cov=ronwo --cov-branch
everything works as expected.