danielpalme / ReportGenerator

ReportGenerator converts coverage reports generated by coverlet, OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.
https://reportgenerator.io
Apache License 2.0
2.58k stars 281 forks source link

Code coverage report caching deleted files #605

Closed dyapp1435 closed 1 year ago

dyapp1435 commented 1 year ago

Describe the bug It seems that ReportGenerator is caching deleted files when run in an Azure DevOps CI pipeline. Jest correctly outputs the current list of files, but the generated Cobertura report contains a file that was deleted months ago.

What I've tried

To Reproduce The following input helps to reproduce your issue:

  1. Console output of ReportGenerator
/usr/bin/dotnet /home/vsts/work/_tasks/reportgenerator_be803a55-9253-4895-a525-be570d86f161/5.1.20/tools/netcoreapp3.1/ReportGenerator.dll -reports:**/*cobertura*.xml -targetdir:/home/vsts/work/1/coveragereport -reporttypes:HtmlInline_AzurePipelines;Cobertura -sourcedirs: -historydir: -plugins: -assemblyfilters:+* -classfilters:+* -filefilters:+* -verbosity:Info -title: -tag:20230510.3_#14228 -license: settings:maximumNumberOfHistoricCoverageFiles=0

2023-05-10T15:32:05: File '/home/vsts/work/1/s/__FILE_PATH__/__FILE_NAME__.ts' does not exist (any more).

2023-05-10T15:32:05: Writing report file '/home/vsts/work/1/coveragereport/Cobertura.xml'

2023-05-10T15:32:05: Writing report file '/home/vsts/work/1/coveragereport/index.html'

2023-05-10T15:32:05: Report generation took 0.5 seconds

Finishing: Generate code coverage report
danielpalme commented 1 year ago

ReportGenerator generates its results only based on the information available in the supplied coverages files (here: -reports:**/*cobertura*.xml). One of theses files must contain the "deleted" file, otherwise it would not be available in the report.

One way to debug this further:

dyapp1435 commented 1 year ago

Thanks for the quick response! Yeah, now that I'm looking, Cobertura is definitely generating an html report with the deleted file's name. Would this issue be better submitted to the Cobertura repo?

danielpalme commented 1 year ago

Would this issue be better submitted to the Cobertura repo?

I think so, but first you should check if the file is really not available anywhere in your code base.

Every build in Azure Devops runs on a clean agent. Jest/Cobertura don't "remember" a deleted file. It must somehow still be present.

dyapp1435 commented 1 year ago

I can confirm that it's definitely not present anywhere in our repository.

dyapp1435 commented 1 year ago

I've also attempted running jest with the --clearCache and --noCache options with no change. This also does not seem to be a Cobertura issue, as when I run the test step with the --codeCoverage flag locally it does not pick up the deleted files. It only happens when using the Report Generator task in our Azure DevOps pipeline.

danielpalme commented 1 year ago

Could you please create an artifact of the coverage file supplied to ReportGenerator in your Azure DevOps pipeline.

See my comment above.

I'm pretty sure the file is listed in some of the Cobertura files.

dyapp1435 commented 1 year ago

Sorry for the delay. It's definitely listed in the Cobertura files, I can see it here: cobertura-output-51623

Should this just go to the Cobertura GitHub board?

danielpalme commented 1 year ago

The highlighted file is an HTML file. An XML file must also exist here (ReportGenerator parses the XML file).

But the result will be the same: The HTML/XML contains the name of the deleted file. I have no idea how Cobertura comes up with this file. Perhaps the corresponding GitHub board can help.