MishaKav / pytest-coverage-comment

Comments a pull request with the pytest code coverage badge and full report
MIT License
181 stars 60 forks source link

Add support to coverage XML file. #59

Closed xportation closed 2 years ago

xportation commented 2 years ago

Hi, the coverage output wasn't working for my project, the build wasn't failing. I'm proposing to support also the coverage XML file. Depending on the file extension, the coverage choose the TXT or the XML report.

MishaKav commented 2 years ago

@xportation Thanks for the PR, it's a little big one, I will check it and let you know.

xportation commented 2 years ago

Thanks, @MishaKav. I tried to separate the report logic from the parsers. The coverage.js is responsible for the report while the parse.js continue parsing the TXT console output and the parseXml.js parses the XML.

hammersbaldthegodofimpacience commented 2 years ago

Hello,

thanks for the nice work. We would like to use this project but requiring the coverage import from XML. Will the PR be merged?

paulotruta commented 2 years ago

Supporting XML would be an amazing addition.

I'm running a mono-repo and I tried using this action with a .coverage file resulting from the coverage combine command of multiple coverage runs, but I'm getting the following error:

Error: Error: coverage file "*********" has bad format or wrong data

I can correctly produce .xml or .lcov files using coverage xml and coverage lcov respectively, so I'm having trouble understanding why this error happens and if other format would do a better job.

MishaKav commented 2 years ago

I will take a look at how to parse coverage from XML in the next few days.

hammersbaldthegodofimpacience commented 2 years ago

Any updates here? Can we somehow support for that?

MishaKav commented 2 years ago

@xportation huge thanks for the contribution, I merged your changes, fixed bugs and adopted them to all new changes.

now you can all pass coverage.xml path like:

- name: Pytest coverage comment
  uses: MishaKav/pytest-coverage-comment@main
  with:
    pytest-xml-coverage-path: ./coverage.xml
MishaKav commented 2 years ago

@paulotruta I will be glad if you can test new version of the action:

- name: Pytest coverage comment
  uses: MishaKav/pytest-coverage-comment@main
  with:
    pytest-xml-coverage-path: ./coverage.xml