XML parsing failures do not fail the action and can hide failing tests
Closed this issue · 3 comments
The current behavior if XML fails to parse is to log the following message and continue on:
⚠️ Failed to parse file (${file}) with error ${error}
This is not visible in the annotations, only if you go looking for the error. This can result in silent failures if the invalid XML contains failures. I would like to request a new option to cause parse errors to be reported more visibly. I have two suggestions:
Solution A
fail_on_parse_error
: Optional. Fail the build in case of an XML parsing error
This would be the simpler solution to merely exit immediately when reaching a parsing failure, but would make it harder to identify which XML was causing the issue.
Solution B
report_on_parse_error
: Optional. Report a failed test in case of an XML parsing error
In this solution, instead of returning an empty test suite here, a fake test suite could be returned indicating that the XML was not parsed.
Thank you for the report @aconti-ns1
Yes you are correct, the current behavior annotates it as an error to the build, however it does not fail the whole build.
https://github.com/mikepenz/action-junit-report/blob/main/src/testParser.ts#L180
I think your first proposal is a good proposal, to fail the build in case of a parsing error. as it will be the most visible way of an apparent failure due to a wrong xml.
Thanks Mike, if I can get some time to work on a PR I'll do so. Do you have a preference for the option name?
fail_on_parse_error
sounds good :)